/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.2);
    border-radius: 20px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
    border: 2px solid transparent;
    background-clip: content-box;
}

:root {
    /* Light Theme (Default) - Medical Fresh */
    --bg-primary: #f0f9ff;
    --bg-secondary: #ffffff;
    --sidebar-bg: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-primary: #1e293b;
    --text-dim: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.6);
    --accent-primary: #0ea5e9;
    /* Medical Blue */
    --accent-secondary: #10b981;
    /* Success Emerald */
    --danger: #ef4444;
    --success: #10b981;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -6px rgba(0, 0, 0, 0.04);
    --sidebar-width: 280px;
    --header-height: 70px;
}

.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --sidebar-bg: #1e293b;
    --card-bg: rgba(30, 41, 59, 0.5);
    --text-primary: #f8fafc;
    --text-dim: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

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

[dir="rtl"] {
    --font-family: 'Noto Kufi Arabic', sans-serif;
}

[dir="ltr"] {
    --font-family: 'Outfit', sans-serif;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    transition: all 0.3s ease;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-inline-end: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.logo-text {
    font-weight: 800;
    font-size: 1.4rem;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.2rem;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 14px;
    margin-bottom: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 1rem;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--glass-bg);
    color: var(--accent-primary);
    transform: translateX(5px);
}

.nav-item.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(14, 165, 233, 0.3);
}


/* Main Content */
.main-content {
    flex: 1;
    margin-inline-start: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 90;
    gap: 1.5rem;
}

.admin-profile-wrapper {
    position: relative;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
}

.admin-profile:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.admin-profile:hover #admin-name {
    color: white;
}

.dark-mode .admin-profile:hover {
    background: rgba(255, 255, 255, 0.02);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    inset-inline-end: 0;
    width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 0.5rem;
    display: none;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

.profile-dropdown.active {
    display: block;
}

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

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
    width: 100%;
    font-size: 0.9rem;
    font-family: inherit;
    text-align: inherit;
}

.dropdown-item:hover {
    background: var(--bg-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 0.5rem;
}

.view-container {
    padding: 2rem;
    animation: fadeIn 0.4s ease-out;
}

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

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

/* Cards & Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-primary);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.stat-card p {
    font-size: 2rem;
    font-weight: 700;
}

/* Data Table */
.data-table-container {
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(0, 0, 0, 0.02);
    text-align: start;
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    border-bottom: 1px solid var(--glass-border);
}

.dark-mode th {
    background: rgba(255, 255, 255, 0.02);
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: end;
}

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

/* Buttons & Badges */
.btn-icon {
    background: none;
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dark-mode .btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
}

.badge {
    padding: 0.4rem 1rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 650px;
    /* Slightly wider for complex forms */
    max-height: 90vh;
    /* Don't exceed viewport height */
    overflow-y: auto;
    /* Enable vertical scrolling */
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow);
    transform: scale(0.9);
    transition: all 0.3s;
    position: relative;
}

/* Custom scrollbar for better look in dark mode */
.modal::-webkit-scrollbar {
    width: 8px;
}

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

.modal::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

/* Charts */
.chart-container {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    margin-bottom: 2rem;
}

/* SweetAlert Customization */
.swal2-popup {
    font-family: var(--font-family) !important;
    border-radius: 24px !important;
    padding: 1.5rem !important;
}

.swal2-title {
    font-size: 1.25rem !important;
    color: black;
}

.swal2-html-container {
    font-size: 0.95rem !important;
    color: var(--text-dim) !important;
}

.swal2-confirm,
.swal2-cancel {
    border-radius: 12px !important;
    font-weight: 600 !important;
    padding: 0.8rem 1.5rem !important;
}

/* Notification Badges */
.notification-badge {
    background: #ef4444 !important;
    /* Solid vibrant red */
    color: white !important;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    z-index: 10;
}

.dot-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #ef4444 !important;
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
    z-index: 20;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

/* Sidebar Mobile Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Validation Errors */
.val-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 5px;
    display: block;
    animation: fadeIn 0.3s ease;
}

input.error,
select.error,
textarea.error {
    border-color: var(--danger) !important;
}

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

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

/* Responsive Overrides */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(calc(-1 * 280px));
        width: 280px;
        position: fixed;
    }

    [dir="rtl"] .sidebar {
        transform: translateX(280px);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.2);
    }

    .main-content {
        margin-inline-start: 0;
    }

    #mobile-sidebar-toggle {
        display: flex !important;
    }

    .topbar {
        padding: 0 1rem;
        justify-content: space-between;
    }

    .topbar>div:first-child {
        flex: 0 !important;
    }

    /* Fixed table wrapping/scrolling on mobile */
    .view-container {
        padding: 1rem 1.5rem;
        width: 100vw;
        overflow-x: hidden;
    }

    .data-table-container {
        width: calc(100% + 1rem);
        border-radius: 12px;
        margin-inline: -0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 700px;
    }

    .view-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    /* Fix stats grid on mobile */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Fix sidebar items on mobile */
    .sidebar-nav {
        padding: 1rem 0.5rem;
    }

    .nav-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Ensure modals are usable on mobile */
    .modal {
        width: 95%;
        padding: 1.5rem;
        margin: 1rem;
    }

    .chart-container {
        padding: 1rem;
    }

    /* Fixed chart layout on mobile */
    div[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Pulse Dot Animation for Dynamic Security */
.pulse-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    position: relative;
    animation: simple-pulse 2s infinite;
}

@keyframes simple-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #f59e0b !important;
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}