﻿/* Google Cloud Style - Material Design CSS */
:root {
    /* Colors */
    --primary: #1a73e8;
    --primary-hover: #1557b0;
    --secondary: #5f6368;
    --success: #1e8e3e;
    --warning: #f9ab00;
    --danger: #d93025;
    --info: #1a73e8;

    --bg-body: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-sidebar: #ffffff;

    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-disabled: #80868b;

    --border-color: #dadce0;

    --sidebar-width: 256px;
    --topbar-height: 64px;

    --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 16px;
    font-weight: 500;
    color: var(--text-primary);
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 18px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Layout */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Sidebar Components */
.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    margin-right: 12px;
}

.logo-text {
    font-size: 18px;
    font-weight: 500;
    color: #5f6368;
}

.sidebar-nav {
    padding: 16px 0;
    overflow-y: auto;
    flex: 1;
}

.sidebar-nav .nav-group {
    padding: 12px 24px 8px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 8px 24px;
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
}

.sidebar-nav a .icon {
    margin-right: 16px;
    font-style: normal;
    width: 20px;
    height: 20px;
    text-align: center;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav a .icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sidebar-nav a:hover {
    background: #f1f3f4;
}

.sidebar-nav a.active {
    background: #e8f0fe;
    color: var(--primary);
}

.sidebar-nav a.active .icon {
    opacity: 1;
    color: var(--primary);
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.menu-toggle {
    display: none;
    /* Desktop hidden */
    border: none;
    background: none;
    cursor: pointer;
    padding: 8px;
    margin-right: 16px;
}


.topbar-title {
    font-size: 18px;
    font-weight: 400;
    color: var(--text-primary);
    flex: 1;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}


.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.role-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    background: #eee;
    color: #555;
}

.role-admin {
    background: #fee2e2;
    color: #b91c1c;
}

.role-teacher {
    background: #e0e7ff;
    color: #3730a3;
}

.role-student {
    background: #dcfce7;
    color: #166534;
}

.btn-logout {
    font-size: 13px;
    color: var(--primary);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 4px;
}

.btn-logout:hover {
    background: #f8f9fa;
    text-decoration: none;
}

/* Content */
.content {
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Cards */
.card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 24px;
    overflow: hidden;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 767px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Stat Cards */
.stat-card {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.stat-card.primary .stat-value {
    color: #1a73e8;
}

.stat-card.success .stat-value {
    color: #1e8e3e;
}

.stat-card.warning .stat-value {
    color: #f9ab00;
}

.stat-card.danger .stat-value {
    color: #d93025;
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Buttons - Flat High Contrast */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    height: 36px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none !important;
    line-height: normal;
}

.btn-sm {
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
}

/* Primary: Blue Background, White Text */
.btn-primary {
    background-color: #1a73e8;
    color: #ffffff !important;
    border-color: #1a73e8;
}

.btn-primary:hover {
    background-color: #1557b0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Secondary: Grey Background, Dark Text */
.btn-secondary {
    background-color: #f1f3f4;
    color: #3c4043 !important;
    border-color: transparent;
}

.btn-secondary:hover {
    background-color: #e8eaed;
    color: #202124 !important;
}

/* Warning: Orange Background, Dark Text */
.btn-warning {
    background-color: #f9ab00;
    color: #202124 !important;
    border-color: #f9ab00;
}

.btn-warning:hover {
    background-color: #e39b00;
}

/* Danger: Red Background, White Text */
.btn-danger {
    background-color: #d93025;
    color: #ffffff !important;
    border-color: #d93025;
}

.btn-danger:hover {
    background-color: #b71c1c;
}

/* Success: Green Background, White Text */
.btn-success {
    background-color: #1e8e3e;
    color: #ffffff !important;
    border-color: #1e8e3e;
}

.btn-success:hover {
    background-color: #137333;
}


.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 500;
    color: var(--text-secondary);
    background: #f8f9fa;
    white-space: nowrap;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background-color: #f8f9fa;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: #fff;
    border: 1px solid #dadce0;
    border-radius: 4px;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.form-text {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    align-items: center;
}

.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
}

.alert-info {
    color: #055160;
    background-color: #cff4fc;
    border-color: #b6effb;
}

.alert-warning {
    color: #664d03;
    background-color: #fff3cd;
    border-color: #ffecb5;
}

.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 4px;
}

.badge-success {
    color: #137333;
    background-color: #e6f4ea;
}

.badge-warning {
    color: #b05c00;
    background-color: #fef7e0;
}

.badge-secondary {
    color: #5f6368;
    background-color: #f1f3f4;
}

.badge-info {
    color: #1967d2;
    background-color: #e8f0fe;
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 22px;
    font-weight: 400;
    color: #202124;
    margin: 0;
}

.page-subtitle {
    color: #5f6368;
    margin: 4px 0 0;
    font-size: 14px;
}

/* Utilities */
.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.align-center {
    align-items: center;
}

.gap-2 {
    gap: 8px;
}

.mt-4 {
    margin-top: 24px;
}

.mb-4 {
    margin-bottom: 24px;
}

.mx-1 {
    margin-left: 4px;
    margin-right: 4px;
}

.d-inline {
    display: inline-block;
}

.text-muted {
    color: var(--text-secondary) !important;
}

.text-center {
    text-align: center;
}

.w-100 {
    width: 100%;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -12px;
    margin-left: -12px;
}

.col,
[class*="col-"] {
    padding-right: 12px;
    padding-left: 12px;
}

.col {
    flex-basis: 0;
    flex-grow: 1;
    max-width: 100%;
}

.col-auto {
    flex: 0 0 auto;
    width: auto;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }

    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Sidebar Icons Fix */
.sidebar-nav a .icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sidebar-nav a .icon {
    margin-right: 16px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Login Page Override */
body.login-body {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 48px 40px 36px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-logo {
    margin-bottom: 8px;
    font-size: 24px;
    font-weight: 500;
    color: #3c4043;
}

.login-subtitle {
    margin-bottom: 16px;
    font-size: 16px;
    color: #202124;
    font-weight: 500;
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: block;
    }

    /* Overlay when sidebar open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 990;
        display: block;
        /* JS controls existence */
        animation: fadeIn 0.2s;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }
}

/* ==================== UTILITY CLASSES ==================== */

/* Flexbox Utilities */
.d-flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

/* Gap Utilities */
.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

/* Margin/Padding Utilities */
.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

/* Text Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

/* Mobile: Button groups scroll horizontally */
@media (max-width: 767px) {
    .d-flex.gap-4 {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .d-flex.gap-4>.btn {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* ==================== TOPBAR & HEADER ==================== */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 18px;
    font-weight: 500;
    margin-left: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    /* Allow title to take available space */
}

/* Menu Toggle Button (Hamburger) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    flex-direction: column;
    justify-content: space-around;
    z-index: 101;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: all 0.3s;
}

/* User Menu in Header */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    /* Prevent wrapping */
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.role-admin {
    background: #fee2e2;
    color: #991b1b;
}

.role-teacher {
    background: #dbeafe;
    color: #1e40af;
}

.role-student {
    background: #d1fae5;
    color: #065f46;
}

.btn-logout {
    color: var(--danger);
    font-size: 13px;
    border: 1px solid var(--danger);
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    color: #fff;
    text-decoration: none;
}

/* Responsive Topbar */
@media (max-width: 767px) {
    .topbar {
        padding: 0 16px;
    }

    .menu-toggle {
        display: flex;
        /* Show hamburger on mobile */
    }

    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Adjust content margin */
    .main-wrapper {
        margin-left: 0 !important;
        /* Override desktop margin */
    }

    /* Hide less important header items */
    .user-name {
        display: none;
    }

    .topbar-title {
        font-size: 16px;
        margin-left: 12px;
    }

    /* Target specific links to hide */
    .user-menu a[href*="change_password"] {
        display: none;
    }
}

@media (min-width: 768px) {

    /* Ensure sidebar is visible on desktop */
    .sidebar {
        transform: none !important;
        width: var(--sidebar-width);
    }

    .main-wrapper {
        margin-left: var(--sidebar-width);
    }
}

/* ==================== UTILITY CLASSES ==================== */

/* Flexbox Utilities */
.d-flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

/* Gap Utilities */
.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

/* Margin/Padding Utilities */
.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

/* Text Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

/* Responsive Tables */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}