/* Variables & Design Tokens */
:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --accent-primary: #2563eb;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --highlighter: #ccff00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.2;
    overflow-x: hidden;
}

.container {
    margin-left: 10%;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    max-width: 85%;
}

main {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.category-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem;
    padding-right: 2.2rem; /* Space for the vertical label */
    position: relative;
    min-width: 250px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.category-header {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 2rem;
    background: var(--highlighter);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 8px 8px 0;
    box-shadow: -2px 0 5px rgba(0,0,0,0.05);
}

.category-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.85rem;
    font-weight: 900;
    color: #000;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-title i {
    font-size: 1rem;
    margin-bottom: 0.3rem;
    color: #000;
}

.tools-grid {
    display: grid;
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    justify-content: flex-start;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
}

/* Compact Tool Card */
.tool-card {
    background: #f1f5f9;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.1s ease;
}

.tool-card:hover {
    background: #fff;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tool-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.tool-icon-wrapper {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-icon-wrapper img {
    width: 100%;
    height: 100%;
}

footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    text-align: right;
}

footer h1 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-muted);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Responsive */
@media (max-width: 600px) {
    .container { margin-left: 5%; max-width: 90%; }
    .category-section { padding-right: 0.6rem; padding-bottom: 2.2rem; }
    .category-header { 
        top: auto; left: 0; bottom: 0; right: 0; 
        width: 100%; height: 1.8rem; 
        writing-mode: horizontal-tb;
        border-radius: 0 0 8px 8px;
    }
    .category-title { writing-mode: horizontal-tb; font-size: 0.75rem; }
    .memo-grid { grid-template-columns: 1fr; }
}

/* Category Grouping */
.category-group {
    display: flex;
    flex-wrap: nowrap; /* Keep side-by-side on desktop */
    gap: 0.75rem;
    flex: 1 1 500px;
}

@media (max-width: 600px) {
    .category-group { flex-wrap: wrap; }
}

/* Memo Section */
.memo-section {
    width: 100%;
    flex-basis: 100%;
    margin-top: 1.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.memo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--highlighter);
}

.memo-title {
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.memo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.memo-column h3 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    padding-left: 0.2rem;
    border-left: 3px solid var(--accent-primary);
}

.memo-column textarea {
    width: 100%;
    height: 240px; /* Increased to 2x (from 120px) */
    padding: 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    resize: vertical;
    font-size: 0.8rem;
    font-family: inherit;
    background: #fdfdfd;
    line-height: 1.4;
    color: #334155;
}

.memo-column textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: #fff;
}

.save-btn {
    background: var(--text-main);
    color: #fff;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.save-btn:hover {
    background: var(--accent-primary);
    transform: scale(1.05);
}

.save-btn:active {
    transform: scale(0.95);
}

/* Modal and Lock Styles */
.locked-section {
    position: relative;
    transition: all 0.5s ease;
}

.locked-section .tools-grid {
    filter: blur(12px) grayscale(1);
    pointer-events: none;
    user-select: none;
    opacity: 0.6;
}

.section-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: none; /* Only show in locked state */
}

.locked-section .section-controls {
    display: block;
}

.unlock-btn {
    background: var(--text-main);
    color: #fff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.unlock-btn:hover {
    background: var(--accent-primary);
    transform: scale(1.05);
}

.unlocked-section .tools-grid {
    filter: none;
    opacity: 1;
    pointer-events: auto;
}

.unlocked-section .section-controls {
    display: none;
}

/* Memo Lock Style */
.memo-locked textarea,
.memo-locked .d-day-list,
.memo-locked .calendar-event,
.memo-locked .calendar-input-group {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex; /* Kept flex to center, but we can toggle with JS */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    display: none; /* Initially hidden, but will be shown on load or lock */
}

.modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content h3 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.modal-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.modal-content input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.modal-content input:focus {
    border-color: var(--accent-primary);
}

.modal-actions button {
    width: 100%;
    padding: 1rem;
    background: var(--text-main);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-actions button:hover {
    background: var(--accent-primary);
}

/* D-Day Display Area Styles */
.d-day-display-area {
    margin-bottom: 1.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.85rem;
}

.d-day-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.d-day-row.urgent {
    border-bottom: 1px dashed #e2e8f0;
}

.d-day-label {
    min-width: 50px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    text-align: center;
    color: #fff;
}

.urgent .d-day-label {
    background-color: #ef4444; /* Red for urgent */
}

.regular .d-day-label {
    background-color: #3b82f6; /* Blue for regular */
}

.d-day-list {
    flex: 1;
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    white-space: nowrap;
    padding: 2px 0;
}

.d-day-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 2px 8px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    font-weight: 600;
}

.d-day-item span {
    color: #ef4444;
    margin-right: 4px;
}

/* Calendar Section Styles */
.calendar-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #f1f5f9;
}

.calendar-header-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.calendar-header-sub h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
}

.calendar-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.calendar-input-group input[type="date"],
.calendar-input-group input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
}

.calendar-input-group input[type="text"] {
    width: 200px;
}

.urgent-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: #ef4444;
}

.add-btn {
    background: var(--accent-primary);
    color: #fff;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.add-btn:hover {
    background: #1e40af;
}

.calendar-wrapper {
    overflow-x: auto;
}

.calendar-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.calendar-table th,
.calendar-table td {
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.calendar-table th {
    background: #f8fafc;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    text-align: center;
}

.calendar-day {
    height: 100px;
    width: 14.28%;
    background: #fff;
}

.calendar-day.today {
    background: #f0f7ff;
}

.calendar-day.other-month {
    background: #fcfcfc;
    color: #cbd5e1;
}

.day-number {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
}

.calendar-event {
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 2px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-event.ev-urgent {
    background: #fee2e2;
    border-left: 2px solid #ef4444;
    color: #b91c1c;
}

.calendar-event.ev-regular {
    background: #dbeafe;
    border-left: 2px solid #3b82f6;
    color: #1e40af;
}

.delete-ev {
    font-size: 0.6rem;
    color: #94a3b8;
    margin-left: 4px;
}

.delete-ev:hover {
    color: #ef4444;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .calendar-header-sub {
        flex-direction: column;
        align-items: flex-start;
    }
    .calendar-input-group {
        width: 100%;
        flex-direction: column;
    }
    .calendar-input-group input[type="text"] {
        width: 100%;
    }
    /* Mobile Calendar Responsive Fix */
    .calendar-table {
        min-width: 100%;
        table-layout: fixed;
    }
    .calendar-day {
        height: auto;
        min-height: 50px;
    }
    .calendar-table th, .calendar-table td {
        padding: 0.3rem 0.1rem;
        font-size: 0.7rem;
    }
    .day-number {
        font-size: 0.65rem;
    }
    .calendar-event {
        font-size: 0.6rem;
        padding: 1px 3px;
        line-height: 1.2;
    }
}
