/* ============================================
   School Teacher Attendance Management System
   Main Stylesheet
   ============================================ */

/* CSS Variables */
:root {
    --primary: #1a2332;
    --primary-light: #2c3e50;
    --primary-dark: #0f141e;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--accent);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: 260px;
    background: var(--primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-brand .logo span {
    color: var(--accent);
}

.sidebar-profile {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-profile .avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 28px;
    font-weight: 700;
    color: var(--white);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.sidebar-profile .name {
    font-weight: 600;
    font-size: 16px;
}

.sidebar-profile .role {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.sidebar-nav .nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    padding: 8px 12px 4px;
    font-weight: 600;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--gray-300);
    transition: var(--transition);
    margin-bottom: 2px;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--danger);
    color: var(--white);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--gray-400);
    font-size: 14px;
    padding: 8px 0;
    transition: var(--transition);
}

.sidebar-footer a:hover {
    color: var(--white);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    background: var(--white);
    padding: 16px 32px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.top-header .left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-header .hamburger {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-700);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    background: none;
    border: none;
}

.top-header .hamburger:hover {
    background: var(--gray-100);
}

.top-header .page-title h1 {
    font-size: 20px;
    font-weight: 700;
}

.top-header .page-title p {
    font-size: 14px;
    color: var(--gray-500);
    margin: 0;
}

.top-header .right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-header .right .notification-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-600);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.top-header .right .notification-btn:hover {
    background: var(--gray-100);
}

.top-header .right .notification-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: var(--white);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 20px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.top-header .right .user-dropdown {
    position: relative;
}

.top-header .right .user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.top-header .right .user-dropdown .dropdown-toggle:hover {
    background: var(--gray-100);
}

.top-header .right .user-dropdown .dropdown-toggle .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 14px;
}

.top-header .right .user-dropdown .dropdown-toggle .name {
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-700);
}

.top-header .right .user-dropdown .dropdown-toggle .chevron {
    color: var(--gray-400);
    font-size: 12px;
}

.top-header .right .user-dropdown .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 8px;
    display: none;
    border: 1px solid var(--gray-200);
}

.top-header .right .user-dropdown .dropdown-menu.show {
    display: block;
}

.top-header .right .user-dropdown .dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 14px;
    transition: var(--transition);
}

.top-header .right .user-dropdown .dropdown-menu a:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.top-header .right .user-dropdown .dropdown-menu a i {
    width: 20px;
    color: var(--gray-500);
}

.top-header .right .user-dropdown .dropdown-menu .divider {
    height: 1px;
    background: var(--gray-200);
    margin: 6px 0;
}

/* Page Content */
.page-content {
    padding: 24px 32px;
    flex: 1;
}

/* ============================================
   Cards & Dashboard
   ============================================ */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-card .stat-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

.stat-card .stat-icon.green {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.stat-card .stat-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-card .stat-icon.yellow {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-card .stat-icon.primary {
    background: rgba(26, 35, 50, 0.1);
    color: var(--primary);
}

.stat-card .stat-number {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
}

/* ============================================
   Tables
   ============================================ */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.table-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.table-wrapper {
    overflow-x: auto;
    padding: 0 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table thead {
    background: var(--gray-50);
}

table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--gray-200);
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

table tbody tr:hover {
    background: var(--gray-50);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.badge-success {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.badge-info {
    background: rgba(6, 182, 212, 0.12);
    color: var(--info);
}

.badge-primary {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-warning:hover {
    background: #d97706;
}

.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group .form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: var(--white);
    font-family: inherit;
}

.form-group .form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-group .form-control.error {
    border-color: var(--danger);
}

.form-group .form-control.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-group .help-text {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-group .error-text {
    font-size: 13px;
    color: var(--danger);
    margin-top: 4px;
    display: none;
}

.form-group .error-text.show {
    display: block;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/* ============================================
   Filters
   ============================================ */
.filter-bar {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    padding: 20px 24px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-bar .filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-bar .filter-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.filter-bar .filter-group select,
.filter-bar .filter-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: var(--white);
}

.filter-bar .filter-group select:focus,
.filter-bar .filter-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.filter-bar .filter-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 16px 24px;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.4s ease;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: var(--warning);
}

.toast-info {
    background: var(--info);
}

.toast i {
    font-size: 20px;
}

.toast .close {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.8;
    transition: var(--transition);
}

.toast .close:hover {
    opacity: 1;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 48px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    max-width: 400px;
    margin: 0 auto;
    color: var(--gray-500);
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    gap: 6px;
    padding: 16px 24px;
    justify-content: center;
    border-top: 1px solid var(--gray-200);
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--gray-600);
    transition: var(--transition);
    border: 1px solid transparent;
}

.pagination a:hover {
    background: var(--gray-100);
}

.pagination a.active {
    background: var(--accent);
    color: var(--white);
}

.pagination a.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 20px;
}

.modal-header .close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    transition: var(--transition);
}

.modal-header .close:hover {
    color: var(--gray-800);
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
    justify-content: flex-end;
}

/* ============================================
   Profile Page
   ============================================ */
.profile-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    padding: 32px;
    max-width: 600px;
    margin: 0 auto;
}

.profile-card .profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.profile-card .profile-header .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--white);
}

.profile-card .profile-header .info h2 {
    font-size: 22px;
    margin-bottom: 2px;
}

.profile-card .profile-header .info .role-tag {
    font-size: 14px;
    color: var(--gray-500);
}

/* ============================================
   Responsive Utilities
   ============================================ */
.text-center {
    text-align: center;
}
.text-right {
    text-align: right;
}
.text-muted {
    color: var(--gray-500);
}
.mt-2 {
    margin-top: 8px;
}
.mt-4 {
    margin-top: 16px;
}
.mb-2 {
    margin-bottom: 8px;
}
.mb-4 {
    margin-bottom: 16px;
}
.mb-6 {
    margin-bottom: 24px;
}
.gap-2 {
    gap: 8px;
}
.gap-4 {
    gap: 16px;
}
.flex {
    display: flex;
}
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}
.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.flex-wrap {
    flex-wrap: wrap;
}
/* ============================================
   Additional Admin Styles
   ============================================ */

/* Avatar in table */
.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--white);
}

.avatar-sm.primary {
    background: var(--accent);
}

.avatar-sm.green {
    background: var(--success);
}

/* Text utilities */
.text-danger {
    color: var(--danger);
}

.text-muted {
    color: var(--gray-500);
}

.text-center {
    text-align: center;
}

/* HR */
hr {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 16px 0;
}

/* Empty state improvements */
.empty-state {
    padding: 40px 20px;
}

.empty-state i {
    font-size: 48px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--gray-500);
    max-width: 400px;
    margin: 0 auto;
}

/* Dashboard card improvements */
.stat-card {
    cursor: default;
}

.stat-card .stat-icon {
    flex-shrink: 0;
}

.stat-card .stat-info {
    flex: 1;
}

.stat-card .stat-number {
    line-height: 1.2;
}

/* Table action buttons */
.table-wrapper .btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Flash message improvements */
.flash-message {
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filter bar on mobile improvements */
@media (max-width: 480px) {
    .filter-bar .filter-actions .btn {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* Status badge animations */
.badge {
    transition: var(--transition);
}

.badge:hover {
    transform: scale(1.05);
}

/* Modal improvements */
.modal-body {
    padding: 4px 0 12px;
}

.modal-body p {
    margin-bottom: 8px;
}

/* Profile card improvements */
.profile-card h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.profile-card h2 i {
    color: var(--accent);
}

.profile-card h4 {
    font-size: 16px;
    margin-bottom: 8px;
}

/* Button group in table */
.table-wrapper .btn-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .table-wrapper .btn-group {
        justify-content: flex-end;
    }
}