/* CSS Variables */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg-body: #f1f5f9;
    --sidebar-width: 280px;
    --header-height: 70px;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-card: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    border-left: 1px solid var(--border);
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand i {
    font-size: 1.8rem;
    color: var(--primary);
}

.brand h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
}

.nav-menu {
    padding: 20px 16px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: all 0.2s;
    font-weight: 600;
    cursor: pointer;
}

.nav-item:hover {
    background: #f8fafc;
    color: var(--primary);
}

.nav-item.active {
    background: #e0e7ff;
    color: var(--primary);
}

/* Main Layout */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin 0.3s;
}

/* Header */
header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-main);
    cursor: pointer;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.bg-blue {
    background: #eff6ff;
    color: #3b82f6;
}

.bg-green {
    background: #f0fdf4;
    color: #22c55e;
}

.bg-red {
    background: #fef2f2;
    color: #ef4444;
}

/* Tables & Lists */
.card-container {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    padding: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 15px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: right;
    padding: 16px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid #f1f5f9;
}

td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

/* Mobile Table Cards */
@media (max-width: 600px) {

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 15px;
        padding: 10px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-right: 120px;
        text-align: left;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        position: absolute;
        right: 10px;
        width: 100px;
        font-weight: 700;
        color: var(--text-muted);
        text-align: right;
        content: attr(data-label);
        font-size: 0.8rem;
    }
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge.pending {
    background: #fff7ed;
    color: #ea580c;
}

.status-badge.approved {
    background: #f0fdf4;
    color: #16a34a;
}

.status-badge.rejected {
    background: #fef2f2;
    color: #dc2626;
}

/* Staff Grid */
.staff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
}

.staff-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    padding: 24px;
    text-align: center;
    border: 1px solid transparent;
    transition: 0.2s;
    position: relative;
}

.staff-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
}

.staff-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 16px;
    border: 3px solid #f1f5f9;
}

.add-staff-card {
    border: 2px dashed #cbd5e1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    cursor: pointer;
    min-height: 240px;
}

.add-staff-card:hover {
    background: #f1f5f9;
    border-color: var(--primary);
}

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

    .sidebar.active {
        transform: translateX(0);
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
    }

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

    .toggle-btn {
        display: block;
    }

    .header-search {
        display: none !important;
    }

    .main-content {
        padding-top: 0;
    }
}

@media (max-width: 600px) {
    header {
        padding: 0 15px;
    }

    .section-header h3 {
        width: 100%;
        margin-bottom: 5px;
    }

    .section-header div {
        width: 100%;
        justify-content: space-between;
    }

    #searchInput {
        width: 100% !important;
    }
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 950;
    display: none;
    backdrop-filter: blur(2px);
}

.overlay.active {
    display: block;
}
}

@media (max-width: 768px) {
    .header-search {
        display: none;
    }

    .stat-card {
        padding: 20px;
    }

    td,
    th {
        white-space: nowrap;
    }

    .card-container {
        padding: 16px;
        overflow-x: auto;
    }
}

/* Sections Visibility */
.page-section {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    padding: 30px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    animation: slideUp 0.3s;
    overflow-y: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 30px;
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(100px);
    transition: 0.3s;
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.toast.active {
    transform: translateY(0);
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    -webkit-transform: translateX(24px);
    -ms-transform: translateX(24px);
    transform: translateX(24px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}