/* =====================================================
   Botany Virtual Lab — Dashboard Layout
   ===================================================== */

/* =====================================================
   Body grid: sidebar (fixed) + topbar + main content
   ===================================================== */
.dashboard-body {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    font-size: 15px;
}

.sidebar-logo:hover { text-decoration: none; color: var(--text); }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.nav-section { display: flex; flex-direction: column; gap: 2px; }

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-2);
    padding: 0 10px;
    margin-bottom: 6px;
    font-weight: 600;
    opacity: 0.7;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    text-decoration: none;
    transition: all 0.15s;
    position: relative;
}

.nav-link:hover {
    background: var(--bg-3);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    background: rgba(0,255,136,0.1);
    color: var(--accent);
    font-weight: 600;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: rgba(0,255,136,0.15);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-2);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-3);
    margin-bottom: 8px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0a0e1a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
    font-size: 14px;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { overflow: hidden; flex: 1; }
.user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 11px;
    color: var(--text-2);
    text-transform: capitalize;
}

.logout-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* =====================================================
   Topbar
   ===================================================== */
.topbar {
    grid-area: topbar;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
    height: 60px;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
}

/* =====================================================
   MAIN CONTENT — This is the key fix
   The base.twig wraps content in <main class="site-main">.
   We override it to sit in the "main" grid cell.
   ===================================================== */
.dashboard-body .site-main {
    grid-area: main;
    overflow-y: auto;
    height: calc(100vh - 60px);
    padding: 0;
    min-height: 0;
}

/* Hide the public site footer on dashboard pages */
.dashboard-body .site-footer {
    display: none;
}

/* Main content container */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 32px 60px;
    width: 100%;
}

/* =====================================================
   Cards
   ===================================================== */
.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}

.card-header h2,
.card-header h3 {
    font-size: 16px;
    font-weight: 700;
}

/* =====================================================
   Grids
   ===================================================== */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.dash-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

/* =====================================================
   Stat cards
   ===================================================== */
.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: rgba(0,255,136,0.3);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 12px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* =====================================================
   Progress bars
   ===================================================== */
.progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 3px;
    transition: width 0.4s;
}

/* =====================================================
   Badges
   ===================================================== */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: rgba(0,255,136,0.15); color: var(--accent); }
.badge-danger  { background: rgba(255,68,102,0.15); color: var(--danger); }
.badge-warning { background: rgba(255,221,0,0.15); color: var(--warning); }
.badge-info    { background: rgba(0,170,255,0.15); color: var(--accent-2); }

/* =====================================================
   Data tables
   ===================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-2);
    font-weight: 600;
    background: rgba(255,255,255,0.02);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* =====================================================
   Info rows
   ===================================================== */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--text-2); }

/* =====================================================
   Notifications
   ===================================================== */
.notif-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.notif-msg { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.notif-time { color: var(--text-2); font-size: 11px; margin-top: 4px; opacity: 0.6; }

/* =====================================================
   Class cards
   ===================================================== */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.class-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
}

.class-card:hover {
    transform: translateY(-3px);
    border-color: rgba(0,255,136,0.3);
}

.class-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    align-items: flex-start;
    gap: 8px;
}

.class-code {
    font-family: 'Courier New', monospace;
    background: rgba(0,170,255,0.1);
    color: var(--accent-2);
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.class-card h3 { font-size: 15px; margin-bottom: 6px; line-height: 1.3; }
.class-teacher { color: var(--text-2); font-size: 13px; }

/* =====================================================
   Class rows (compact list)
   ===================================================== */
.class-list { display: flex; flex-direction: column; gap: 10px; }

.class-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}

.class-row:hover { background: rgba(255,255,255,0.04); text-decoration: none; }
.class-row-icon { font-size: 26px; flex-shrink: 0; }
.class-row-body { flex: 1; min-width: 0; }
.class-row-title {
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.class-row-meta { color: var(--text-2); font-size: 12px; }
.class-row-pct { font-weight: 700; color: var(--accent); flex-shrink: 0; }

/* =====================================================
   Lab cards
   ===================================================== */
.lab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

.lab-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s;
}

.lab-card:hover { transform: translateY(-3px); border-color: rgba(0,255,136,0.3); }

.lab-card-thumb {
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.lab-card-body { padding: 14px; }

.lab-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.lab-compact {
    display: block;
    padding: 14px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}

.lab-compact:hover { background: rgba(0,255,136,0.08); text-decoration: none; }
.lab-compact-thumb { font-size: 24px; margin-bottom: 6px; }
.lab-compact-title { font-size: 13px; font-weight: 600; }

.lab-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    margin-bottom: 8px;
    transition: all 0.2s;
}

.lab-row:hover { background: rgba(0,255,136,0.06); text-decoration: none; }
.lab-row-thumb { font-size: 22px; flex-shrink: 0; }
.lab-row-body { flex: 1; min-width: 0; }
.lab-row-title { font-weight: 600; font-size: 14px; }
.lab-row-meta { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.lab-row-cost { font-weight: 700; color: var(--accent); flex-shrink: 0; }

/* =====================================================
   Quiz cards
   ===================================================== */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.quiz-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.quiz-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* =====================================================
   Sessions
   ===================================================== */
.session-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.session-row:last-child { border-bottom: none; }

.session-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,170,255,0.15);
    color: var(--accent-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.session-body { flex: 1; min-width: 0; }
.session-title { font-weight: 600; font-size: 14px; }
.session-meta { color: var(--text-2); font-size: 12px; margin-top: 2px; }

/* =====================================================
   Pagination
   ===================================================== */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page {
    display: inline-block;
    padding: 7px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.page:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.page.active {
    background: var(--accent);
    color: #0a0e1a;
    border-color: var(--accent);
    font-weight: 700;
}

/* =====================================================
   Enroll box (class detail)
   ===================================================== */
.enroll-box {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    min-width: 240px;
    text-align: center;
}

/* =====================================================
   Filter tabs
   ===================================================== */
.filter-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    color: var(--text-2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    display: inline-block;
}

.filter-tab:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
    text-decoration: none;
}

.filter-tab.active {
    background: var(--accent);
    color: #0a0e1a;
}

/* =====================================================
   Class form (create/edit)
   ===================================================== */
.class-form .card { margin-bottom: 20px; }

/* Lab select checkboxes */
.lab-select-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.lab-select-item:hover { background: rgba(255,255,255,0.04); }
.lab-select-item input { margin-top: 3px; flex-shrink: 0; }

/* =====================================================
   Question blocks (quiz editor)
   ===================================================== */
.question-block {
    padding: 16px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    border-left: 3px solid var(--accent-2);
}

.question-block:hover { background: rgba(255,255,255,0.03); }

/* =====================================================
   Responsive — Tablet
   ===================================================== */
@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: 1fr; }
}

/* =====================================================
   Responsive — Mobile
   ===================================================== */
@media (max-width: 900px) {
    .dashboard-body {
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.25s;
        z-index: 1000;
        height: 100vh;
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-toggle { display: block; }

    .dashboard-body .site-main {
        height: calc(100vh - 60px);
    }

    .dashboard-container { padding: 20px 16px 40px; }
}