/* درع Admin — Clean Dashboard UI (AZLAW-inspired) */
:root {
    --brand: #1E5ABD;
    --brand-dark: #164a9e;
    --brand-light: #3b7ddd;
    --accent: #20B2AA;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-w: 248px;
    --topbar-h: 72px;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 20px rgba(26, 35, 50, 0.05);
    --shadow-lg: 0 8px 28px rgba(26, 35, 50, 0.08);
    --text: #1A2332;
    --text-muted: #64748b;
    --border: #E2E8F0;
    --surface: #ffffff;
    --bg: #ffffff;
    --sidebar-bg: #ffffff;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Cairo', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

body.sidebar-open { overflow: hidden; }

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1050;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(26, 35, 50, 0.06);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(26, 35, 50, 0.12); border-radius: 3px; }

.sidebar-header {
    padding: 16px 14px;
    border-bottom: 2px solid var(--brand);
    flex-shrink: 0;
    background: #fff;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-logo-text .brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.sidebar-logo-text .brand-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

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

.nav-group-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 12px 10px 6px;
}

.nav-item { margin-bottom: 1px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 9px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.84rem;
    line-height: 1.3;
    transition: background 0.2s, color 0.2s;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
}

.nav-link i {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    color: var(--brand);
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(30, 90, 189, 0.08);
    color: var(--text);
}

.nav-link.active {
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(30, 90, 189, 0.28);
}

.nav-link.active i { color: #fff; }

/* ─── Main Layout ─── */
.main-wrapper {
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-title h2 {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0;
    color: var(--text);
}

.topbar-breadcrumb {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 600;
}

.topbar-breadcrumb a {
    color: var(--brand);
    text-decoration: none;
}

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

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-dropdown .btn-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.user-dropdown .btn-user:hover,
.user-dropdown .btn-user:focus,
.user-dropdown .btn-user.show {
    border-color: var(--brand);
    box-shadow: 0 4px 12px rgba(30, 90, 189, 0.12);
    color: var(--text);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.user-dropdown .dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 12px 32px rgba(26, 35, 50, 0.12);
    min-width: 200px;
}

.user-dropdown .dropdown-item {
    color: var(--text);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.875rem;
}

.user-dropdown .dropdown-item:hover { background: rgba(30, 90, 189, 0.08); }
.user-dropdown .dropdown-item.logout:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.user-dropdown .dropdown-divider { border-color: var(--border); margin: 6px 0; }

.page-content {
    padding: 20px 24px 28px;
    flex: 1;
    background: #f8fafc;
}

/* ─── KPI Cards ─── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-card.blue::after { background: var(--brand); }
.kpi-card.green::after { background: var(--success); }
.kpi-card.teal::after { background: var(--accent); }
.kpi-card.red::after { background: var(--danger); }
.kpi-card.amber::after { background: var(--warning); }

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.kpi-icon.blue { background: rgba(30, 90, 189, 0.1); color: var(--brand); }
.kpi-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.kpi-icon.teal { background: rgba(32, 178, 170, 0.12); color: var(--accent); }
.kpi-icon.red { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.12); color: var(--warning); }

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 6px;
}

/* ─── Panels ─── */
.panel {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h3 i {
    color: var(--brand);
}

.panel-body { padding: 0; }
.panel-body.padded { padding: 1.5rem; }
.panel-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

/* ─── Data Table ─── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table thead th {
    background: #f8fafc;
    padding: 0.875rem 1.25rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 0.9rem;
}

.data-table tbody tr {
    transition: background 0.15s;
}

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

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

/* ─── User Cell ─── */
.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.avatar.sm { width: 32px; height: 32px; font-size: 0.75rem; border-radius: 10px; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; border-radius: 20px; }

.avatar-1 { background: #6366f1; }
.avatar-2 { background: #3b82f6; }
.avatar-3 { background: #10b981; }
.avatar-4 { background: #f59e0b; }

.user-name {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.user-name:hover { color: var(--brand); }

.user-sub { font-size: 0.8rem; color: var(--text-muted); }

/* ─── Status Pills ─── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.pill-success { background: #ecfdf5; color: #059669; }
.pill-success::before { background: #10b981; }
.pill-danger { background: #fef2f2; color: #dc2626; }
.pill-danger::before { background: #ef4444; }
.pill-warning { background: #fffbeb; color: #b45309; }
.pill-warning::before { background: #f59e0b; }
.pill-muted { background: #f1f5f9; color: #64748b; }
.pill-muted::before { background: #94a3b8; }
.pill-info { background: #eff6ff; color: #2563eb; }
.pill-info::before { background: #3b82f6; }

/* ─── Action Buttons ─── */
.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-action {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.btn-action.view:hover { background: #eff6ff; color: var(--brand); border-color: #bfdbfe; }
.btn-action.edit:hover { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }
.btn-action.warn:hover { background: #fffbeb; color: var(--warning); border-color: #fde68a; }
.btn-action.hide:hover { background: #f8fafc; color: #475569; border-color: #cbd5e1; }
.btn-action.delete:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

.btn-brand {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-brand:hover {
    color: #fff;
    background: var(--brand-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(30, 90, 189, 0.3);
}

.btn-outline-brand {
    background: transparent;
    color: var(--brand);
    border: 1.5px solid var(--brand);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-outline-brand:hover {
    background: var(--brand);
    color: #fff;
}

/* ─── Forms ─── */
.form-modern .form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.form-modern .form-control,
.form-modern .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-modern .form-control:focus,
.form-modern .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(30, 90, 189, 0.1);
}

.input-group-modern {
    display: flex;
    align-items: stretch;
    flex-direction: row-reverse;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group-modern:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(30, 90, 189, 0.1);
}

.input-group-modern .input-icon {
    padding: 0 1rem;
    background: #f8fafc;
    display: flex;
    align-items: center;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
}

.input-group-modern input {
    flex: 1;
    border: none;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
}

/* ─── Token Box ─── */
.token-box {
    background: #0f172a;
    color: #94a3b8;
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    word-break: break-all;
    direction: ltr;
    text-align: left;
    line-height: 1.6;
}

.code-inline {
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.82rem;
    direction: ltr;
    display: inline-block;
}

/* ─── Detail Grid ─── */
.detail-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.5rem;
}

.detail-item {
    margin-bottom: 1.25rem;
}

.detail-item label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-item .value {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ─── Alerts ─── */
.alert-modern {
    border: none;
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.alert-modern.success { background: #ecfdf5; color: #065f46; }
.alert-modern.error { background: #fef2f2; color: #991b1b; }

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
    display: block;
}

/* ─── Login Page ─── */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.login-brand {
    background: var(--brand-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.login-brand-icon {
    width: 90px;
    height: 90px;
    border-radius: 24px;
    background: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 2rem;
    color: #fff;
}

.login-brand-content {
    position: relative;
    text-align: center;
    color: #fff;
    max-width: 400px;
}

.login-brand h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.login-brand p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.05rem;
    line-height: 1.8;
}

.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-card h2 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ─── Sidebar Overlay ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    backdrop-filter: blur(4px);
}

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

.btn-menu {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.btn-menu:hover {
    border-color: var(--brand);
    box-shadow: 0 4px 12px rgba(30, 90, 189, 0.1);
}

/* ─── Pagination override ─── */
.pagination { margin: 0; gap: 4px; }
.page-link {
    border-radius: 8px !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    font-weight: 500;
}
.page-item.active .page-link {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
}

/* ─── Settings Tabs ─── */
.settings-tabs {
    border-bottom: 2px solid var(--border);
    gap: 4px;
}
.settings-tabs .nav-link {
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.settings-tabs .nav-link:hover {
    color: var(--brand);
    background: rgba(30, 90, 189, 0.05);
}
.settings-tabs .nav-link.active {
    color: var(--brand);
    background: var(--surface);
    border-bottom: 2px solid var(--brand);
    margin-bottom: -2px;
}

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}
.form-check.form-switch .form-check-input {
    width: 2.75em;
    height: 1.4em;
    cursor: pointer;
}

.page-preview-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(30, 90, 189, 0.08);
    transition: background 0.2s;
}

.page-preview-link:hover {
    background: rgba(30, 90, 189, 0.15);
    color: var(--brand-dark);
}

/* ─── Responsive ─── */
@media (max-width: 1199px) {
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: -8px 0 32px rgba(26, 35, 50, 0.15);
    }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-right: 0; }
    .btn-menu { display: flex; }
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .page-content { padding: 16px; }
    .top-bar { padding: 0 16px; }
}

@media (max-width: 576px) {
    .top-bar { padding: 0 12px; }
    .topbar-title h2 { font-size: 1.1rem; }
    .kpi-value { font-size: 1.5rem; }
}
