/* =========================
   1. GLOBAL THEME & RESET (Cloudflare Radar Inspired)
========================= */
:root {
    --primary: #0045A6;
    /* Cloudflare Blue */
    --primary-hover: #003682;
    --accent: #F6821F;
    /* Cloudflare Orange */

    --success: #10b981;
    --success-bg: #d1fae5;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;

    --bg-body: #F2F2F2;
    /* Radar Light Grey */
    --bg-card: #FFFFFF;

    --text-main: #000000;
    --text-muted: #666666;

    --radius-lg: 12px;
    /* Minimal rounding */
    --radius-md: 8px;
    --radius-sm: 4px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);

    /* Sidebar Theme - Dark/High Contrast */
    --sidebar-bg: #1a1a1a;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: #999999;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    background-image: url('bg.jpg'); /* Added background image */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

ul {
    list-style: none;
}

/* =========================
   2. APP LAYOUT
========================= */
.app-layout {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 64px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    color: var(--sidebar-text);
    transition: width 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar:hover {
    width: 250px;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--sidebar-text);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    overflow: hidden;
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-title i {
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle {
    display: none; /* Hidden as hover handles expansion now */
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
    margin-top: 2rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0.75rem;
    color: var(--sidebar-text-muted);
    font-weight: 500;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    width: 100%;
    overflow: hidden;
}

.nav-item i {
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.nav-item:hover {
    color: var(--sidebar-text);
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item.logout {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.nav-item.logout:hover {
    color: var(--danger);
    background: transparent;
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    flex: 1;
    margin-left: 0;
    background: transparent;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- TOP HEADER --- */
.top-header {
    background: transparent;
    padding: 2rem 2rem 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-main);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #FFFFFF;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 0.9rem;
}

.profile-avatar {
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

/* =========================
   3. CONTAINER & TYPOGRAPHY
========================= */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem 3rem 2rem;
    width: 100%;
}

.container {
    padding: 0;
}

h1,
h2,
h3 {
    color: var(--text-main);
    margin-bottom: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.25rem;
}

p {
    color: var(--text-muted);
}

/* =========================
   4. STAT CARDS (RADAR BENTO STYLE)
========================= */
.stat-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Generic Card Style */
.stat-card,
.chart-container,
.card,
.nudge-container {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    /* Minimal shadow */
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* Subtle border */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover,
.chart-container:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    gap: 1rem;
}

.stat-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    /* Slightly squarer icons */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(0, 69, 166, 0.1);
    /* Primary light wash */
    color: var(--primary);
}

.stat-card .info h3 {
    font-size: 2.5rem;
    /* Large number */
    font-weight: 800;
    margin: 0.5rem 0 0 0;
    color: var(--text-main);
    line-height: 1;
    letter-spacing: -0.03em;
}

.stat-card .info p {
    font-size: 0.95rem;
    margin: 0;
    font-weight: 500;
    color: var(--text-muted);
}

/* Contextual Colors */
.stat-card.important .icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-card .icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-card .icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.stat-card .icon.danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* =========================
   5. RECENT ACTIVITY & LISTS
========================= */
.activity-list {
    margin-top: 0.5rem;
}

.activity-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f1f1;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.95rem;
}

.activity-list li:last-child {
    border-bottom: none;
}

.activity-list .time {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f3f4f6;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    min-width: 70px;
    text-align: center;
    font-family: monospace;
}

/* =========================
   6. FORMS & INPUTS
========================= */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
    background: #FAFAFA;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 2px rgba(0, 69, 166, 0.2);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: var(--primary-hover);
}

/* =========================
   7. UTILITIES & ANIMATIONS
========================= */
.alert {
    padding: 1rem;
    background: var(--warning-bg);
    color: #92400e;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
}

.alert-danger {
    background: var(--danger-bg);
    color: #991b1b;
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

/* Table Styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid #f1f1f1;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.95rem;
}

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Dashboard Specifics */
.chart-container h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}



@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        min-height: 60px;
        position: relative;
        padding: 1rem;
    }
    
    .sidebar:hover {
        width: 100%;
    }
    
    .sidebar-brand {
        justify-content: space-between;
        width: 100%;
    }
    
    .mobile-menu-toggle {
        display: block;
        background: transparent;
        border: none;
        color: var(--sidebar-text);
        font-size: 1.5rem;
        cursor: pointer;
    }
    
    .sidebar-menu {
        display: none;
        margin-top: 1rem;
    }
    
    .sidebar-menu.show {
        display: flex;
    }
    
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.5rem 1rem 1rem 1rem;
    }
    
    .header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions form {
        margin-right: 0 !important;
    }

    .header-actions select {
        width: 100%;
    }

    .profile-pill {
        justify-content: center;
    }
    
    .page-title {
        font-size: 1.7rem;
        line-height: 1.2;
        word-break: break-word;
    }
    
    main {
        padding: 1rem;
    }
}

/* =========================
   8. LOGIN PAGE SPECIFIC (Dashboard Theme)
========================= */
.login-page {
    background-color: var(--bg-body);
    /* Cloudflare Light Grey */
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

/* Mascot Wrapper */
.mascot-container {
    width: 140px;
    height: 120px;
    margin: 0 auto -60px auto;
    /* Negative margin to pull card up or mascot down */
    position: relative;
    z-index: 2;
    /* Above card */
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.mascot-container img {
    width: 100%;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

/* Card */
.login-card {
    background: #FFFFFF;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    position: relative;
    z-index: 10;
    animation: slideUp 0.5s ease-out;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* Login Inputs */
.login-card .form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.login-card label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    display: block;
}

.login-card input {
    background: #FAFAFA;
    border: 1px solid #d1d5db;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    width: 100%;
}

.login-card input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 69, 166, 0.15);
    /* Primary Light */
}

/* Login Button */
.login-card .btn {
    background: var(--primary);
    color: white;
    font-weight: 600;
    padding: 0.875rem;
    border-radius: 6px;
    font-size: 1rem;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.login-card .btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.login-footer {
    position: absolute;
    bottom: 2rem;
    color: var(--text-muted);
    /* Darker text for light bg */
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
}

.login-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* =========================
   9. LECTURER DASHBOARD SPECIFIC
========================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 2fr 1fr;
        /* Chart 2/3, Nudge 1/3 */
    }
}

.nudge-container {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.nudge-item {
    background: #fff;
    /* Ensure it pops against grey bg if needed, or keeping white on white card needs border */
    border: 1px solid #fee2e2;
    border-left: 4px solid var(--danger);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
}

.ai-badge {
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    /* Primary to Purple */
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 12px;
    margin-left: 0.5rem;
    vertical-align: middle;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.insight-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    /* Light blue gradient */
    border: 1px solid #bfdbfe;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    color: #1e3a8a;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.insight-box i {
    color: #2563eb;
    font-size: 1.25rem;
    margin-top: 0.2rem;
}