/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --accent: #4f46e5;
    --accent-light: #4f46e522;

    /* Light theme */
    --bg:        #f8f9fa;
    --surface:   #ffffff;
    --border:    #e2e8f0;
    --text:      #1a202c;
    --text-muted:#6b7280;
    --danger:    #ef4444;
    --warning:   #f59e0b;
    --success:   #10b981;

    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

    --sidebar-w: 220px;
    --topbar-h:  56px;
    --bottom-h:  64px;
}

[data-theme="dark"] {
    --bg:        #0f172a;
    --surface:   #1e293b;
    --border:    #334155;
    --text:      #f1f5f9;
    --text-muted:#94a3b8;
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    grid-row: 1 / -1;
    grid-column: 1;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: block;
    margin-bottom: 2rem;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li { margin-bottom: .25rem; }

.nav-links a, .sidebar-footer a {
    display: block;
    padding: .6rem .75rem;
    border-radius: 8px;
    color: var(--text);
    font-size: .9rem;
    text-decoration: none;
    transition: background .15s;
}

.nav-links a:hover, .sidebar-footer a:hover { background: var(--bg); }
.nav-links a.active, .sidebar-footer a.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: auto;
}

/* Topbar (mobile) */
.topbar {
    display: none;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title { font-weight: 600; }

.menu-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text);
    padding: .5rem;
    min-width: 44px;
    min-height: 44px;
}

/* Main content */
.main-content {
    grid-column: 2;
    padding: 2rem;
    max-width: 900px;
}

/* Bottom tab bar (mobile) */
.bottom-tabs {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: var(--bottom-h);
    z-index: 100;
}

.bottom-tabs a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    font-size: .7rem;
    color: var(--text-muted);
    text-decoration: none;
    min-height: 44px;
    gap: 2px;
    transition: color .15s;
}

.bottom-tabs a.active { color: var(--accent); }
.bottom-tabs .tab-icon { font-size: 1.2rem; }
.bottom-tabs .tab-add {
    background: var(--accent);
    color: #fff !important;
    border-radius: 50%;
    width: 48px; height: 48px;
    min-height: unset;
    margin-top: -16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    font-size: 1.5rem !important;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: var(--topbar-h) 1fr;
        padding-bottom: var(--bottom-h);
    }

    .sidebar {
        display: none;
        position: fixed;
        top: var(--topbar-h);
        left: 0; bottom: 0;
        width: 80%;
        max-width: 280px;
        z-index: 200;
        box-shadow: var(--shadow-md);
        height: auto;
    }

    .sidebar.open { display: flex; }

    .topbar { display: flex; }
    .bottom-tabs { display: flex; }

    .main-content {
        grid-column: 1;
        padding: 1rem;
    }
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem 1.2rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: opacity .15s, box-shadow .15s;
    min-height: 44px;
}

.btn:hover { opacity: .88; text-decoration: none; }
.btn-sm { padding: .4rem .8rem; min-height: 36px; font-size: .82rem; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; color: var(--text-muted); border: none; }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

/* Assignment card */
.assignment-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--class-color, var(--accent));
    border-radius: var(--radius);
    padding: .85rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    box-shadow: var(--shadow);
    margin-bottom: .6rem;
    transition: box-shadow .15s;
}

.assignment-card:hover { box-shadow: var(--shadow-md); }
.assignment-card.overdue { border-left-color: var(--danger); background: #fff5f5; }
[data-theme="dark"] .assignment-card.overdue { background: #2d1515; }
.assignment-card.done { opacity: .55; }

.card-status-btn {
    background: none;
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 28px; height: 28px;
    min-width: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    transition: border-color .15s, background .15s;
    flex-shrink: 0;
}

.card-status-btn[data-status="in_progress"] {
    border-color: var(--warning);
    background: #fef3c7;
}

.card-status-btn[data-status="done"] {
    border-color: var(--success);
    background: #d1fae5;
    color: var(--success);
}

.card-body {
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.card-body:hover { text-decoration: none; }
.card-body:hover .card-title { color: var(--accent); }
.card-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .15s;
}
.card-meta  { font-size: .8rem; color: var(--text-muted); display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .2rem; }

.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.badge-homework { background: #dbeafe; color: #1d4ed8; }
.badge-project  { background: #fce7f3; color: #9d174d; }
.badge-test     { background: #fef3c7; color: #92400e; }

.badge-priority-high   { background: #fee2e2; color: #991b1b; }
.badge-priority-medium { background: #fef9c3; color: #854d0e; }
.badge-priority-low    { background: #f1f5f9; color: #64748b; }

/* ── Section headings ────────────────────────────────────────────────────── */

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    margin-top: 1.5rem;
}

.section-head:first-child { margin-top: 0; }

.section-head h2 {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }

label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    display: block;
    width: 100%;
    padding: .6rem .8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    min-height: 44px;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

textarea { resize: vertical; min-height: 80px; }

.radio-group, .checkbox-group {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: .9rem;
    transition: border-color .15s, background .15s;
    min-height: 44px;
}

.radio-option input { display: none; }
.radio-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

/* ── Page header ─────────────────────────────────────────────────────────── */

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

.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
    font-weight: 500;
}

.flash-success { background: #d1fae5; color: #065f46; }
.flash-error   { background: #fee2e2; color: #991b1b; }
.flash-info    { background: #dbeafe; color: #1e40af; }

/* ── Auth pages ──────────────────────────────────────────────────────────── */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg);
}

.auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.auth-box h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: .25rem;
}

.auth-box .subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-box .footer-link { text-align: center; font-size: .88rem; margin-top: 1rem; color: var(--text-muted); }

/* ── Color swatches ──────────────────────────────────────────────────────── */

.swatch-group {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

.swatch {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform .1s;
}

.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: var(--text); }

/* ── Calendar ────────────────────────────────────────────────────────────── */

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.cal-nav h2 { font-size: 1.1rem; font-weight: 700; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-day-name {
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: .25rem 0;
    text-transform: uppercase;
}

.cal-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-height: 70px;
    padding: .3rem .4rem;
    font-size: .8rem;
    cursor: pointer;
    transition: box-shadow .1s;
}

.cal-day:hover { box-shadow: var(--shadow-md); }
.cal-day.today { border-color: var(--accent); font-weight: 700; }
.cal-day.other-month { opacity: .35; }

.cal-day-num { font-weight: 600; margin-bottom: .25rem; }

.cal-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin: 1px;
}

/* ── Progress bar ────────────────────────────────────────────────────────── */

.progress-bar {
    background: var(--border);
    border-radius: 99px;
    height: 6px;
    overflow: hidden;
    margin-top: .4rem;
}

.progress-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width .3s;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p { margin-bottom: 1rem; font-size: 1.05rem; }

/* ── Overlay (mobile sidebar backdrop) ───────────────────────────────────── */

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 150;
}

.overlay.open { display: block; }

/* ── Setup wizard ────────────────────────────────────────────────────────── */

.wizard-steps {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.wizard-step {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 99px;
    transition: background .3s;
}

.wizard-step.active { background: var(--accent); }

/* ── Filter bar ──────────────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.filter-bar select, .filter-bar input { width: auto; flex: 1; min-width: 130px; }

/* ── Class chip ──────────────────────────────────────────────────────────── */

.class-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .6rem;
    border-radius: 99px;
    font-size: .78rem;
    font-weight: 600;
}

.class-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
