/* Chronos Calendar Task Manager - Modernized Design System (v3) */

/* --- CSS Variables & Design Tokens --- */
:root {
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Theme colors defaults (Dark Theme) */
    --bg-app: #060913;
    --bg-sidebar: rgba(13, 20, 38, 0.45);
    --bg-surface: rgba(20, 30, 54, 0.5);
    --bg-surface-hover: rgba(30, 45, 80, 0.65);
    
    --border-color: rgba(255, 255, 255, 0.05);
    --border-color-focus: #6366f1;
    --border-glass: rgba(255, 255, 255, 0.06);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --primary-glow: rgba(99, 102, 241, 0.45);
    
    --success: #10b981;
    --success-hover: #059669;
    --success-light: rgba(16, 185, 129, 0.15);
    --success-glow: rgba(16, 185, 129, 0.4);
    
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: rgba(239, 68, 68, 0.15);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.15);

    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --border-radius-xl: 28px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme overrides */
body.light-theme {
    --bg-app: #f1f3f9;
    --bg-sidebar: rgba(255, 255, 255, 0.65);
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-hover: rgba(255, 255, 255, 0.95);
    
    --border-color: rgba(0, 0, 0, 0.06);
    --border-color-focus: #3b82f6;
    --border-glass: rgba(0, 0, 0, 0.05);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.1);
    --primary-glow: rgba(59, 130, 246, 0.3);
    
    --success: #10b981;
    --success-hover: #059669;
    --success-light: rgba(16, 185, 129, 0.15);
    --success-glow: rgba(16, 185, 129, 0.3);
}

/* --- Base & Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

input, textarea, button, select {
    font-family: inherit;
    font-size: inherit;
}

/* --- Decorative Mesh Backgrounds --- */
.mesh-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

.mesh-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    mix-blend-mode: screen;
    animation: floatAnimation 20s infinite alternate;
}

body.light-theme .mesh-blob {
    opacity: 0.1;
    mix-blend-mode: multiply;
    filter: blur(140px);
}

.blob-1 {
    width: 500px;
    height: 500px;
    background-color: var(--primary);
    top: -10%;
    right: 5%;
    animation-delay: 0s;
}

.blob-2 {
    width: 600px;
    height: 600px;
    background-color: #ec4899; /* pink accent */
    bottom: -15%;
    left: 10%;
    animation-delay: 4s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background-color: #3b82f6;
    top: 40%;
    left: 40%;
    animation-delay: 8s;
}

@keyframes floatAnimation {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(60px, -40px) scale(1.15);
    }
    100% {
        transform: translate(-40px, 50px) scale(0.9);
    }
}

/* --- App Layout --- */
.app-container {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
}

/* --- Glassmorphic Sidebar --- */
.sidebar {
    width: 280px;
    height: 100vh;
    position: sticky;
    top: 0;
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border-right: 1px solid var(--border-glass);
    padding: 2.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-shrink: 0;
    z-index: 100;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-left: 0.5rem;
}

.brand-icon {
    font-size: 2.25rem;
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.75px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Sidebar Navigation Navigation Menu */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    transform: translateX(3px);
}

body.light-theme .nav-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    box-shadow: 0 4px 15px -5px var(--primary-light);
}

.nav-icon {
    font-size: 1.35rem;
}

/* Quick Stats — pinned to bottom, more compact */
.quick-stats {
    display: flex;
    flex-direction: row;
    gap: 0.6rem;
    flex-shrink: 0;
}

.stat-card {
    background-color: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    padding: 0.75rem 0.85rem;
    border-radius: var(--border-radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    flex: 1;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-md);
}

body.light-theme .stat-card:hover {
    border-color: rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    width: 100%;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-glass);
}

/* Premium Slider Theme Toggle Switch */
.theme-switch-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.4rem 0.75rem;
    border-radius: 30px;
    border: 1px solid var(--border-glass);
}

body.light-theme .theme-switch-container {
    background-color: rgba(0, 0, 0, 0.05);
}

.theme-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    user-select: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3f3f46;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
}

body.light-theme .slider {
    background-color: #cbd5e1;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.switch input:checked + .slider {
    background-color: var(--primary);
}

.switch input:checked + .slider:before {
    transform: translateX(22px);
}

/* --- Main Content Area --- */
.main-content {
    flex: 1 1 0%;  /* grow, shrink, basis 0 — takes all remaining space without margin:auto fight */
    min-width: 0;  /* allow flex child to shrink below content size */
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* --- Header Section --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.month-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    min-width: 0; /* allow shrinking on smaller screens */
    text-align: center;
    letter-spacing: -1.25px;
    background: linear-gradient(135deg, var(--text-primary) 50%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.all-tasks-header {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-box {
    position: relative;
    width: clamp(160px, 22vw, 300px); /* fluid: shrinks on narrow screens */
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 1.25rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.65rem;
    background-color: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px var(--primary-light), 0 4px 15px rgba(99, 102, 241, 0.1);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.35rem;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-lg {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    box-shadow: 0 4px 14px var(--primary-light);
}

.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 1rem;
    font-weight: 600;
}

.btn-sm .btn-icon {
    font-size: 1rem;
}


.btn-icon {
    padding: 0.65rem;
    aspect-ratio: 1;
}

.btn-nav {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.btn-nav:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--text-muted);
    transform: scale(1.05);
}

.btn-secondary {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--text-secondary);
}

.btn-today {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 15px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

.btn-danger-soft {
    background-color: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger-soft:hover {
    background-color: var(--danger);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

.btn-danger-text {
    background: transparent;
    color: var(--danger);
    padding: 0.25rem;
    border-radius: var(--border-radius-sm);
}

.btn-danger-text:hover {
    background-color: var(--danger-light);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--border-radius-md);
}

.btn-danger-outline:hover {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

/* Danger zone separator in modals */
.modal-danger-zone {
    padding: 0 2.25rem 1.5rem;
}

.danger-zone-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.25), transparent);
    margin-bottom: 1rem;
}

.btn-block {
    width: 100%;
}

/* --- Calendar Core --- */
.calendar-container {
    background-color: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.weekdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background-color: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-glass);
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

body.light-theme .weekdays-grid {
    background-color: rgba(0, 0, 0, 0.02);
}

.weekdays-grid div {
    padding: 1.15rem 0.5rem;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(130px, 1fr);
}

/* Day Cell Style */
.day-cell {
    border-right: 1px solid var(--border-glass);
    border-bottom: 1px solid var(--border-glass);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 130px;
    cursor: pointer;
    position: relative;
    background-color: transparent;
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.day-cell:nth-child(7n) {
    border-right: none;
}

.day-cell:hover {
    background-color: var(--bg-surface-hover);
}

/* Active Highlight on Clicked/Open Day Cell */
.day-cell.selected-active {
    background-color: rgba(99, 102, 241, 0.05);
    box-shadow: inset 0 0 0 1px var(--primary);
}

body.light-theme .day-cell.selected-active {
    background-color: rgba(59, 130, 246, 0.03);
}

/* Highlight today */
.day-cell.today {
    background-color: rgba(99, 102, 241, 0.08);
}

body.light-theme .day-cell.today {
    background-color: rgba(59, 130, 246, 0.06);
}

.day-cell.today .day-number {
    background-color: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 3px 8px var(--primary-glow);
}

/* Outside month days */
.day-cell.padding-day {
    opacity: 0.25;
    background-color: rgba(0, 0, 0, 0.05);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.day-number {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Day Mini Stats Badge */
.day-hour-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

body.light-theme .day-hour-badge {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: transparent;
}

.day-cell.has-tasks .day-hour-badge {
    background-color: var(--primary-light);
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.2);
}

.day-cell.all-done .day-hour-badge {
    background-color: var(--success-light);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

/* Tasks preview on Calendar cells (Modern Connection Pill Bars) */
.day-tasks-preview {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.25rem;
    flex-grow: 1;
    overflow: hidden;
}

.mini-task {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--text-muted);
    border-radius: 4px;
    transition: all var(--transition-fast);
    margin: 0 1px;
}

body.light-theme .mini-task {
    background-color: rgba(0, 0, 0, 0.03);
}

.mini-task.completed {
    text-decoration: line-through;
    opacity: 0.4;
    border-left-color: var(--success) !important;
}

.mini-task.active {
    border-left-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

body.light-theme .mini-task.active {
    background-color: rgba(59, 130, 246, 0.08);
}

/* Range bar connection adjustments */
.mini-task.range-start {
    border-radius: 6px 0 0 6px;
    margin-right: -8px; /* touch right edge */
    padding-right: 8px;
    border-left-width: 4px;
}

.mini-task.range-mid {
    border-radius: 0;
    margin-left: -8px;
    margin-right: -8px;
    border-left: none; /* remove left border to make it continuous */
    background-color: rgba(99, 102, 241, 0.15); /* make range bar look solid */
    padding-left: 8px;
    padding-right: 8px;
}

body.light-theme .mini-task.range-mid {
    background-color: rgba(59, 130, 246, 0.12);
}

.mini-task.range-end {
    border-radius: 0 6px 6px 0;
    margin-left: -8px;
    border-left: none;
    background-color: rgba(99, 102, 241, 0.15);
    padding-left: 8px;
}

body.light-theme .mini-task.range-end {
    background-color: rgba(59, 130, 246, 0.12);
}

/* Range tasks that are completed should also merge nicely */
.mini-task.completed.range-start,
.mini-task.completed.range-mid,
.mini-task.completed.range-end {
    background-color: rgba(16, 185, 129, 0.05);
    border-left-color: var(--success);
}

/* Progress indicator line at the bottom of day cells */
.day-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width var(--transition-normal);
}

/* --- View Containers --- */
.view-container {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInView var(--transition-normal) forwards;
}

@keyframes fadeInView {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- All Tasks View Styles --- */
.all-tasks-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    padding: 1rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 1.5rem;
    gap: 1.5rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.35rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-glass);
}

body.light-theme .filter-group {
    background-color: rgba(0, 0, 0, 0.03);
}

.filter-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.15rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-tab:hover {
    color: var(--text-primary);
}

.filter-tab.active {
    background-color: var(--bg-surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-glass);
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

.select-control {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 0.5rem 1.5rem 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}

body.light-theme .select-control {
    background-color: #ffffff;
}

.select-control:focus {
    border-color: var(--border-color-focus);
    outline: none;
}

.global-tasks-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

/* Global Task Card Component */
.global-task-card {
    background-color: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.global-task-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg), 0 4px 20px rgba(99, 102, 241, 0.05);
}

.global-task-card.completed {
    opacity: 0.75;
}

.global-task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.global-task-card-left {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.global-task-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.global-task-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.3;
    color: var(--text-primary);
    word-break: break-word;
}

.global-task-card.completed .global-task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.global-task-dates {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.date-range-badge {
    background-color: rgba(255, 255, 255, 0.04);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    color: var(--text-secondary);
}

body.light-theme .date-range-badge {
    background-color: rgba(0, 0, 0, 0.04);
}

.global-task-hours {
    font-size: 0.8rem;
    font-weight: 700;
    background-color: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--border-radius-sm);
    white-space: nowrap;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.global-task-card.completed .global-task-hours {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border-color: transparent;
}

.global-task-body {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding: 0.85rem 0;
    flex-grow: 1;
}

body.light-theme .global-task-body {
    border-top-color: rgba(0, 0, 0, 0.04);
    border-bottom-color: rgba(0, 0, 0, 0.04);
}

.global-task-notes-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.global-task-notes {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.global-task-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    align-items: center;
}

/* --- Slide-out Drawer --- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    display: flex;
    justify-content: flex-end;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    width: 550px;
    max-width: 90vw;
    background-color: rgba(13, 20, 38, 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    height: 100%;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    border-left: 1px solid var(--border-glass);
}

body.light-theme .drawer {
    background-color: rgba(255, 255, 255, 0.9);
}

.drawer-overlay.open .drawer {
    transform: translateX(0);
}

.drawer-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .drawer-header {
    background-color: rgba(0, 0, 0, 0.02);
}

.drawer-date {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
}

.drawer-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.btn-close {
    background: transparent;
    color: var(--text-secondary);
}

.btn-close:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

body.light-theme .btn-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.drawer-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.drawer-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-glass);
    background-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .drawer-footer {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Day progress in drawer */
.day-progress-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    padding: 1rem;
    border-radius: var(--border-radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-bar-bg {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

body.light-theme .progress-bar-bg {
    background-color: rgba(0, 0, 0, 0.05);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width var(--transition-normal);
}

/* Tasks list in drawer */
.section-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-md);
}

.empty-icon {
    font-size: 2.5rem;
}

/* Task Item */
.task-item {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.task-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.task-item.completed-item {
    opacity: 0.75;
    background-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .task-item.completed-item {
    background-color: rgba(0, 0, 0, 0.01);
}

.task-item-main {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

/* Custom Checkbox */
.checkbox-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-top: 0.2rem;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 20px;
    width: 20px;
    background-color: transparent;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
}

.checkmark::after {
    content: "check";
    font-family: 'Material Icons Round';
    font-size: 14px;
    color: white;
    display: none;
}

.checkbox-container input:checked ~ .checkmark::after {
    display: block;
}

.task-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.task-title-text {
    font-weight: 600;
    font-size: 0.98rem;
    word-break: break-word;
    color: var(--text-primary);
}

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

.task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hour-tag {
    background-color: var(--primary-light);
    color: var(--primary);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.task-item.completed-item .hour-tag {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-color: transparent;
}

/* Notes expand/collapse and inline edits */
.task-notes-wrapper {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

body.light-theme .task-notes-wrapper {
    border-top-color: rgba(0, 0, 0, 0.04);
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
}

.notes-header:hover {
    color: var(--text-secondary);
}

.notes-icon {
    font-size: 1rem;
    transition: transform var(--transition-fast);
}

.notes-header.expanded .notes-icon {
    transform: rotate(180deg);
}

.notes-body {
    display: none;
    margin-top: 0.5rem;
}

.notes-body.expanded {
    display: block;
}

.notes-display-area {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 24px;
    padding: 0.4rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}

.notes-display-area:hover {
    background-color: rgba(255, 255, 255, 0.02);
    box-shadow: 0 0 0 1px var(--border-glass);
}

body.light-theme .notes-display-area:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.notes-editor {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    padding: 0.65rem;
    resize: vertical;
    outline: none;
}

body.light-theme .notes-editor {
    background-color: #ffffff;
}

.notes-editor:focus {
    border-color: var(--border-color-focus);
}

.notes-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* --- Global Dialog Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 600px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    background-color: rgba(13, 20, 38, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    transform: translateY(30px) scale(0.95);
    transition: transform var(--transition-normal);
}

body.light-theme .modal {
    background-color: rgba(255, 255, 255, 0.95);
}

.modal-overlay.open .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 1.5rem 2.25rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .modal-header {
    background-color: rgba(0, 0, 0, 0.02);
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.task-form-modal {
    padding: 2.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

.modal-actions-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

/* Forms layout */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-row {
    display: flex;
    gap: 1.25rem;
}

.form-row .col {
    flex: 1;
}

.form-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 0.95rem;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

body.light-theme .form-control {
    background-color: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}

.form-control:focus {
    outline: none;
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.form-control.textarea {
    resize: none;
}

/* Custom Slim Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

body.light-theme ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 200;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    padding: 1rem 1.35rem;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    transform: translateY(20px);
    opacity: 0;
    transition: all var(--transition-fast);
    pointer-events: auto;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

.toast-icon {
    font-size: 1.25rem;
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-info .toast-icon {
    color: var(--primary);
}

.toast-message {
    font-size: 0.85rem;
    font-weight: 600;
}


/* --- Folders Section --- */
.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Flexible: takes available space between nav and bottom pinned sections */
    flex: 1 1 0;
    min-height: 0; /* allow shrinking below content size */
    overflow: hidden;
}

.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem 0.35rem;
    background: rgba(255,255,255,0.02);
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
    border: 1px solid var(--border-glass);
    border-bottom: none;
    flex-shrink: 0;
}

body.light-theme .sidebar-section-header {
    background: rgba(0,0,0,0.015);
}

.sidebar-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

.btn-add-inline {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.btn-add-inline:hover {
    color: var(--primary);
    background-color: var(--primary-light);
}

body.light-theme .btn-add-inline:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.btn-add-inline span {
    font-size: 1.15rem;
}

/* Scrollable folders list panel */
.folders-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    flex: 1 1 0;
    min-height: 0;
    padding: 0.5rem 0.35rem;
    border: 1px solid var(--border-glass);
    border-top: none;
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
    background: rgba(0, 0, 0, 0.08);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

body.light-theme .folders-list {
    background: rgba(0, 0, 0, 0.02);
    scrollbar-color: rgba(0,0,0,0.08) transparent;
}

.folder-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    text-align: left;
    width: 100%;
}

.folder-nav-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    transform: translateX(2px);
}

body.light-theme .folder-nav-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.folder-nav-item.active {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.folder-nav-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.folder-color-circle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px currentColor;
}

.folder-task-count {
    font-size: 0.7rem;
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    font-weight: 700;
    border: 1px solid var(--border-glass);
}

body.light-theme .folder-task-count {
    background-color: #ffffff;
}

/* --- Color Picker in Modal --- */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #ffffff;
    transform: scale(1.15);
    box-shadow: 0 0 12px currentColor;
}

body.light-theme .color-option.selected {
    border-color: #0f172a;
}

/* --- Folder Badges on Tasks --- */
.folder-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Subtasks Checklist --- */
.subtasks-container {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

body.light-theme .subtasks-container {
    border-top-color: rgba(0, 0, 0, 0.04);
}

.subtasks-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subtasks-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.subtask-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background-color: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

body.light-theme .subtask-item {
    background-color: rgba(0, 0, 0, 0.015);
}

.subtask-item:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

body.light-theme .subtask-item:hover {
    border-color: rgba(0, 0, 0, 0.1);
}

.subtask-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-grow: 1;
}

.subtask-checkbox-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.subtask-checkbox-container input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.subtask-checkmark {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--text-muted);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.subtask-checkbox-container:hover input ~ .subtask-checkmark {
    border-color: var(--primary);
}

.subtask-checkbox-container input:checked ~ .subtask-checkmark {
    background-color: var(--success);
    border-color: var(--success);
}

.subtask-checkmark::after {
    content: "check";
    font-family: 'Material Icons Round';
    font-size: 11px;
    color: white;
    display: none;
}

.subtask-checkbox-container input:checked ~ .subtask-checkmark::after {
    display: block;
}

.subtask-title-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    word-break: break-word;
}

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

.btn-delete-subtask {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: 4px;
}

.btn-delete-subtask:hover {
    color: var(--danger);
    background-color: var(--danger-light);
}

.btn-delete-subtask span {
    font-size: 1.05rem;
}

.add-subtask-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.subtask-input {
    flex-grow: 1;
    padding: 0.4rem 0.65rem;
    font-size: 0.82rem;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

body.light-theme .subtask-input {
    background-color: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}

.subtask-input:focus {
    outline: none;
    border-color: var(--border-color-focus);
}

.btn-subtask-add {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: var(--border-radius-sm);
}

/* --- Responsiveness --- */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        overflow: visible;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        padding: 1.25rem 1.5rem;
        gap: 1.25rem;
    }
    /* In mobile/tablet: folders section resets to auto height */
    .sidebar-section {
        flex: none;
        max-height: 220px;
    }
    .sidebar-nav {
        flex-direction: row;
        width: 100%;
    }
    .nav-item {
        flex: 1;
        justify-content: center;
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: 0.65rem 0.5rem;
    }
    .nav-item:hover {
        transform: none;
    }
    .nav-item.active {
        border-bottom-color: var(--primary);
        box-shadow: none;
    }
    .quick-stats {
        flex-direction: row;
    }
    .stat-card {
        flex: 1;
    }
    .main-content {
        width: 100%;
        padding: 1.5rem 1.25rem;
    }
    .mesh-blob {
        filter: blur(80px);
    }
}

@media (max-width: 480px) {
    .modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 0.6rem;
    }
    .modal-actions-right {
        width: 100%;
        margin-left: 0;
        display: flex;
        gap: 0.5rem;
    }
    .modal-actions-right .btn,
    .modal-actions .btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-right {
        width: 100%;
    }
    .search-box {
        width: 100%;
    }
    .weekdays-grid {
        font-size: 0.75rem;
    }
    .days-grid {
        grid-auto-rows: minmax(100px, 1fr);
    }
    .day-cell {
        min-height: 100px;
        padding: 0.5rem;
    }
    .day-tasks-preview {
        display: none;
    }
    .quick-stats {
        flex-direction: column;
    }
    .all-tasks-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-group {
        justify-content: space-between;
    }
    .sort-group {
        justify-content: space-between;
    }
    .month-title {
        font-size: 2rem;
        min-width: auto;
    }
}

/* --- Right-to-Left (RTL) Arabic Stylesheet Overrides --- */
[dir="rtl"] {
    font-family: 'Cairo', var(--font-primary);
}

[dir="rtl"] .brand-name,
[dir="rtl"] .month-title,
[dir="rtl"] .drawer-date,
[dir="rtl"] .modal-title,
[dir="rtl"] .section-title,
[dir="rtl"] .global-task-title {
    font-family: 'Cairo', var(--font-heading);
}

/* Sidebar overrides */
[dir="rtl"] .sidebar {
    border-left: 1px solid var(--border-glass);
    border-right: none;
}

[dir="rtl"] .nav-item {
    border-right: 3px solid transparent;
    border-left: none;
    text-align: right;
}

[dir="rtl"] .nav-item:hover {
    transform: translateX(-3px);
}

[dir="rtl"] .nav-item.active {
    border-right-color: var(--primary);
    border-left-color: transparent;
}

[dir="rtl"] .folder-nav-item {
    border-right: 3px solid transparent;
    border-left: none;
    text-align: right;
}

[dir="rtl"] .folder-nav-item:hover {
    transform: translateX(-3px);
}

[dir="rtl"] .folder-nav-item.active {
    border-right-color: var(--primary);
    border-left-color: transparent;
}

/* Search input overrides */
[dir="rtl"] .search-icon {
    right: 0.85rem;
    left: auto;
}

[dir="rtl"] .search-box input {
    padding: 0.75rem 2.65rem 0.75rem 1rem;
}

/* Calendar grid cell overrides */
[dir="rtl"] .day-cell {
    border-left: 1px solid var(--border-glass);
    border-right: none;
}

[dir="rtl"] .day-cell:nth-child(7n) {
    border-left: none;
}

/* Range connected pills flow in RTL */
[dir="rtl"] .mini-task.range-start {
    border-radius: 0 6px 6px 0; /* round right edge */
    margin-left: -8px; /* touch left */
    margin-right: 1px;
    padding-left: 8px;
    border-right-width: 4px;
    border-left-width: 0;
}

[dir="rtl"] .mini-task.range-mid {
    border-radius: 0;
    margin-left: -8px;
    margin-right: -8px;
    border-left: none;
    border-right: none;
    padding-left: 8px;
    padding-right: 8px;
}

[dir="rtl"] .mini-task.range-end {
    border-radius: 6px 0 0 6px; /* round left edge */
    margin-right: -8px; /* touch right */
    margin-left: 1px;
    padding-right: 8px;
    border-right-width: 0;
    border-left-width: 0;
}

/* Drawer overlays sliding from left */
[dir="rtl"] .drawer-overlay {
    direction: ltr; /* Force LTR positioning on the overlay so flex-start is visually on the left edge */
    justify-content: flex-start;
}

[dir="rtl"] .drawer {
    direction: rtl; /* Restore RTL text flow and alignment inside the drawer content */
    transform: translateX(-100%);
    border-right: 1px solid var(--border-glass);
    border-left: none;
}

[dir="rtl"] .drawer-overlay.open .drawer {
    transform: translateX(0);
}

/* Tasks details formatting in RTL */
[dir="rtl"] .checkbox-container {
    margin-left: 0.75rem;
    margin-right: 0;
}

[dir="rtl"] .task-meta .hour-tag, 
[dir="rtl"] .task-meta .folder-badge {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Forms columns alignment */
[dir="rtl"] .form-row {
    flex-direction: row; /* Flex row still applies, order mirrors automatically */
}

/* Toast notifications align to right in RTL */
[dir="rtl"] .toast-container {
    right: 2rem;
    left: auto;
}

[dir="rtl"] .toast {
    border-left: none;
}

[dir="rtl"] .toast-success {
    border-right: 4px solid var(--success);
}

[dir="rtl"] .toast-info {
    border-right: 4px solid var(--primary);
}

/* --- Authentication Views --- */
.auth-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
    background: radial-gradient(circle at center, rgba(6, 9, 19, 0.8) 0%, #030408 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

body.light-theme .auth-wrapper {
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.8) 0%, #e2e8f0 100%);
}

.auth-card {
    width: 440px;
    max-width: 100%;
    background-color: rgba(13, 20, 38, 0.65);
    backdrop-filter: blur(30px) saturate(160%);
    -webkit-backdrop-filter: blur(30px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 
                0 0 50px rgba(99, 102, 241, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

body.light-theme .auth-card {
    background-color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1), 
                0 0 50px rgba(59, 130, 246, 0.05);
}

.auth-card-glow {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

body.light-theme .auth-card-glow {
    background: radial-gradient(circle, rgba(59, 130, 246, 0.05) 0%, transparent 60%);
}

.auth-header, .auth-form-modern, .auth-divider, .google-btn-wrapper, .auth-footer {
    position: relative;
    z-index: 1;
}

.auth-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.auth-logo-icon {
    font-size: 3.25rem;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.35));
    margin-bottom: 0.25rem;
}

#auth-title {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

#auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Modern Outlined Floating Labels */
.form-group-modern {
    position: relative;
    margin-bottom: 1.25rem;
}

.form-group-modern input {
    width: 100%;
    padding: 0.95rem 1.15rem;
    background: rgba(6, 9, 19, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

body.light-theme .form-group-modern input {
    background: rgba(255, 255, 255, 0.6);
}

.form-group-modern input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group-modern label {
    position: absolute;
    left: 1.15rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 500;
    pointer-events: none;
    transition: all var(--transition-fast);
}

.form-group-modern input:focus ~ label,
.form-group-modern input:not(:placeholder-shown) ~ label {
    top: 0;
    font-size: 0.72rem;
    padding: 0 0.4rem;
    background: #0b0f19;
    color: var(--primary);
    transform: translateY(-50%);
    font-weight: 600;
    border-radius: 4px;
}

body.light-theme .form-group-modern input:focus ~ label,
body.light-theme .form-group-modern input:not(:placeholder-shown) ~ label {
    background: #f8fafc;
}

.btn-modern-glow {
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.25px;
    border-radius: 12px;
    box-shadow: 0 4px 14px var(--primary-light);
}

.btn-modern-glow:hover {
    box-shadow: 0 4px 20px var(--primary-glow);
}

/* Auth Divider */
.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    margin: 0.5rem 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-glass);
}

.auth-divider:not(:empty)::before {
    margin-right: 1rem;
}

.auth-divider:not(:empty)::after {
    margin-left: 1rem;
}

/* Google Sign-in Button Container */
.google-btn-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Ensure GSI iframe renders nicely */
.google-btn-wrapper iframe {
    margin: 0 auto;
}

.auth-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-glass);
    padding-top: 1.25rem;
    margin-top: 0.5rem;
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    font-size: inherit;
    transition: color var(--transition-fast);
    padding: 0 0.25rem;
}

.btn-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* User profile display in Sidebar */
.user-profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-md);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all var(--transition-fast);
    gap: 0.5rem;
}

.user-profile-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    overflow: hidden;
    color: var(--text-primary);
}

.user-profile-info span.material-icons-round {
    font-size: 1.6rem;
    color: var(--primary);
    filter: drop-shadow(0 0 4px var(--primary-light));
}

#user-display-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

body.light-theme .btn-logout {
    background: rgba(0, 0, 0, 0.04);
}

.btn-logout:hover {
    background-color: var(--danger-light);
    color: var(--danger);
    transform: scale(1.05);
}

/* RTL Adjustments for Auth & Profile */
[dir="rtl"] .user-profile-card {
    flex-direction: row-reverse;
}


/* ============================================================
   MOBILE BOTTOM NAVIGATION BAR & SHEETS
   ============================================================ */

/* The bottom nav and sheets are only shown on mobile */
.mobile-bottom-nav,
.mobile-sheet-overlay {
    display: none;
}


@media (max-width: 768px) {

    /* Add bottom padding to main content so nothing hides behind the bar */
    .main-content {
        padding-bottom: 5rem !important;
    }

    /* Hide desktop-only sidebar sections */
    .sidebar .sidebar-section,
    .sidebar .quick-stats,
    .sidebar #user-profile-section,
    .sidebar .sidebar-footer {
        display: none !important;
    }

    /* Compact sidebar top bar */
    .sidebar {
        gap: 0.85rem !important;
        padding: 1rem 1.25rem !important;
        border-bottom: 1px solid var(--border-glass);
    }

    /* Side-by-side brand + create task button */
    .sidebar .brand {
        display: none; /* hidden — shown in bottom bar label */
    }

    .sidebar #sidebar-add-task {
        border-radius: var(--border-radius-md);
    }

    /* Nav items inline */
    .sidebar-nav {
        flex-direction: row;
    }

    .nav-item {
        flex: 1;
        justify-content: center;
        border-left: none !important;
        border-bottom: 3px solid transparent;
        padding: 0.6rem 0.5rem;
        font-size: 0.82rem;
    }

    .nav-item.active {
        border-bottom-color: var(--primary) !important;
        box-shadow: none !important;
    }

    /* ---- MOBILE BOTTOM NAV ---- */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: var(--bg-sidebar);
        backdrop-filter: blur(20px) saturate(160%);
        -webkit-backdrop-filter: blur(20px) saturate(160%);
        border-top: 1px solid var(--border-glass);
        padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
    }

    .mob-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 0.62rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        cursor: pointer;
        padding: 0.35rem 0.25rem;
        border-radius: var(--border-radius-sm);
        transition: all var(--transition-fast);
        position: relative;
    }

    .mob-nav-item .material-icons-round {
        font-size: 1.45rem;
        transition: all var(--transition-fast);
    }

    .mob-nav-item:hover,
    .mob-nav-item.active {
        color: var(--primary);
    }

    .mob-nav-item.active .material-icons-round {
        filter: drop-shadow(0 0 6px var(--primary-glow));
    }

    /* Floating add button in the center */
    .mob-nav-add-btn {
        background: linear-gradient(135deg, var(--primary), #818cf8);
        color: white !important;
        border-radius: 50%;
        width: 52px;
        height: 52px;
        flex: none;
        margin: -14px auto 0;
        box-shadow: 0 4px 18px var(--primary-glow);
        transition: all var(--transition-fast);
    }

    .mob-nav-add-btn .material-icons-round {
        font-size: 1.65rem;
        color: white;
    }

    .mob-nav-add-btn:hover {
        transform: scale(1.08) translateY(-2px);
        box-shadow: 0 6px 24px var(--primary-glow);
    }

    /* ---- MOBILE SHEETS (slide-up panels) ---- */
    .mobile-sheet-overlay {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 300;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        align-items: flex-end;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-normal);
    }

    .mobile-sheet-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-sheet {
        width: 100%;
        background: var(--bg-sidebar);
        backdrop-filter: blur(24px) saturate(180%);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        border-top: 1px solid var(--border-glass);
        border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
        padding: 1rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        transform: translateY(100%);
        transition: transform var(--transition-normal);
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
        max-height: 85vh;
        overflow-y: auto;
    }

    body.light-theme .mobile-sheet {
        background: rgba(255, 255, 255, 0.95);
    }

    .mobile-sheet-overlay.open .mobile-sheet {
        transform: translateY(0);
    }

    /* drag handle */
    .mobile-sheet-handle {
        width: 40px;
        height: 4px;
        background: var(--border-glass);
        border-radius: 2px;
        margin: 0 auto -0.5rem;
        flex-shrink: 0;
    }

    /* User row */
    .mobile-sheet-user {
        display: flex;
        align-items: center;
        gap: 0.85rem;
        background: var(--bg-surface);
        border: 1px solid var(--border-glass);
        border-radius: var(--border-radius-md);
        padding: 1rem 1.1rem;
    }

    .mobile-sheet-avatar {
        font-size: 2.4rem !important;
        color: var(--primary) !important;
        filter: drop-shadow(0 0 8px var(--primary-light));
        flex-shrink: 0;
    }

    .mobile-sheet-user-info {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        flex: 1;
        overflow: hidden;
    }

    .mobile-sheet-username {
        font-weight: 700;
        font-size: 1rem;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-sheet-user-label {
        font-size: 0.72rem;
        color: var(--text-muted);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mobile-sheet-logout {
        flex-direction: row !important;
        gap: 0.4rem;
        padding: 0.5rem 0.85rem !important;
        border-radius: var(--border-radius-md) !important;
        font-size: 0.8rem;
        font-weight: 700;
        color: var(--text-secondary) !important;
        background: rgba(239, 68, 68, 0.08) !important;
        border: 1px solid rgba(239, 68, 68, 0.15) !important;
        flex-shrink: 0;
    }

    .mobile-sheet-logout .material-icons-round {
        font-size: 1.1rem !important;
    }

    .mobile-sheet-logout:hover {
        background-color: var(--danger-light) !important;
        color: var(--danger) !important;
    }

    /* Divider */
    .mobile-sheet-divider {
        height: 1px;
        background: var(--border-glass);
        margin: 0 -1.5rem;
    }

    /* Stats row */
    .mobile-sheet-stats {
        display: flex;
        gap: 1rem;
    }

    .mobile-stat-card {
        flex: 1;
        background: var(--bg-surface);
        border: 1px solid var(--border-glass);
        border-radius: var(--border-radius-md);
        padding: 1rem;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }

    .mobile-stat-value {
        font-family: var(--font-heading);
        font-size: 1.75rem;
        font-weight: 800;
        color: var(--primary);
        letter-spacing: -0.5px;
    }

    .mobile-stat-label {
        font-size: 0.65rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.75px;
        font-weight: 700;
    }

    /* Settings rows */
    .mobile-sheet-settings {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-setting-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: var(--bg-surface);
        border: 1px solid var(--border-glass);
        border-radius: var(--border-radius-md);
        padding: 0.85rem 1.1rem;
    }

    .mobile-setting-label {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        color: var(--text-primary);
        font-weight: 600;
        font-size: 0.9rem;
    }

    .mobile-setting-label .material-icons-round {
        font-size: 1.2rem;
        color: var(--text-secondary);
    }

    .mob-select {
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--border-glass);
        color: var(--text-primary);
        padding: 0.4rem 0.75rem;
        border-radius: var(--border-radius-sm);
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
    }

    body.light-theme .mob-select {
        background: #ffffff;
    }

    .mob-select:focus {
        outline: none;
        border-color: var(--primary);
    }

    /* Close button */
    .mobile-sheet-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--border-glass);
        border-radius: var(--border-radius-md);
        color: var(--text-secondary);
        padding: 0.85rem;
        font-size: 0.9rem;
        font-weight: 700;
        cursor: pointer;
        transition: all var(--transition-fast);
        width: 100%;
        margin-top: 0.25rem;
    }

    body.light-theme .mobile-sheet-close-btn {
        background: rgba(0, 0, 0, 0.03);
    }

    .mobile-sheet-close-btn:hover {
        background: rgba(255, 255, 255, 0.07);
        color: var(--text-primary);
    }

    /* Folders sheet */
    .mobile-sheet-folders-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 0.25rem;
    }

    .mobile-sheet-title {
        font-family: var(--font-heading);
        font-size: 1.15rem;
        font-weight: 700;
        color: var(--text-primary);
    }

    .mob-folders-list {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        max-height: 45vh;
        overflow-y: auto;
    }

} /* end @media (max-width: 768px) */


/* ============================================================
   TASK FORM RESPONSIVENESS & RTL ENHANCEMENTS
   ============================================================ */

/* Form controls touch minimums & date input color schemes */
.form-control {
    min-height: 42px;
    box-sizing: border-box;
}

input[type="date"].form-control {
    min-height: 44px;
    box-sizing: border-box;
}

body.dark-theme input[type="date"].form-control {
    color-scheme: dark;
}

body.light-theme input[type="date"].form-control {
    color-scheme: light;
}

/* Modal responsive rules on mobile & small viewports */
@media (max-width: 640px) {
    .modal-overlay {
        padding: 0.5rem;
        align-items: flex-end;
    }

    .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        border-radius: var(--border-radius-xl) var(--border-radius-xl) var(--border-radius-md) var(--border-radius-md) !important;
        overflow-y: auto !important;
        margin: 0 !important;
    }

    .modal-header {
        padding: 1.15rem 1.25rem;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-surface);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .task-form-modal {
        padding: 1.25rem;
        gap: 1rem;
    }

    /* Stack start date and end date fields on small screens so date pickers never cut off! */
    .form-row {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .modal-actions {
        margin-top: 0.75rem;
        gap: 0.75rem;
    }

    .modal-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 0.75rem 0.75rem;
    }
}

/* RTL Form Adjustments */
[dir="rtl"] .form-label {
    text-align: right;
}

[dir="rtl"] .form-control {
    text-align: right;
}

[dir="rtl"] select.select-control {
    background-position: left 0.75rem center;
}

[dir="rtl"] .modal-header {
    flex-direction: row;
}

[dir="rtl"] .modal-actions {
    flex-direction: row;
}


/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* ── Tablet (769px – 1199px) ─────────────────────────────── */
@media (max-width: 1199px) {

    .sidebar {
        width: 230px;
        padding: 1.5rem 1.15rem 1.15rem;
        gap: 1.1rem;
    }

    .main-content {
        padding: 1.75rem 2rem;
        gap: 1.5rem;
    }

    .month-title {
        font-size: 1.85rem;
        letter-spacing: -0.75px;
    }

    .days-grid {
        grid-auto-rows: minmax(100px, 1fr);
    }

    .day-cell {
        min-height: 100px;
        padding: 0.55rem;
    }

    .mini-task {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
}

/* ── Compact (≤900px) — Header wraps, sidebar narrows ───── */
@media (max-width: 900px) {

    .sidebar {
        width: 190px;
        padding: 1.25rem 1rem 1rem;
        gap: 0.9rem;
    }

    .brand-name {
        font-size: 1.2rem;
        letter-spacing: -0.5px;
    }

    .brand-icon {
        font-size: 1.75rem;
    }

    .main-content {
        padding: 1.25rem 1.25rem;
        gap: 1.25rem;
    }

    /* Header wraps into two rows */
    .header {
        flex-wrap: wrap;
        gap: 0.85rem;
    }

    .header-right {
        width: 100%;
    }

    .search-box {
        width: 100%;
        max-width: none;
    }

    .month-title {
        font-size: 1.4rem;
        letter-spacing: -0.5px;
    }

    .calendar-nav {
        gap: 0.65rem;
    }

    .btn-today {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .days-grid {
        grid-auto-rows: minmax(85px, 1fr);
    }

    .day-cell {
        min-height: 85px;
        padding: 0.4rem;
        gap: 0.25rem;
    }

    .weekdays-grid div {
        padding: 0.75rem 0.25rem;
        font-size: 0.68rem;
    }

    .mini-task {
        font-size: 0.6rem;
        padding: 0.18rem 0.35rem;
    }

    .nav-item {
        padding: 0.7rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.6rem;
    }

    .nav-icon {
        font-size: 1.1rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    /* All-tasks filter bar stacks vertically */
    .all-tasks-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .sort-group {
        width: 100%;
    }

    .select-control {
        width: 100%;
    }
}

/* ── Mobile Calendar & Main Content Fixes (≤768px) ─────── */
/* (The sidebar/nav/sheet styles already live in the block above) */
@media (max-width: 768px) {

    /* Stack sidebar on top, main content below */
    .app-container {
        flex-direction: column;
    }

    /* Sidebar becomes a full-width top bar */
    .sidebar {
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        top: auto !important;
        flex-shrink: 0;
        border-right: none !important;
        border-bottom: 1px solid var(--border-glass);
    }

    /* Main content takes full width below the sidebar top bar */
    .main-content {
        width: 100% !important;
        padding: 0.85rem !important;
        padding-bottom: 5.5rem !important;
        gap: 0.85rem !important;
    }


    /* Header fits on mobile */
    .header {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .calendar-nav {
        flex: 1;
        gap: 0.4rem;
    }

    .month-title {
        font-size: 1.15rem !important;
        letter-spacing: -0.25px !important;
    }

    .header-right {
        width: 100%;
    }

    .search-box {
        width: 100% !important;
        max-width: none !important;
    }

    /* Calendar grid — compact cells on mobile */
    .days-grid {
        grid-auto-rows: minmax(62px, auto) !important;
    }

    .day-cell {
        min-height: 62px !important;
        padding: 0.3rem !important;
        gap: 0.15rem !important;
    }

    .day-number {
        font-size: 0.78rem;
    }

    .day-hour-badge {
        font-size: 0.56rem;
        padding: 0.1rem 0.25rem;
    }

    .weekdays-grid div {
        padding: 0.5rem 0 !important;
        font-size: 0.58rem;
        letter-spacing: 0.25px;
    }

    .mini-task {
        font-size: 0.58rem;
        padding: 0.12rem 0.25rem;
    }

    /* Hide "Today" button — saves space on mobile */
    .btn-today {
        display: none !important;
    }

    /* Drawer fills screen */
    .drawer {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0 !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* All-tasks view on mobile */
    .all-tasks-filters {
        flex-direction: column !important;
        align-items: flex-start;
        gap: 0.65rem;
    }

    .sort-group {
        width: 100%;
    }

    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .filter-tab {
        flex: 1;
        text-align: center;
        padding: 0.45rem 0.5rem;
        font-size: 0.78rem;
    }
}

/* ── Small Mobile (≤400px) — ultra compact ──────────────── */
@media (max-width: 400px) {

    .sidebar {
        padding: 0.75rem 0.85rem !important;
    }

    #sidebar-add-task {
        font-size: 0.72rem;
        padding: 0.4rem 0.6rem;
    }

    .days-grid {
        grid-auto-rows: minmax(52px, auto) !important;
    }

    .day-cell {
        min-height: 52px !important;
        padding: 0.2rem !important;
    }

    .mini-task {
        display: none; /* too tiny to read, hide task text in cells */
    }

    .day-tasks-preview::after {
        content: '';
        display: block;
        height: 3px;
        background: var(--primary);
        border-radius: 2px;
        opacity: 0.6;
        margin-top: 2px;
    }
}


/* ============================================================
   FOLDER MEMBERS & TASK JOIN FEATURE — Styles
   ============================================================ */

/* --- Folder nav wrapper (for hover manage-members btn) --- */
.folder-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
}

.folder-nav-wrapper .folder-nav-item {
    flex: 1;
    min-width: 0;
    border-radius: var(--border-radius-md);
}

/* Manage Members & Edit Folder buttons — hidden, slides in on hover */
.btn-folder-members,
.btn-folder-edit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0;
    height: 36px;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.btn-folder-members .material-icons-round,
.btn-folder-edit .material-icons-round {
    font-size: 1.1rem;
}

.folder-nav-wrapper:hover .btn-folder-members,
.folder-nav-wrapper:hover .btn-folder-edit {
    width: 32px;
    padding: 0 4px;
    opacity: 1;
    color: var(--primary);
    background: var(--primary-light);
}

.btn-folder-members:hover,
.btn-folder-edit:hover {
    color: var(--primary) !important;
    background: var(--primary-light) !important;
    transform: scale(1.1);
}

/* --- Folder member count badge --- */
.folder-member-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
}

/* Shared folder icon in sidebar */
.folder-shared-icon {
    font-size: 0.85rem !important;
    color: var(--text-muted);
    opacity: 0.75;
}

/* --- Task Member Avatars cluster --- */
.task-member-avatars {
    display: flex;
    align-items: center;
    margin-top: 0.35rem;
    gap: -4px; /* negative gap for overlap — achieved via margin below */
}

.task-member-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    border: 1.5px solid var(--bg-surface);
    margin-right: -5px;
    transition: transform var(--transition-fast);
    letter-spacing: 0;
    cursor: default;
    user-select: none;
}

.task-member-avatar:hover {
    transform: translateY(-2px) scale(1.1);
    z-index: 2;
}

.task-member-extra {
    background: var(--bg-surface-hover) !important;
    color: var(--text-secondary);
    font-size: 0.6rem;
    border: 1.5px solid var(--border-glass);
}

/* --- Join / Leave Task Button --- */
.btn-join-task {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: var(--border-radius-md);
    border: 1.5px solid var(--primary);
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-join-task:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-join-task.btn-joined {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}

.btn-join-task.btn-joined:hover {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

/* ─── Members Modal ────────────────────────────────────────────────────── */

.members-add-section {
    margin-bottom: 1.25rem;
}

.members-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.add-member-form {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
}

.member-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: stretch;
}

.add-member-form .form-control {
    width: 100%;
    height: 44px;
    padding: 0 1rem;
    border-radius: var(--border-radius-md);
}

.btn-add-member {
    flex-shrink: 0;
    height: 44px;
    padding: 0 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-height: 210px;
    overflow-y: auto;
    padding: 4px;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.88rem;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--primary-light);
    color: var(--primary);
}

.autocomplete-item-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Members list */
.members-list-section {
    min-height: 80px;
}

.members-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 2px;
}

.members-list::-webkit-scrollbar {
    width: 4px;
}

.members-list::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 4px;
}

/* Member count badge in modal */
.members-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
}

/* Member chip row */
.member-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
    animation: chipSlideIn 0.2s ease;
}

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

.member-chip:hover {
    background: var(--bg-surface-hover);
    border-color: rgba(255,255,255,0.1);
}

.member-chip-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.member-chip-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    min-width: 0;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.btn-remove-member {
    flex-shrink: 0;
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    opacity: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}

.member-chip:hover .btn-remove-member {
    opacity: 1;
}

/* Empty state */
.members-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
}

/* ============================================================
   USER PROFILE EDIT FEATURE — Styles
   ============================================================ */

.profile-avatar-upload-container {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-lg);
    margin-bottom: 1.25rem;
}

.avatar-preview-wrapper {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}

.profile-avatar-preview {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-light);
    border: 2px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-preview .default-avatar-icon {
    font-size: 4rem;
    color: var(--primary);
}

.avatar-upload-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform var(--transition-fast);
}

.avatar-upload-badge .material-icons-round {
    font-size: 0.95rem;
}

.avatar-upload-badge:hover {
    transform: scale(1.15);
    background: var(--primary-hover);
}

.avatar-upload-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.avatar-buttons-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-danger-soft {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
    transition: all var(--transition-fast);
}

.btn-danger-soft:hover {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}

.media-size-notice {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.media-size-notice strong {
    color: var(--primary);
}

/* User avatar circles in sidebar & header */
.user-avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    flex-shrink: 0;
}

.user-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-details-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- Loader System --- */

/* 1. Top Loading Progress Bar for API Requests */
.top-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #ec4899, #3b82f6);
    box-shadow: 0 0 12px var(--primary);
    z-index: 99999;
    transition: width 0.3s ease, opacity 0.4s ease;
    opacity: 0;
    pointer-events: none;
}

.top-progress-bar.loading {
    opacity: 1;
    animation: topProgressAnim 1.4s infinite ease-in-out;
}

@keyframes topProgressAnim {
    0% { width: 0%; left: 0; }
    50% { width: 75%; left: 12.5%; }
    100% { width: 100%; left: 0; }
}

/* 2. Global Page Splash & Refresh Loader */
.global-page-loader {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 90000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

body.light-theme .global-page-loader {
    background: rgba(248, 250, 252, 0.96);
}

.global-page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    text-align: center;
}

.loader-logo-ring {
    position: relative;
    width: 84px;
    height: 84px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loader-logo-icon {
    font-size: 2.6rem;
    color: var(--primary);
    filter: drop-shadow(0 0 16px rgba(99, 102, 241, 0.6));
    animation: pulseLogo 1.8s infinite alternate ease-in-out;
}

.loader-spinner-ring {
    position: absolute;
    inset: 0;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--primary);
    border-right-color: #ec4899;
    border-radius: 50%;
    animation: spinRing 0.9s linear infinite;
}

body.light-theme .loader-spinner-ring {
    border-color: rgba(0, 0, 0, 0.08);
    border-top-color: var(--primary);
    border-right-color: #ec4899;
}

.loader-brand-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.loader-status-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

@keyframes spinRing {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseLogo {
    0% { transform: scale(0.92); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 1; }
}

/* 3. Button Loading & Spinner States */
.btn-loading {
    position: relative;
    pointer-events: none !important;
    opacity: 0.82 !important;
}

.btn-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spinRing 0.75s linear infinite;
    margin-right: 0.45rem;
    vertical-align: middle;
}

html[dir="rtl"] .btn-spinner {
    margin-right: 0;
    margin-left: 0.45rem;
}
