/* ============================================================
 * Bezoor Admin — Black & Gold Minimal Theme
 * No external dependencies, pure CSS.
 * ============================================================ */

:root {
    /* Brand */
    --gold:           #D4AF37;
    --gold-light:     #E8C76B;
    --gold-dark:      #A88824;

    /* Surfaces */
    --bg-0:           #0A0A0B;
    --bg-1:           #111114;
    --bg-2:           #16161A;
    --bg-3:           #1E1E24;
    --bg-hover:       #22232B;
    --border:         #2A2B33;
    --border-strong:  #3A3B45;

    /* Text */
    --text-primary:   #F5F5F7;
    --text-secondary: #A8A9B3;
    --text-muted:     #6B6C77;

    /* Status */
    --green:          #4ADE80;
    --red:            #F87171;
    --orange:         #FB923C;
    --blue:           #60A5FA;

    /* Layout */
    --sidebar-w:      260px;
    --header-h:       60px;
    --radius-sm:      6px;
    --radius:         10px;
    --radius-lg:      14px;
    --shadow:         0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.2);
    --shadow-lg:      0 4px 20px rgba(0,0,0,.4);

    /* Type */
    --font-base:      'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono:      'SF Mono', Menlo, Consolas, monospace;

    /* Motion */
    --t-fast:         120ms ease;
    --t:              200ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: var(--font-base);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
 * Layout
 * ============================================================ */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    min-height: 100vh;
}

[dir="rtl"] .layout {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
}

.app-header {
    grid-area: header;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .breadcrumbs {
    color: var(--text-secondary);
    font-size: 13px;
}
.app-header .breadcrumbs strong {
    color: var(--text-primary);
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-menu .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--bg-0);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.user-menu .user-name { font-weight: 600; font-size: 13px; }
.user-menu .user-role { font-size: 11px; color: var(--text-muted); }

.lang-switch {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: var(--t-fast);
}
.lang-switch:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ============================================================
 * Sidebar
 * ============================================================ */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-1);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--header-h);
}
.sidebar-brand-logo {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--bg-0); font-weight: 800; font-size: 16px;
}
.sidebar-brand-name {
    font-weight: 700;
    font-size: 18px;
    color: var(--gold);
    letter-spacing: 0.5px;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    display: flex; flex-direction: column;
    gap: 2px;
}

.sidebar-section-title {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--t-fast);
    border: 1px solid transparent;
}
.nav-item:hover {
    background: var(--bg-2);
    color: var(--text-primary);
}
.nav-item.active {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
    border-color: rgba(212, 175, 55, 0.25);
}
.nav-item .icon {
    width: 18px; height: 18px;
    display: inline-flex;
    align-items: center; justify-content: center;
}
.nav-item .badge {
    margin-inline-start: auto;
    font-size: 10px;
    background: var(--gold);
    color: var(--bg-0);
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
}

/* ============================================================
 * Main content
 * ============================================================ */
.main-content {
    grid-area: main;
    padding: 24px 28px;
    overflow-x: hidden;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
.page-header .page-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

/* ============================================================
 * Cards
 * ============================================================ */
.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color var(--t-fast);
}
.card:hover { border-color: var(--border-strong); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body { padding-top: 4px; }

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; inset-inline-start: 0;
    width: 3px; height: 100%;
    background: var(--gold);
    opacity: 0;
    transition: opacity var(--t);
}
.stat-card.accent::before { opacity: 1; }
.stat-card:hover { border-color: var(--gold-dark); }
.stat-card .label {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 8px;
}
.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}
.stat-card .value .currency {
    font-size: 14px;
    color: var(--gold);
    margin-inline-start: 6px;
    font-weight: 500;
}
.stat-card .delta {
    font-size: 12px;
    margin-top: 6px;
    color: var(--text-muted);
}
.stat-card .delta.up    { color: var(--green); }
.stat-card .delta.down  { color: var(--red); }

/* ============================================================
 * Tables
 * ============================================================ */
.table-wrapper {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}
.table-toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    background: var(--bg-2);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: start;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-2); }
.data-table .empty {
    text-align: center;
    padding: 40px 14px;
    color: var(--text-muted);
}
.data-table .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============================================================
 * Badges
 * ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
    line-height: 1.4;
}
.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.badge-success     { color: var(--green);  background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.3); }
.badge-danger      { color: var(--red);    background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.3); }
.badge-warning     { color: var(--orange); background: rgba(251, 146, 60, 0.1); border-color: rgba(251, 146, 60, 0.3); }
.badge-info        { color: var(--blue);   background: rgba(96, 165, 250, 0.1); border-color: rgba(96, 165, 250, 0.3); }
.badge-gold        { color: var(--gold);   background: rgba(212, 175, 55, 0.1); border-color: rgba(212, 175, 55, 0.3); }
.badge-muted       { color: var(--text-muted); background: var(--bg-2); border-color: var(--border); }
.badge.no-dot::before { display: none; }

/* ============================================================
 * Buttons
 * ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--t-fast);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--gold);
    color: var(--bg-0);
    border-color: var(--gold);
}
.btn-primary:hover:not(:disabled) { background: var(--gold-light); border-color: var(--gold-light); }

.btn-secondary {
    background: var(--bg-2);
    border-color: var(--border);
    color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-success { background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.4); color: var(--green); }
.btn-success:hover:not(:disabled) { background: rgba(74, 222, 128, 0.2); }

.btn-danger { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.2); }

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }
.btn-block { width: 100%; }

/* ============================================================
 * Forms
 * ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.form-help {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}
.form-control {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    transition: var(--t-fast);
}
.form-control:focus {
    outline: none;
    border-color: var(--gold);
    background: var(--bg-1);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='%23A8A9B3' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    padding-inline-end: 32px;
}
[dir="rtl"] select.form-control { background-position: left 12px center; padding-inline-end: 12px; padding-inline-start: 32px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 200px; }

/* ============================================================
 * Alerts / Flash
 * ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border: 1px solid;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: rgba(74, 222, 128, 0.08); color: var(--green); border-color: rgba(74, 222, 128, 0.3); }
.alert-error   { background: rgba(248, 113, 113, 0.08); color: var(--red);   border-color: rgba(248, 113, 113, 0.3); }
.alert-info    { background: rgba(96, 165, 250, 0.08); color: var(--blue);   border-color: rgba(96, 165, 250, 0.3); }
.alert-warning { background: rgba(251, 146, 60, 0.08); color: var(--orange); border-color: rgba(251, 146, 60, 0.3); }

/* ============================================================
 * Modal
 * ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t);
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform var(--t);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-title { font-weight: 700; font-size: 16px; }
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============================================================
 * Login
 * ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(212, 175, 55, 0.08), transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(212, 175, 55, 0.05), transparent 50%),
        var(--bg-0);
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-brand .logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    border-radius: 16px;
    display: inline-flex;
    align-items: center; justify-content: center;
    margin-bottom: 12px;
    color: var(--bg-0);
    font-weight: 800;
    font-size: 28px;
}
.login-brand h1 {
    color: var(--gold);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}
.login-brand p { color: var(--text-secondary); font-size: 13px; }

/* ============================================================
 * Map container
 * ============================================================ */
.map-wrapper {
    height: 500px;
    background: var(--bg-2);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.leaflet-container {
    background: var(--bg-2) !important;
}
/* Dark-mode tweaks for OSM tiles */
.leaflet-tile { filter: brightness(0.7) contrast(1.05) saturate(0.8); }

/* ============================================================
 * Charts
 * ============================================================ */
.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

/* ============================================================
 * Utilities
 * ============================================================ */
.flex            { display: flex; }
.flex-1          { flex: 1; }
.gap-1           { gap: 4px; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.gap-4           { gap: 16px; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-wrap       { flex-wrap: wrap; }

.text-center     { text-align: center; }
.text-muted      { color: var(--text-muted); }
.text-secondary  { color: var(--text-secondary); }
.text-gold       { color: var(--gold); }
.text-success    { color: var(--green); }
.text-danger     { color: var(--red); }
.text-mono       { font-family: var(--font-mono); }
.text-sm         { font-size: 12px; }
.text-lg         { font-size: 16px; }
.font-bold       { font-weight: 700; }

.mt-1 { margin-top:  4px; } .mt-2 { margin-top:  8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Live indicator */
.live-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--green);
    border-radius: 50%;
    margin-inline-end: 6px;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(1.4); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
 * Responsive
 * ============================================================ */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }
    .sidebar {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 200;
        transition: transform var(--t);
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { padding: 16px; }
}
