/* ─────────────────────────────────────────────────────────────────
 * Tanzeemi Admin · Saudi-emerald + warm-gold design system
 * RTL-first (Arabic-default). All directional spacing uses *-inline-*
 * properties so layout flips automatically when dir="ltr" is applied.
 * ──────────────────────────────────────────────────────────────── */

:root {
    /* Brand */
    --emerald:        #006B3F;
    --emerald-dark:   #004D2D;
    --emerald-light:  #2E8C5A;
    --emerald-soft:   #E6F2EC;
    --gold:           #D4A24A;
    --gold-dark:      #A67A2B;
    --gold-soft:      #FAF1DD;

    /* Semantic */
    --success: #1F9D55;
    --warning: #E9A23B;
    --danger:  #E0463A;
    --info:    #1F73C2;

    /* Neutrals (warm sand) */
    --n-0:   #FFFFFF;
    --n-50:  #FAF8F4;
    --n-100: #F2EFE8;
    --n-200: #E6E1D6;
    --n-300: #CFC8B7;
    --n-400: #A9A28E;
    --n-500: #7C7669;
    --n-600: #5A5546;
    --n-700: #3F3B30;
    --n-800: #272520;
    --n-900: #14130F;

    --radius:    14px;
    --radius-sm: 10px;
    --shadow-1:  0 1px 2px rgba(20, 19, 15, .06), 0 4px 12px rgba(20, 19, 15, .05);
    --shadow-2:  0 4px 12px rgba(20, 19, 15, .10), 0 12px 32px rgba(20, 19, 15, .08);
    --font-ar:   'Tajawal', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --duration:  .18s;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--n-50);
    color: var(--n-800);
    font-family: var(--font-ar);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--emerald); text-decoration: none; }
a:hover { text-decoration: underline; }
.link { color: var(--emerald); font-weight: 600; }
.muted { color: var(--n-500); }
.small { font-size: 12px; }

h1, h2, h3 { font-weight: 700; color: var(--n-900); margin: 0 0 8px; }
h1 { font-size: 28px; letter-spacing: -.3px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ─── Login ─────────────────────────────────────────────────── */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-light) 100%);
    padding: 24px;
}
.login-brand {
    text-align: center;
    color: var(--gold-soft);
    margin-bottom: 24px;
}
.login-brand h1 {
    color: var(--gold-soft);
    font-size: 36px;
    margin: 8px 0 4px;
}
.login-brand p { margin: 0; color: rgba(255,255,255,.85); }
.login-mark {
    width: 56px; height: 56px; margin: 0 auto;
    border: 2px solid var(--gold);
    border-radius: 50%;
    background:
      radial-gradient(circle at 50% 35%, var(--gold) 4px, transparent 5px),
      radial-gradient(circle at 38% 35%, var(--gold) 3px, transparent 4px),
      radial-gradient(circle at 62% 35%, var(--gold) 3px, transparent 4px);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--n-0);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
}
.login-foot {
    margin-top: 24px;
    color: rgba(255,255,255,.7);
    font-size: 12px;
}

/* ─── Forms ─────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 13px; color: var(--n-700); }
.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--n-300);
    border-radius: var(--radius-sm);
    background: var(--n-0);
    font: inherit;
    color: var(--n-900);
    transition: border-color var(--duration), box-shadow var(--duration);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px rgba(0, 107, 63, .15);
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn-primary, .btn-danger, .btn-ghost, .btn-outline {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--duration), border-color var(--duration), transform var(--duration);
}
.btn-primary { background: var(--emerald); color: #fff; }
.btn-primary:hover { background: var(--emerald-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b8362c; }
.btn-ghost { background: transparent; color: var(--n-700); }
.btn-ghost:hover { background: var(--n-100); }
.btn-outline { background: transparent; color: var(--emerald); border-color: var(--emerald); }
.btn-outline:hover { background: var(--emerald-soft); }
.btn-block { width: 100%; }

/* ─── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 12px;
}
.alert-error { background: #fde6e4; color: #842018; border: 1px solid #f5c6c1; }
.alert-info  { background: #e6efff; color: #103a78; border: 1px solid #bcd0fa; }

/* ─── Admin shell ───────────────────────────────────────────── */
.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}
.admin-sidebar {
    background: linear-gradient(180deg, var(--emerald) 0%, var(--emerald-dark) 100%);
    color: #fff;
    padding: 22px 14px;
    display: flex; flex-direction: column;
    gap: 16px;
    position: sticky; top: 0;
    height: 100vh;
}
.admin-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 8px 14px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.admin-brand strong { display: block; font-size: 17px; color: var(--gold-soft); }
.admin-brand span { font-size: 12px; opacity: .8; }
.brand-mark {
    width: 36px; height: 36px;
    border-radius: 50%;
    background:
      radial-gradient(circle at 50% 30%, var(--gold) 4px, transparent 5px),
      radial-gradient(circle at 36% 30%, var(--gold) 3px, transparent 4px),
      radial-gradient(circle at 64% 30%, var(--gold) 3px, transparent 4px),
      var(--emerald-dark);
    border: 2px solid var(--gold);
    flex: 0 0 36px;
}
.admin-side-foot { margin-top: auto; padding-inline: 8px; opacity: .6; font-size: 12px; }

.nav-menu { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.85);
    font-weight: 500;
    text-decoration: none;
    transition: background var(--duration), color var(--duration);
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active {
    background: rgba(212, 162, 74, .22);
    color: var(--gold-soft);
    border-inline-end: 3px solid var(--gold);
}
.nav-link .i { font-size: 16px; }

.admin-main {
    background: var(--n-50);
    display: flex; flex-direction: column;
    min-width: 0;
}
.admin-topbar {
    display: flex; align-items: center;
    gap: 16px;
    padding: 14px 22px;
    background: var(--n-0);
    border-bottom: 1px solid var(--n-200);
    position: sticky; top: 0; z-index: 10;
}
.topbar-spacer { flex: 1; }

.user-pill {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--n-100);
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--emerald);
    color: var(--gold-soft);
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 13px;
}
.user-meta { line-height: 1.1; }
.user-meta strong { display: block; font-size: 13px; }
.user-meta span { font-size: 11px; }

.logout-form { display: inline; margin: 0; }

.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    width: 36px; height: 36px;
    border: 1px solid var(--n-200);
    background: var(--n-0);
    border-radius: 8px;
    cursor: pointer;
    align-items: center; justify-content: center;
}
.hamburger span {
    width: 18px; height: 2px;
    background: var(--n-700);
    border-radius: 1px;
}

.admin-content { padding: 22px; max-width: 1320px; width: 100%; }

/* ─── Page head ─────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin-bottom: 2px; }
.page-head .head-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--n-300); display: inline-block; }
.dot-live { background: var(--success); box-shadow: 0 0 0 4px rgba(31,157,85,.18); }
.dot-idle { background: var(--n-400); }

/* ─── KPI grid ──────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.kpi-card {
    background: var(--n-0);
    border: 1px solid var(--n-200);
    border-radius: var(--radius);
    padding: 18px;
    display: flex; flex-direction: column; gap: 4px;
    box-shadow: var(--shadow-1);
    position: relative;
    overflow: hidden;
}
.kpi-card::after {
    content: '';
    position: absolute;
    inset-inline-start: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--emerald);
}
.kpi-card.kpi-emerald::after { background: var(--emerald); }
.kpi-card.kpi-gold::after    { background: var(--gold); }
.kpi-card.kpi-danger::after  { background: var(--danger); }
.kpi-label { font-size: 13px; color: var(--n-500); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--n-900); letter-spacing: -.5px; }
.kpi-delta { color: var(--success); font-weight: 700; font-size: 13px; }
.kpi-hint  { font-size: 12px; }

.kpi-card.skeleton {
    height: 108px;
    background: linear-gradient(90deg, var(--n-100) 25%, var(--n-200) 50%, var(--n-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ─── Cards / Tables ────────────────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}
.card {
    background: var(--n-0);
    border: 1px solid var(--n-200);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-1);
}
.card-head {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.card-head h2 { margin: 0; }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}
.table th, .table td {
    padding: 10px 8px;
    text-align: start;
    border-bottom: 1px solid var(--n-100);
}
.table th {
    font-weight: 700;
    color: var(--n-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--n-50); }

.list-rows { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.list-rows li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 6px;
    border-bottom: 1px solid var(--n-100);
}
.list-rows li:last-child { border-bottom: none; }
.list-link { display: flex; flex-direction: column; gap: 2px; color: inherit; }
.list-link strong { font-weight: 600; }
.list-link:hover { text-decoration: none; color: var(--emerald); }

/* ─── Status badges ─────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--n-100);
    color: var(--n-700);
}
.badge-booking-requested,
.badge-vendor-pending,
.badge-event-draft,
.badge-report-open,
.badge-invoice-pending,
.badge-user-pending      { background: #fff4dd; color: #8a5a05; }
.badge-booking-approved,
.badge-vendor-active,
.badge-event-published,
.badge-report-resolved,
.badge-invoice-paid,
.badge-user-approved     { background: var(--emerald-soft); color: var(--emerald-dark); }
.badge-booking-completed { background: #d8eee2; color: #1c5a36; }
.badge-booking-rejected,
.badge-vendor-rejected,
.badge-event-cancelled,
.badge-report-dismissed,
.badge-booking-cancelled { background: #fde6e4; color: #842018; }
.badge-vendor-suspended,
.badge-invoice-void      { background: #ecead4; color: #5a5546; }
.badge-event-archived    { background: var(--n-200); color: var(--n-700); }
.badge-report-investigating { background: #e6efff; color: #103a78; }

/* ─── Empty state ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--n-500);
}
.empty-glyph { font-size: 36px; color: var(--gold); margin-bottom: 10px; }

/* ─── Confirm dialog ────────────────────────────────────────── */
.dialog-backdrop {
    position: fixed; inset: 0;
    background: rgba(20, 19, 15, .55);
    display: grid; place-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    animation: fadein .15s ease-out;
}
.dialog-card {
    background: var(--n-0);
    border-radius: var(--radius);
    padding: 22px;
    width: min(90vw, 440px);
    box-shadow: var(--shadow-2);
}
.dialog-actions {
    display: flex; justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ─── Toasts ────────────────────────────────────────────────── */
.toast-host {
    position: fixed;
    inset-block-end: 24px;
    inset-inline-end: 24px;
    display: flex; flex-direction: column;
    gap: 8px;
    z-index: 1100;
    pointer-events: none;
}
.toast {
    background: var(--n-900);
    color: var(--n-0);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
    display: flex; align-items: center; gap: 10px;
    min-width: 240px;
    animation: slidein .18s ease-out;
}
.toast-success { background: var(--emerald-dark); }
.toast-error   { background: #842018; }
.toast-warning { background: #8a5a05; }
.toast-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 12px;
}
@keyframes slidein {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);  opacity: 1; }
}

/* ─── Filters / Toolbars ────────────────────────────────────── */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 14px;
}
.toolbar input[type="search"],
.toolbar select {
    padding: 9px 12px;
    border: 1px solid var(--n-300);
    border-radius: var(--radius-sm);
    background: var(--n-0);
    font: inherit;
    min-width: 180px;
}
.toolbar input[type="search"] { min-width: 280px; }

/* ─── Pagination ────────────────────────────────────────────── */
.pager {
    display: flex; align-items: center; gap: 6px;
    margin-top: 12px;
    justify-content: flex-end;
}
.pager button {
    border: 1px solid var(--n-300);
    background: var(--n-0);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: inherit;
}
.pager button[disabled] { color: var(--n-400); cursor: not-allowed; }
.pager .current { background: var(--emerald); color: var(--n-0); border-color: var(--emerald); }

/* ─── Detail panes ──────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
    align-items: start;
}
.kv-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; }
.kv-list dt { color: var(--n-500); font-weight: 600; }
.kv-list dd { margin: 0; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 960px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: fixed; inset-block: 0; inset-inline-start: -260px;
        width: 260px;
        transition: transform var(--duration);
        z-index: 50;
    }
    body.nav-open .admin-sidebar { transform: translateX(-100%); /* RTL flip */ inset-inline-start: 0; }
    .hamburger { display: inline-flex; }
    .dash-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}

/* ─── LTR overrides (English) ───────────────────────────────── */
[dir="ltr"] body.nav-open .admin-sidebar {
    transform: translateX(100%);
}
