/* ============================
   SchoolOS - School Management System
   Custom Styles
   ============================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0891b2;
    --dark: #1e293b;
    --light: #f8fafc;
    --white: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 60px;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f1f5f9;
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ============================
   Login Page
   ============================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1e40af 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
    animation: rotate 30s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.login-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo .logo-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.login-logo .logo-icon i {
    font-size: 32px;
    color: var(--white);
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 13px;
    color: var(--secondary);
}

.login-card .form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
}

.login-card .form-control {
    height: 44px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border-color);
    font-size: 14px;
    padding: 0 14px;
    transition: var(--transition);
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.login-card .input-group-text {
    background: var(--light);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius) 0 0 var(--radius);
    color: var(--secondary);
    height: 44px;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card .input-group .form-control {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.btn-login {
    height: 46px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: var(--white);
    transition: var(--transition);
    width: 100%;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-dark), #1e40af);
    color: var(--white);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--secondary);
}

/* ============================
   Sidebar
   ============================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: var(--white);
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.sidebar-brand {
    padding: 20px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon i {
    font-size: 18px;
    color: var(--white);
}

.sidebar-brand .brand-text h5 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    color: var(--white);
}

.sidebar-brand .brand-text span {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-menu {
    padding: 12px 0;
}

.sidebar-menu .menu-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    padding: 12px 20px 8px;
    font-weight: 600;
}

.sidebar-menu .nav-item {
    padding: 0 12px;
    margin-bottom: 2px;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.65);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.sidebar-menu .nav-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu .nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.sidebar-menu .nav-link.active {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.sidebar-menu .nav-link .badge {
    margin-left: auto;
    font-size: 10px;
    padding: 3px 7px;
}

.sidebar-menu .nav-link .link-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: var(--transition);
}

.sidebar-menu .nav-link[aria-expanded="true"] .link-arrow {
    transform: rotate(90deg);
}

.sidebar-menu .collapse {
    padding-left: 28px;
}

.sidebar-menu .collapse .nav-link {
    font-size: 13px;
    padding: 8px 14px;
}

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

/* ============================
   Sidebar Collapsed State (Desktop)
   ============================ */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-brand {
    padding: 20px 0;
    justify-content: center;
}

.sidebar.collapsed .sidebar-brand .brand-text,
.sidebar.collapsed .sidebar-menu .menu-label,
.sidebar.collapsed .sidebar-menu .nav-link span,
.sidebar.collapsed .sidebar-menu .nav-link .badge,
.sidebar.collapsed .sidebar-menu .nav-link .link-arrow,
.sidebar.collapsed .sidebar-menu .collapse {
    display: none;
}

.sidebar.collapsed .sidebar-menu .nav-link {
    justify-content: center;
    padding: 10px;
}

.sidebar.collapsed .nav-item {
    position: relative;
}

.sidebar.collapsed .nav-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1100;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}

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

/* ============================
   Page Transition (prevents the
   "jump" / flash feeling when
   navigating between pages)
   ============================ */
html.js body {
    opacity: 0;
}

html.js body.page-ready {
    opacity: 1;
    animation: pageFadeIn 0.18s ease-in;
}

/* Sidebar pre-collapsed (set before first paint from localStorage) so the
   sidebar doesn't render wide then suddenly shrink on every navigation */
html.sidebar-pre-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

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

@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Prevent sidebar state flash-of-wrong-state before JS applies it */
.sidebar, .main-content {
    transition: width 0.2s ease, margin-left 0.2s ease, transform 0.2s ease;
}

/* ============================
   Top Header
   ============================ */
.top-header {
    height: var(--header-height);
    background: var(--white);
    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: 999;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--dark);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.header-search {
    position: relative;
}

.header-search input {
    width: 300px;
    height: 38px;
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    padding: 0 16px 0 40px;
    font-size: 13px;
    background: var(--light);
    transition: var(--transition);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    width: 360px;
}

.header-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary);
    font-size: 14px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--secondary);
    position: relative;
    transition: var(--transition);
}

.header-btn:hover {
    background: var(--light);
    color: var(--dark);
}

.header-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--white);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    margin-left: 8px;
}

.header-user:hover {
    background: var(--light);
}

.header-user img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
}

.header-user .user-info {
    line-height: 1.3;
}

.header-user .user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
}

.header-user .user-info .role {
    font-size: 11px;
    color: var(--secondary);
}

/* ============================
   Global Search
   ============================ */
.global-search {
    position: relative;
}

.global-search .search-trigger {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--secondary);
    transition: var(--transition);
}

.global-search .search-trigger:hover {
    background: var(--light);
    color: var(--dark);
}

.global-search .search-input-wrapper {
    position: relative;
    display: none;
}

.global-search .search-input-wrapper.active {
    display: block;
}

.global-search .search-input {
    width: 280px;
    height: 38px;
    border: 1.5px solid var(--primary);
    border-radius: 20px;
    padding: 0 16px 0 40px;
    font-size: 13px;
    background: var(--white);
    transition: var(--transition);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.global-search .search-input:focus {
    width: 320px;
}

.global-search .search-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    font-size: 14px;
}

.global-search .search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    font-size: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.global-search .search-clear:hover {
    background: var(--light);
    color: var(--dark);
}

.search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1001;
}

.search-overlay.active {
    display: block;
}

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 360px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 1002;
    display: none;
}

.search-results-dropdown.active {
    display: block;
}

.search-results-dropdown .search-category {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--secondary);
    background: var(--light);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
}

.search-results-dropdown .search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--dark);
    border-bottom: 1px solid #f1f5f9;
}

.search-results-dropdown .search-item:hover,
.search-results-dropdown .search-item.highlighted {
    background: var(--primary-light);
}

.search-results-dropdown .search-item i {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: var(--light);
    color: var(--primary);
    flex-shrink: 0;
}

.search-results-dropdown .search-item .item-info {
    flex: 1;
    min-width: 0;
}

.search-results-dropdown .search-item .item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-results-dropdown .search-item .item-name mark {
    background: #fef08a;
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

.search-results-dropdown .search-item .item-role {
    font-size: 11px;
    color: var(--secondary);
}

.no-results {
    padding: 30px 20px;
    text-align: center;
    color: var(--secondary);
}

.no-results i {
    font-size: 36px;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.no-results p {
    font-size: 13px;
    margin: 0;
}

/* ============================
   Notification Badge
   ============================ */
.notification-badge {
    position: relative;
}

.notification-badge .badge-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--white);
    line-height: 1;
}

/* ============================
   Profile Dropdown
   ============================ */
.profile-dropdown {
    position: relative;
}

.profile-dropdown .header-user {
    border: 0;
    background: transparent;
    font-family: inherit;
    text-align: left;
}

.profile-dropdown .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 8px 0;
    z-index: 1000;
    display: none;
    animation: dropdownFade 0.2s ease;
}

.profile-dropdown .dropdown-menu.show {
    display: block;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--dark);
    transition: var(--transition);
}

.profile-dropdown .dropdown-item:hover {
    background: var(--light);
    color: var(--primary);
}

.profile-dropdown .dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--secondary);
    font-size: 14px;
}

.profile-dropdown .dropdown-item:hover i {
    color: var(--primary);
}

.profile-dropdown .dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.profile-dropdown .dropdown-item.danger {
    color: var(--danger);
}

.profile-dropdown .dropdown-item.danger i {
    color: var(--danger);
}

/* Live camera capture */
.camera-dialog { max-width: 560px; }
.camera-frame { background: #0f172a; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.camera-frame video, .camera-frame img { width: 100%; height: 100%; object-fit: cover; }
.camera-frame img[hidden], .camera-frame video[hidden] { display: none; }

/* Camera Modal */
.camera-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.camera-modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    overflow: hidden;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.camera-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.camera-modal-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.camera-modal-header h5 i {
    color: var(--primary);
}

.camera-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--secondary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.camera-close:hover {
    color: var(--dark);
}

.camera-modal-body {
    padding: 16px;
}

.camera-preview-container {
    position: relative;
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
    margin-bottom: 16px;
}

.camera-preview-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.camera-frame {
    width: 80%;
    height: 80%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
}

.camera-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.camera-controls .btn {
    flex: 1;
    min-width: 100px;
}

/* Photo upload button group */
.photo-upload-group {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.photo-upload-group .form-control {
    flex: 1;
}

.photo-upload-group .btn-camera {
    height: 42px;
    padding: 0 14px;
    white-space: nowrap;
}

@media (max-width: 576px) {
    .camera-modal-content {
        margin: 10px;
    }

    .camera-controls {
        flex-direction: column;
    }

    .camera-controls .btn {
        width: 100%;
    }
}

/* CNIC Duplicate Warning */
.cnic-warning {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

.cnic-warning-text {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.cnic-warning-text.show {
    display: block;
}

/* ============================
   Page Content
   ============================ */
.page-content {
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h4 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.page-header .breadcrumb {
    font-size: 13px;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
}

.page-header .breadcrumb a {
    color: var(--primary);
}

.page-header .breadcrumb a:hover {
    text-decoration: underline;
}

.page-header .breadcrumb .separator {
    color: #cbd5e1;
}

.page-header .breadcrumb .current {
    color: var(--secondary);
}

/* ============================
   Stats Cards
   ============================ */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-card .stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-card .stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-card .stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-card .stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-card .stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-card .stat-icon.teal { background: #ccfbf1; color: #0d9488; }
.stat-card .stat-icon.pink { background: #fce7f3; color: #db2777; }
.stat-card .stat-icon.yellow { background: #fef9c3; color: #ca8a04; }

.stat-card .stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-info p {
    font-size: 13px;
    color: var(--secondary);
    margin: 0;
}

.stat-card .stat-info .stat-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================
   Cards
   ============================ */
.fims-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.fims-card .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
}

.fims-card .card-header h5 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fims-card .card-header h5 i {
    color: var(--primary);
}

.fims-card .card-body {
    padding: 20px;
}

/* ============================
   Tables
   ============================ */
.fims-table {
    width: 100%;
    border-collapse: collapse;
}

.fims-table thead th {
    background: var(--light);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.fims-table tbody td {
    padding: 12px 16px;
    font-size: 13.5px;
    color: var(--dark);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.fims-table tbody tr:hover {
    background: #f8fafc;
}

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

/* ============================
   Buttons
   ============================ */
.btn-fims {
    height: 38px;
    padding: 0 18px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

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

.btn-fims-primary:hover {
    background: var(--primary-dark);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

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

.btn-fims-success:hover {
    background: #15803d;
    color: var(--white);
}

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

.btn-fims-danger:hover {
    background: #b91c1c;
    color: var(--white);
}

.btn-fims-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--dark);
}

.btn-fims-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-fims-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

/* ============================
   Badges
   ============================ */
.badge-fims {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-fims.success { background: #dcfce7; color: #16a34a; }
.badge-fims.danger { background: #fee2e2; color: #dc2626; }
.badge-fims.warning { background: #fef3c7; color: #d97706; }
.badge-fims.info { background: #e0f2fe; color: #0284c7; }
.badge-fims.primary { background: #dbeafe; color: #2563eb; }
.badge-fims.secondary { background: #f1f5f9; color: #64748b; }
.badge-fims.purple { background: #f3e8ff; color: #9333ea; }

/* Alias support: some pages use "badge-fims badge-success" instead of
   "badge-fims success" - support both so badges always render with color */
.badge-fims.badge-success { background: #dcfce7; color: #16a34a; }
.badge-fims.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-fims.badge-warning { background: #fef3c7; color: #d97706; }
.badge-fims.badge-info { background: #e0f2fe; color: #0284c7; }
.badge-fims.badge-primary { background: #dbeafe; color: #2563eb; }
.badge-fims.badge-secondary { background: #f1f5f9; color: #64748b; }
.badge-fims.badge-purple { background: #f3e8ff; color: #9333ea; }
.badge-fims.badge-light { background: #f1f5f9; color: #64748b; }

/* ============================
   Forms
   ============================ */
.fims-form .form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
}

.fims-form .form-control,
.fims-form .form-select {
    height: 42px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border-color);
    font-size: 14px;
    padding: 0 14px;
    transition: var(--transition);
}

.fims-form .form-control:focus,
.fims-form .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.fims-form textarea.form-control {
    height: auto;
    padding: 12px 14px;
}

/* ============================
   Avatar
   ============================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.avatar-sm { width: 32px; height: 32px; }
.avatar-lg { width: 56px; height: 56px; }

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

/* ============================
   Quick Actions / Action Buttons
   ============================ */
.action-btns {
    display: flex;
    gap: 4px;
}

.action-btns .btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.btn-icon.view { background: #dbeafe; color: #2563eb; }
.btn-icon.view:hover { background: #2563eb; color: #fff; }
.btn-icon.edit { background: #dcfce7; color: #16a34a; }
.btn-icon.edit:hover { background: #16a34a; color: #fff; }
.btn-icon.delete { background: #fee2e2; color: #dc2626; }
.btn-icon.delete:hover { background: #dc2626; color: #fff; }
.btn-icon.print { background: #f3e8ff; color: #9333ea; }
.btn-icon.print:hover { background: #9333ea; color: #fff; }

/* ============================
   Notice / Announcement Popup
   ============================ */
.notice-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 380px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 9999;
    animation: slideIn 0.4s ease;
    display: none;
}

.notice-popup.show {
    display: block;
}

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

.notice-popup .notice-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: var(--white);
}

.notice-popup .notice-header h6 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--white);
}

.notice-popup .notice-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: var(--white);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

.notice-popup .notice-body {
    padding: 16px 18px;
    max-height: 300px;
    overflow-y: auto;
}

.notice-popup .notice-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.notice-popup .notice-item .notice-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 2px;
}

.notice-popup .notice-item .notice-text {
    font-size: 12px;
    color: var(--secondary);
}

.notice-popup .notice-item .notice-date {
    font-size: 11px;
    color: var(--secondary);
    margin-top: 4px;
}

/* ============================
   Attendance Badge Styles
   ============================ */
.att-present { background: #dcfce7; color: #16a34a; }
.att-absent { background: #fee2e2; color: #dc2626; }
.att-late { background: #fef3c7; color: #d97706; }
.att-leave { background: #e0f2fe; color: #0284c7; }

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

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

.calendar-day {
    text-align: center;
    padding: 8px 4px;
    font-size: 13px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

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

.calendar-day.today {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
}

.calendar-day.has-event {
    position: relative;
}

.calendar-day.has-event::after {
    content: '';
    width: 4px;
    height: 4px;
    background: var(--danger);
    border-radius: 50%;
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.calendar-day.inactive {
    color: #cbd5e1;
}

/* ============================
   Modal Customization
   ============================ */
.modal-fims .modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-fims .modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

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

.modal-fims .modal-body {
    padding: 20px;
}

.modal-fims .modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

/* ============================
   Empty State
   ============================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.empty-state .empty-icon i {
    font-size: 36px;
    color: #cbd5e1;
}

.empty-state h5 {
    font-size: 18px;
    color: var(--dark);
    margin-bottom: 6px;
    font-weight: 600;
}

.empty-state p {
    font-size: 14px;
    color: var(--secondary);
    margin-bottom: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================
   Profile / User Card
   ============================ */
.profile-card {
    text-align: center;
    padding: 24px;
}

.profile-card .profile-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-light);
    margin-bottom: 12px;
}

.profile-card h5 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.profile-card .profile-role {
    font-size: 13px;
    color: var(--secondary);
}

.profile-info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.profile-info-row:last-child {
    border-bottom: none;
}

.profile-info-row .label {
    color: var(--secondary);
    font-weight: 500;
}

.profile-info-row .value {
    color: var(--dark);
    font-weight: 600;
}

/* ============================
   Sidebar Overlay (mobile)
   ============================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* ============================
   Chart placeholder
   ============================ */
.chart-placeholder {
    background: linear-gradient(135deg, var(--light), #e2e8f0);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    color: var(--secondary);
    font-size: 14px;
    font-weight: 500;
}

/* ============================
   Loading Spinner
   ============================ */
.fims-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(37,99,235,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================
   Notification Panel
   ============================ */
.notification-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 1000;
    display: none;
    animation: dropdownFade 0.2s ease;
}

.notification-panel.show {
    display: block;
}

.notification-panel .notif-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notification-panel .notif-header h6 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.notification-panel .notif-list {
    max-height: 380px;
    overflow-y: auto;
}

.notification-panel .notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    transition: var(--transition);
    cursor: pointer;
}

.notification-panel .notif-item:hover {
    background: var(--light);
}

.notification-panel .notif-item.unread {
    background: #f0f7ff;
}

.notification-panel .notif-item .notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary);
}

.notification-panel .notif-item .notif-text {
    font-size: 13px;
    color: var(--dark);
    line-height: 1.4;
}

.notification-panel .notif-item .notif-text strong {
    font-weight: 600;
}

.notification-panel .notif-item .notif-time {
    font-size: 11px;
    color: var(--secondary);
    margin-top: 2px;
}

.notification-panel .notif-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.notification-panel .notif-footer a {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}

/* ============================
   Scrollbar
   ============================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .header-search input {
        width: 200px;
    }

    .header-search input:focus {
        width: 240px;
    }

    .global-search .search-input {
        width: 200px;
    }

    .global-search .search-input:focus {
        width: 240px;
    }

    .search-results-dropdown {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .main-content,
    .page-content,
    .container-fluid {
        min-width: 0;
    }

    .header-left {
        min-width: 0;
    }

    .header-right {
        flex-shrink: 0;
    }

    .page-header,
    .page-content .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* Plain page headers (d-flex justify-content-between) used across modules */
    .container-fluid .d-flex.justify-content-between.align-items-center.mb-4,
    .container-fluid.mt-4 .d-flex.justify-content-between.align-items-center,
    .page-content .d-flex.justify-content-between.align-items-center {
        flex-wrap: wrap;
        row-gap: 12px;
    }
    .container-fluid .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child,
    .container-fluid.mt-4 .d-flex.justify-content-between.align-items-center > div:last-child,
    .page-content .d-flex.justify-content-between.align-items-center > div:last-child {
        flex-wrap: wrap;
        width: 100%;
    }

    .page-header .d-flex.gap-2,
    .page-header > div:last-child {
        flex-wrap: wrap;
        width: 100%;
    }

    .page-header .btn-fims,
    .page-header .btn {
        flex: 1 1 auto;
    }

    .fims-card .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100% - 24px);
        margin: 12px auto;
    }

    .stat-card {
        margin-bottom: 4px;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs::-webkit-scrollbar {
        height: 3px;
    }

    .top-header {
        padding: 0 14px;
    }

    .profile-dropdown .dropdown-menu {
        position: fixed;
        top: calc(var(--header-height) - 4px);
        right: 12px;
        width: min(220px, calc(100vw - 24px));
        z-index: 1050;
    }

    .container-fluid.px-4 {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .table-responsive {
        border-radius: var(--radius);
        -webkit-overflow-scrolling: touch;
    }

    /* Unwrapped fims-tables: make them scroll horizontally on small screens
       instead of blowing out the page width */
    .fims-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .fims-table th,
    .fims-table td {
        white-space: nowrap;
    }
    .table-responsive .fims-table {
        display: table;
        overflow-x: visible;
        width: 100%;
    }

    /* Bootstrap plain tables (table-hover etc.) not wrapped in .table-responsive */
    .table.table-hover,
    .table.table-bordered,
    .table.align-middle,
    .table.mb-0 {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table.table-hover th,
    .table.table-hover td,
    .table.table-bordered th,
    .table.table-bordered td,
    .table.align-middle th,
    .table.align-middle td,
    .table.mb-0 th,
    .table.mb-0 td {
        white-space: nowrap;
    }
    .table-responsive .table {
        display: table;
        width: 100%;
    }
}

@media (max-width: 576px) {
    .page-content {
        padding: 16px;
    }

    .stat-card {
        padding: 16px;
    }

    .header-search {
        display: none;
    }

    .live-clock {
        display: none;
    }

    .global-search {
        display: none;
    }

    .login-card {
        padding: 24px;
    }

    .header-user .user-info {
        display: none;
    }

    .header-user {
        padding: 6px 4px;
    }

    .top-header {
        padding: 0 10px;
    }

    .header-left {
        gap: 10px;
    }

    .profile-dropdown .dropdown-menu {
        right: 0;
        width: min(220px, calc(100vw - 20px));
    }

    .modal-dialog {
        width: auto;
        margin: 10px;
    }

    .table-responsive {
        margin-right: -1px;
    }
}

@media (max-width: 380px) {
    .top-header {
        padding: 0 8px;
    }

    .page-content,
    .container-fluid.px-4 {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .page-header .btn-fims,
    .page-header .btn {
        width: 100%;
    }
}

/* ============================
   Print Styles
   ============================ */
.print-header {
    display: none;
}

@media print {
    body {
        background: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .no-print,
    .sidebar,
    .top-header,
    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }

    /* Hide on-screen chrome that should not print */
    .page-header .breadcrumb,
    .page-header .btn,
    .page-header .dropdown,
    .page-header .d-flex,
    .stat-card,
    .bulk-bar,
    .pagination,
    .fims-card.mb-4,
    .fims-card .card-header {
        display: none !important;
    }

    /* Clean printable table */
    .fims-table {
        border-collapse: collapse !important;
        width: 100% !important;
        font-size: 12px !important;
    }
    .fims-table thead th,
    .fims-table tbody td {
        border: 1px solid #d1d5db !important;
        background: #fff !important;
        color: #111 !important;
    }
    .fims-table thead th {
        background: #eef2f7 !important;
    }
    .badge-fims {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .avatar-sm {
        display: none !important;
    }

    /* Print-only report header */
    .print-header {
        display: block !important;
        margin-bottom: 14px;
        border-bottom: 2px solid #0f172a;
        padding-bottom: 10px;
    }
    .print-header h2 {
        margin: 0;
        font-size: 18px;
        font-weight: 700;
        color: #0f172a;
    }
    .print-header p {
        margin: 4px 0 0;
        font-size: 12px;
        color: #475569;
    }
}
