/* ==========================================================================
   TODO / WORK MODAL (TIÊU CHUẨN ARCHITECTURE.MD)
   - Glassmorphism & Dark Mode 100%
   - Responsive & Mobile First
   - Không hover translate
   - Chống tràn ngang tuyệt đối (No horizontal scroll)
   ========================================================================== */

/* Khóa cuộn khi mở modal */
body.no-scroll {
    overflow: hidden !important;
    overflow-x: hidden !important;
}

html:has(.todo-modal-backdrop.active) {
    overflow-x: hidden !important;
}

.todo-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

.todo-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.todo-modal-box {
    position: relative;
    background: var(--popup-bg);
    border: 1px solid var(--popup-border);
    border-radius: 20px;
    box-shadow: var(--popup-glow);
    width: 100%;
    max-width: 480px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    overflow-y: hidden;
    overflow-x: hidden;
    margin: auto;
    transform: scale(0.96);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.todo-modal-backdrop.active .todo-modal-box {
    transform: scale(1);
}

/* Header bar */
.todo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--popup-border);
    flex-shrink: 0;
    box-sizing: border-box;
}

.todo-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.todo-module-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    max-width: calc(100vw - 90px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.todo-module-select {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-body);
    color: var(--text-color);
    border: 1px solid var(--popup-border);
    outline: none;
    cursor: pointer;
}

/* Navigation bar */
.todo-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px 6px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.todo-month-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
    text-transform: capitalize;
    white-space: nowrap;
}

.todo-nav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.todo-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--btn-border);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.todo-nav-btn:hover {
    background: rgba(127, 127, 127, 0.12);
    border-color: #f59e0b;
    color: #f59e0b;
}

.todo-today-btn {
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--btn-border);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.todo-today-btn:hover {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border-color: #f59e0b;
}

/* Weekdays */
.todo-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    padding: 6px 12px 2px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
    box-sizing: border-box;
}

/* Calendar Grid */
.todo-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 4px 12px 10px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.todo-day-cell {
    aspect-ratio: 1;
    min-height: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease;
    border: 1px solid transparent;
}

.todo-day-cell:hover {
    background: rgba(127, 127, 127, 0.08);
}

.todo-day-solar {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text-color);
}

.todo-day-lunar {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 1px;
    line-height: 1;
}

.todo-day-cell.other-month {
    opacity: 0.32;
}

.todo-day-cell.is-today:not(.is-selected) {
    border-color: rgba(245, 158, 11, 0.7);
    background: rgba(245, 158, 11, 0.05);
}

.todo-day-cell.is-selected {
    background: #f59e0b !important;
    border-color: #f59e0b !important;
}

.todo-day-cell.is-selected .todo-day-solar {
    color: #000 !important;
    font-weight: 800;
}

.todo-day-cell.is-selected .todo-day-lunar {
    color: rgba(0, 0, 0, 0.75) !important;
    font-weight: 600;
}

.todo-day-dot {
    position: absolute;
    bottom: 3px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #f59e0b;
}

.todo-day-cell.is-selected .todo-day-dot {
    background: #000;
}

/* Date Infobar */
.todo-date-infobar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 18px;
    background: rgba(127, 127, 127, 0.05);
    border-top: 1px solid var(--popup-border);
    border-bottom: 1px solid var(--popup-border);
    flex-shrink: 0;
    box-sizing: border-box;
}

.todo-date-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.todo-date-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
}

.todo-date-lunar-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.todo-filter-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.todo-filter-btn {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--btn-border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.todo-filter-btn.active {
    background: #f59e0b;
    color: #000;
    border-color: #f59e0b;
}

/* Scroll area conforming to Architecture Section 20 */
.todo-list-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    max-height: 280px;
    min-height: 160px;
    box-sizing: border-box;
}

.todo-list-inner {
    padding: var(--general-py, 1rem) var(--general-px, 1.25rem);
    box-sizing: border-box;
}

/* Todo items */
.todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 12px;
    border: 1px solid var(--popup-border);
    margin-bottom: 8px;
    background: var(--bg-body);
    box-sizing: border-box;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.todo-item:hover {
    border-color: rgba(245, 158, 11, 0.35);
}

.todo-item.is-completed {
    opacity: 0.55;
    background: rgba(127, 127, 127, 0.03);
}

.todo-checkbox-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.todo-check-circle {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--btn-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: transparent;
    font-size: 0.75rem;
}

.todo-item.is-completed .todo-check-circle {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.todo-content {
    flex-grow: 1;
    min-width: 0;
}

.todo-title-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.35;
}

.todo-item.is-completed .todo-title-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.todo-time-badge {
    background: rgba(127, 127, 127, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.todo-priority-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.todo-priority-high { background: #ef4444; }
.todo-priority-normal { background: #3b82f6; }
.todo-priority-low { background: #10b981; }

.todo-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.todo-btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.85rem;
}

.todo-btn-icon:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Empty state */
.todo-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 16px;
    text-align: center;
    color: var(--text-muted);
}

.todo-empty-icon {
    font-size: 32px;
    color: var(--text-muted);
    margin-bottom: 12px;
    opacity: 0.6;
}

.todo-empty-text {
    font-size: 0.9rem;
    line-height: 1.45;
    margin: 0;
}

/* Bottom bar & Add Form */
.todo-footer {
    padding: 12px 18px 14px;
    border-top: 1px solid var(--popup-border);
    background: var(--popup-bg);
    flex-shrink: 0;
    box-sizing: border-box;
}

.todo-add-box {
    display: flex;
    gap: 8px;
    align-items: center;
    box-sizing: border-box;
}

.todo-add-input {
    flex-grow: 1;
    min-width: 0;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--popup-border);
    background: var(--bg-body);
    color: var(--text-color);
    padding: 0 12px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.todo-add-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.todo-time-input {
    width: 85px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--popup-border);
    background: var(--bg-body);
    color: var(--text-color);
    padding: 0 6px;
    font-size: 0.82rem;
    outline: none;
    text-align: center;
    flex-shrink: 0;
}

/* Responsive Media Query cho màn hình nhỏ (Mobile <= 480px) */
@media (max-width: 480px) {
    .todo-modal-backdrop {
        padding: 10px 8px;
    }

    .todo-header {
        padding: 10px 14px;
    }

    /* YÊU CẦU: Dòng chữ Tháng 10 năm 2026 nằm khác dòng với button điều hướng ngày tháng */
    .todo-month-nav {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 10px 14px 6px;
    }

    .todo-month-title {
        text-align: center;
        width: 100%;
        font-size: 1.05rem;
    }

    .todo-nav-actions {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .todo-weekdays {
        padding: 4px 6px 2px;
        font-size: 0.74rem;
    }

    .todo-calendar-grid {
        gap: 2px;
        padding: 4px 6px 8px;
    }

    .todo-day-cell {
        min-height: 38px;
        border-radius: 8px;
    }

    .todo-day-solar {
        font-size: 0.88rem;
    }

    .todo-day-lunar {
        font-size: 0.62rem;
    }

    /* YÊU CẦU: Chữ Thứ Tư, 14/10/2026 Âm lịch: 05/09/2026 nằm khác dòng với Tất cả Chưa xong Đã xong */
    .todo-date-infobar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 14px;
    }

    .todo-date-left {
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: baseline;
        flex-wrap: wrap;
        gap: 4px;
    }

    .todo-date-title {
        font-size: 0.86rem;
    }

    .todo-date-lunar-sub {
        font-size: 0.74rem;
    }

    .todo-filter-group {
        width: 100%;
        display: flex;
        gap: 6px;
    }

    .todo-filter-btn {
        flex: 1;
        text-align: center;
        padding: 6px 4px;
        font-size: 0.75rem;
        border-radius: 10px;
    }

    .todo-list-inner {
        padding: 10px 12px;
    }

    .todo-footer {
        padding: 10px 12px;
    }

    .todo-add-box {
        gap: 6px;
    }

    .todo-add-input {
        height: 38px;
        font-size: 0.85rem;
        padding: 0 10px;
    }

    .todo-time-input {
        width: 72px;
        height: 38px;
        font-size: 0.78rem;
        padding: 0 4px;
    }
}
