/* ========== CSS Variables ========== */
:root {
    --primary: #5a7d5c;
    --primary-dark: #4a6b4c;
    --primary-light: #7a9e7e;
    --primary-lighter: #a8c4aa;
    --bg-main: #e8f0e8;
    --bg-card: #ffffff;
    --bg-sidebar: #5a7d5c;
    --bg-sidebar-hover: #4a6b4c;
    --text-primary: #2d3a2e;
    --text-secondary: #5a6b5c;
    --text-light: #8a9a8c;
    --text-white: #ffffff;
    --border: #d0ddd0;
    --border-light: #e8f0e8;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --info: #2196f3;
    --shadow: 0 2px 8px rgba(90, 125, 92, 0.12);
    --shadow-lg: 0 4px 16px rgba(90, 125, 92, 0.18);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --sidebar-width: 200px;
    --sidebar-collapsed: 60px;
    --transition: all 0.3s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 24px 16px 16px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    font-size: 32px;
    margin-bottom: 4px;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
    white-space: nowrap;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--primary-lighter);
    margin-top: 2px;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-subtitle {
    opacity: 0;
    width: 0;
}

.nav-menu {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 4px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
}

.nav-item.active {
    background: rgba(255,255,255,0.18);
    color: var(--text-white);
    font-weight: 500;
}

.nav-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.nav-text {
    margin-left: 10px;
    font-size: 14px;
    transition: opacity 0.2s;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    margin-left: 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.btn-icon {
    background: rgba(255,255,255,0.15);
    border: none;
    color: var(--text-white);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.25);
}

/* ========== Mobile Nav ========== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    z-index: 100;
    padding: 6px 0 8px;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item,
.mobile-nav-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    color: rgba(255,255,255,0.6);
    transition: var(--transition);
}

.mobile-nav-item.active,
.mobile-nav-item:active {
    color: var(--text-white);
}

.mobile-nav-icon {
    font-size: 22px;
}

.mobile-nav-text {
    font-size: 10px;
    margin-top: 2px;
}

.mobile-more-menu {
    display: none;
    position: fixed;
    bottom: 64px;
    right: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 99;
    padding: 8px;
    min-width: 160px;
}

.mobile-more-menu.show {
    display: block;
}

.mobile-more-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.mobile-more-item:hover {
    background: var(--bg-main);
}

.mobile-more-icon {
    font-size: 18px;
    margin-right: 10px;
    width: 24px;
    text-align: center;
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 28px;
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

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

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.card-body {
    color: var(--text-secondary);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-white);
}

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

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-success {
    background: var(--success);
    color: var(--text-white);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-white);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 10px 20px;
    font-size: 15px;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    transition: var(--transition);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(90, 125, 92, 0.12);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

.table th {
    background: var(--bg-main);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

.table tr:hover {
    background: rgba(90, 125, 92, 0.04);
}

.table tr:last-child td {
    border-bottom: none;
}

/* ========== Tags & Badges ========== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.tag-primary {
    background: rgba(90, 125, 92, 0.12);
    color: var(--primary);
}

.tag-success {
    background: rgba(76, 175, 80, 0.12);
    color: var(--success);
}

.tag-warning {
    background: rgba(255, 152, 0, 0.12);
    color: var(--warning);
}

.tag-danger {
    background: rgba(244, 67, 54, 0.12);
    color: var(--danger);
}

/* ========== Stats ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
}

/* ========== Dashboard Widgets ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

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

.list-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}

.list-item:last-child {
    border-bottom: none;
}

.list-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.list-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.list-action {
    flex-shrink: 0;
}

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

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

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-main);
}

/* ========== Toast ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 18px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    animation: toastIn 0.3s ease;
    min-width: 240px;
    border-left: 4px solid var(--primary);
}

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

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== Tabs ========== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-light);
    flex-wrap: wrap;
}

.tab {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

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

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

/* ========== Filter Bar ========== */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg-main);
    border-radius: var(--radius);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-label {
    font-size: 12px;
    color: var(--text-light);
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 15px;
}

/* ========== Drag & Drop ========== */
.drag-item {
    cursor: grab;
    user-select: none;
}

.drag-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    min-height: 60px;
    transition: var(--transition);
}

.drop-zone.drag-over {
    border-color: var(--primary-light);
    background: rgba(90, 125, 92, 0.06);
}

/* ========== Student Card ========== */
.student-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: var(--transition);
}

.student-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
}

.student-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.student-card-info {
    flex: 1;
    min-width: 0;
}

.student-card-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.student-card-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.student-card-score {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

/* ========== Seating Grid ========== */
.seating-grid {
    display: grid;
    gap: 10px;
    justify-content: center;
}

.seat {
    width: 80px;
    height: 60px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-light);
    background: var(--bg-main);
    transition: var(--transition);
    cursor: pointer;
}

.seat.occupied {
    border-style: solid;
    border-color: var(--primary-light);
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 500;
}

.seat:hover {
    border-color: var(--primary);
}

.seat.drag-over {
    background: rgba(90, 125, 92, 0.12);
    border-color: var(--primary);
}

.teacher-desk {
    grid-column: 1 / -1;
    text-align: center;
    padding: 12px;
    background: var(--primary-lighter);
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

/* ========== Calendar ========== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    padding: 8px 4px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
}

.calendar-day:hover {
    background: var(--border);
}

.calendar-day.has-duty {
    background: rgba(90, 125, 92, 0.12);
    border: 1px solid var(--primary-lighter);
}

.calendar-day-number {
    font-weight: 500;
}

.calendar-day-duty {
    font-size: 10px;
    color: var(--primary);
    margin-top: 2px;
    text-align: center;
    line-height: 1.2;
}

/* ========== File Upload ========== */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-main);
}

.file-upload:hover {
    border-color: var(--primary-light);
    background: rgba(90, 125, 92, 0.04);
}

.file-upload-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.file-upload-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.file-upload-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }
    .sidebar .sidebar-title,
    .sidebar .sidebar-subtitle,
    .sidebar .nav-text {
        opacity: 0;
        width: 0;
        margin-left: 0;
    }
    .main-content {
        margin-left: var(--sidebar-collapsed);
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-bottom: 80px;
    }
    .mobile-nav {
        display: flex;
    }
    .page-title {
        font-size: 18px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-group {
        width: 100%;
    }
    .filter-group .form-select,
    .filter-group .form-input {
        width: 100%;
    }
    .seating-grid {
        gap: 6px;
    }
    .seat {
        width: 60px;
        height: 50px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .card {
        padding: 14px;
    }
    .table th,
    .table td {
        padding: 8px 10px;
        font-size: 13px;
    }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* ========== Utility ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
