* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0066cc;
    --primary-dark: #0052a3;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --border-color: #dee2e6;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Arabic', sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========== APP SHELL ========== */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

/* ========== SIDEBAR ========== */
.app-sidebar {
    width: 260px;
    background: linear-gradient(135deg, #0066cc 0%, #004299 100%);
    color: white;
    padding: 0;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.app-sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: bold;
    font-size: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    transition: var(--transition);
}

.sidebar-close:hover {
    opacity: 1;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    cursor: pointer;
}

.sidebar-backdrop.active {
    display: block;
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: block;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: white;
    padding-left: 25px;
}

.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: white;
    font-weight: 600;
}

/* ========== NAVBAR ========== */
.app-navbar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 999;
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-left: 260px;
}

.navbar-left {
    display: flex;
    gap: 15px;
    align-items: center;
}

.burger-menu {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
}

.burger-menu span {
    width: 25px;
    height: 3px;
    background: var(--dark);
    border-radius: 2px;
    transition: var(--transition);
}

.burger-menu.open span:nth-child(1) {
    transform: rotate(45deg) translateY(12px);
}

.burger-menu.open span:nth-child(2) {
    opacity: 0;
}

.burger-menu.open span:nth-child(3) {
    transform: rotate(-45deg) translateY(-12px);
}

.navbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark);
}

.navbar-right {
    display: flex;
    gap: 15px;
    align-items: center;
}

.profile-menu {
    position: relative;
}

.profile-toggle {
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 10px;
    padding: 6px 8px;
    transition: var(--transition);
}

.profile-toggle:hover {
    background: rgba(0, 102, 204, 0.08);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    z-index: 1200;
}

.profile-menu.open .profile-dropdown {
    display: block;
}

.profile-dropdown-item {
    display: block;
    text-decoration: none;
    color: var(--dark);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.92rem;
    transition: var(--transition);
}

.profile-dropdown-item:hover {
    background: var(--light);
}

.profile-dropdown-item.danger {
    color: var(--danger);
}

.profile-dropdown-item.danger:hover {
    background: rgba(220, 53, 69, 0.08);
}

.user-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066cc 0%, #004299 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--dark);
}

.user-role {
    font-size: 0.85rem;
    color: var(--secondary);
}

.logout-btn {
    padding: 8px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    text-decoration: none;
}

.profile-label {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--secondary);
    margin-top: 5px;
}

.logout-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ========== MAIN CONTENT ========== */
main {
    flex: 1;
    padding: 20px;
    margin-left: 260px;
    min-width: 0;
    overflow-x: hidden;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-title {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.page-title h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

.page-title p {
    font-size: 0.95rem;
    color: var(--secondary);
    margin: 0;
}

/* ========== CARDS ========== */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 15px 20px;
    background: var(--light);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--dark);
}

.card-body {
    padding: 20px;
}

/* ========== TABLES ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table thead th {
    background: var(--light);
    border-bottom: 2px solid var(--border-color);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.table tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: #333;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-outline-primary {
    border: 1px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-outline-danger {
    border: 1px solid var(--danger);
    color: var(--danger);
    background: transparent;
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--dark);
    font-size: 0.95rem;
}

.form-control,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-control::placeholder {
    color: var(--secondary);
}

/* ========== BADGES ========== */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.bg-success {
    background: var(--success) !important;
    color: white !important;
}

.bg-danger {
    background: var(--danger) !important;
    color: white !important;
}

.bg-warning {
    background: var(--warning) !important;
    color: #333 !important;
}

.bg-info {
    background: var(--info) !important;
    color: white !important;
}

.bg-secondary {
    background: var(--secondary) !important;
    color: white !important;
}

/* ========== ALERTS ========== */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 15px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* ========== MODALS ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--dark);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* ========== GRID ========== */
.row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.col-1 { grid-column: span 1; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; }
.col-12 { grid-column: span 12; }

/* ========== UTILITIES ========== */
.container-fluid {
    width: 100%;
    padding: 0 20px;
}

.d-flex {
    display: flex;
}

.gap-2 { gap: 10px; }
.gap-3 { gap: 15px; }
.gap-4 { gap: 20px; }

.justify-content-between {
    justify-content: space-between;
}

.justify-content-center {
    justify-content: center;
}

.justify-content-end {
    justify-content: flex-end;
}

.align-items-center {
    align-items: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.mb-1 { margin-bottom: 5px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 15px; }
.mb-4 { margin-bottom: 20px; }

.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }

.p-3 { padding: 15px; }
.p-4 { padding: 20px; }

.w-100 {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--secondary);
}

.d-none {
    display: none !important;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ========== AUTH PAGE ========== */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #0066cc 0%, #004299 100%);
}

.auth-card {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 40px;
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--dark);
}

.auth-card p {
    color: var(--secondary);
    margin-bottom: 25px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .app-sidebar {
        width: 0;
        overflow: hidden;
    }

    .app-sidebar.active {
        width: 260px;
        max-width: 80vw;
    }

    main {
        margin-left: 0;
    }

    .navbar-content {
        margin-left: 0;
    }

    .burger-menu {
        display: flex;
    }

    .sidebar-close {
        display: block;
    }

    .user-role {
        display: none;
    }

    .row {
        grid-template-columns: repeat(6, 1fr);
    }

    .col-md-12 { grid-column: span 6; }
    .col-md-8 { grid-column: span 6; }
    .col-md-6 { grid-column: span 6; }
    .col-md-4 { grid-column: span 6; }
    .col-md-3 { grid-column: span 6; }
    .col-md-2 { grid-column: span 3; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    main {
        padding: 15px;
    }

    .page-title h1 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .table {
        font-size: 0.85rem;
    }

    .table thead th,
    .table tbody td {
        padding: 8px 10px;
    }

    .row {
        grid-template-columns: repeat(1, 1fr);
    }

    .col-md-12,
    .col-md-8,
    .col-md-6,
    .col-md-4,
    .col-md-3,
    .col-md-2 {
        grid-column: span 1;
    }

    .auth-card {
        padding: 30px 20px;
    }
}
