/* ========================================
   Google Classroom Lite — Design System
   Minimal, clean, sidebar-based layout
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS Custom Properties ──────────────── */
:root {
    --bg-body: #f0f2f5;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --accent: #1a73e8;
    --accent-hover: #1765cc;
    --accent-light: #e8f0fe;
    --danger: #d93025;
    --danger-light: #fce8e6;
    --success: #1e8e3e;
    --success-light: #e6f4ea;
    --warning: #f9ab00;
    --warning-light: #fef7e0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, .1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, .12);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-w: 260px;
    --topbar-h: 56px;
    --transition: .2s ease;

    /* Course banner colors */
    --banner-1: #1a73e8;
    --banner-2: #e8710a;
    --banner-3: #137333;
    --banner-4: #8430ce;
    --banner-5: #d93025;
    --banner-6: #009688;
}

[data-theme="dark"] {
    --bg-body: #111111;
    --bg-sidebar: #1e1e1e;
    --bg-card: #252525;
    --bg-input: #2a2a2a;
    --bg-hover: #333333;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b6f73;
    --border: #3c3c3c;
    --border-light: #2e2e2e;
    --accent: #8ab4f8;
    --accent-hover: #aecbfa;
    --accent-light: #1a2744;
    --danger-light: #3c1a18;
    --success-light: #1a3328;
    --warning-light: #3c3018;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, .3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, .4);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

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

a:hover {
    text-decoration: underline;
}

/* ── AUTH PAGES ─────────────────────────── */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg-body);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
}

.auth-card .auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: .9rem;
    margin-bottom: 28px;
}

.auth-card .auth-logo {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 12px;
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: .85rem;
    color: var(--text-secondary);
}

.auth-toggle a {
    cursor: pointer;
    font-weight: 600;
}

.role-select {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.role-select label {
    flex: 1;
    text-align: center;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 500;
    transition: all var(--transition);
}

.role-select input {
    display: none;
}

.role-select input:checked+label {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

/* ── APP SHELL ─────────────────────────── */
.app-shell {
    display: none;
    min-height: 100vh;
}

.app-shell.active {
    display: flex;
}

/* ── TOPBAR ────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    gap: 12px;
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: var(--radius);
}

.topbar-hamburger:hover {
    background: var(--bg-hover);
}

.topbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-brand span {
    color: var(--accent);
}

.topbar-spacer {
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
}

/* ── SIDEBAR ───────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 12px 0;
    overflow-y: auto;
    z-index: 90;
    transition: transform .25s ease;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin: 2px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-link .icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-light);
    margin: 8px 16px;
}

.sidebar-section-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    padding: 12px 24px 4px;
}

/* ── MAIN CONTENT ──────────────────────── */
.content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: 28px 32px;
    min-height: calc(100vh - var(--topbar-h));
    flex: 1;
}

/* ── PAGE SECTIONS (SPA) ───────────────── */
.view {
    display: none;
    animation: fadeIn .2s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

/* ── PAGE HEADER ───────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── STAT CARDS ────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: .8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── COURSE CARDS ──────────────────────── */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.course-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition);
}

.course-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.course-card-banner {
    height: 80px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
}

.course-card-banner h3 {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.course-card-body {
    padding: 16px 20px;
}

.course-card-body p {
    font-size: .85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .75rem;
    color: var(--text-muted);
}

.course-code {
    font-family: monospace;
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .75rem;
    cursor: pointer;
}

.course-code:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* ── COURSE DETAIL ─────────────────────── */
.course-detail-banner {
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    margin-bottom: 24px;
    color: #fff;
}

.course-detail-banner h2 {
    font-size: 1.6rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.course-detail-banner p {
    opacity: .9;
    font-size: .9rem;
    margin-top: 4px;
}

.course-detail-banner .detail-code {
    margin-top: 8px;
    font-family: monospace;
    background: rgba(255, 255, 255, .2);
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: .8rem;
}

/* ── TABS ──────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    font-family: inherit;
}

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

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-pane {
    display: none;
    animation: fadeIn .2s ease;
}

.tab-pane.active {
    display: block;
}

/* ── GENERIC CARD ──────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
}

.card h4 {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.card p {
    font-size: .85rem;
    color: var(--text-secondary);
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

/* ── ANNOUNCEMENT CARD ─────────────────── */
.announce-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.announce-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.announce-body {
    flex: 1;
}

.announce-meta {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── BUTTONS ───────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--accent-light);
}

.btn-sm {
    padding: 6px 14px;
    font-size: .8rem;
}

.btn-icon {
    background: none;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

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

.btn-danger:hover {
    opacity: .9;
}

/* ── FORMS ─────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: .9rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border var(--transition);
}

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

textarea.form-control {
    resize: vertical;
    min-height: 90px;
}

select.form-control {
    cursor: pointer;
}

/* ── MODAL ─────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 4px;
    border-radius: var(--radius);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ── TABLE ─────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

th,
td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    background: var(--bg-body);
}

tr:hover td {
    background: var(--bg-hover);
}

/* ── BADGES ────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 10px;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-info {
    background: var(--accent-light);
    color: var(--accent);
}

/* ── SEARCH ────────────────────────────── */
.search-input {
    padding: 8px 14px;
    font-size: .85rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    min-width: 200px;
    transition: border var(--transition);
}

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

/* ── TOAST ─────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 12px);
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: .85rem;
    box-shadow: var(--shadow-md);
    animation: slideIn .25s ease;
    min-width: 260px;
    max-width: 360px;
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ── EMPTY STATE ───────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: .9rem;
    color: var(--text-secondary);
}

/* ── BACK LINK ─────────────────────────── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .85rem;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    margin-bottom: 16px;
    padding: 4px 0;
}

.back-link:hover {
    text-decoration: underline;
}

/* ── CARD META/DEADLINE ────────────────── */
.meta {
    font-size: .78rem;
    color: var(--text-muted);
}

.meta.expired {
    color: var(--danger);
    font-weight: 600;
}

/* ── GRADE INPUT ───────────────────────── */
.grade-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.grade-inline input[type="number"] {
    width: 70px;
    padding: 6px 8px;
    font-size: .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
}

.grade-inline input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── PROFILE SECTION ───────────────────── */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.profile-info h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.profile-info p {
    font-size: .85rem;
    color: var(--text-secondary);
}

/* ── SIDEBAR OVERLAY (Mobile) ──────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .3);
    z-index: 85;
}

.sidebar-overlay.active {
    display: block;
}

/* ── RESPONSIVE ────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        z-index: 95;
    }

    .topbar-hamburger {
        display: block;
    }

    .content {
        margin-left: 0;
        padding: 20px 16px;
    }

    .course-grid {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 28px 20px;
    }
}