/* ==========================================================================
   Admin Dashboard
   ==========================================================================

   Layered on top of app.css, which owns the design tokens. Nothing here
   redefines a colour: it composes the ones already declared.

   A dashboard is read at a desk for hours, so it runs denser than the
   public site and sits on a sunken surface to reduce glare.

   Load order: bootstrap(.rtl) -> bootstrap-icons -> fonts -> app -> admin
   ========================================================================== */

:root {
    --admin-sidebar-width: 268px;
    --admin-sidebar-collapsed: 76px;
    --admin-topbar-height: 64px;
}

body.admin {
    background-color: var(--stone-100);
    font-size: .9375rem;
}

/* ==========================================================================
   Shell
   ==========================================================================
   Logical properties throughout (inline-start, not left) so the whole
   layout mirrors for Arabic without a single RTL override.
   ========================================================================== */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1040;
    width: var(--admin-sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--navy-950);
    color: rgba(255, 255, 255, .72);
    transition: transform var(--transition-base);
}

.admin-main {
    flex: 1;
    min-width: 0;
    margin-inline-start: var(--admin-sidebar-width);
    display: flex;
    flex-direction: column;
}

.admin-content {
    flex: 1;
    padding: 1.5rem;
}

@media (max-width: 991.98px) {
    .admin-sidebar {
        /* Off-canvas below lg. translateX is direction-aware because the
           sidebar is anchored with inset-inline-start. */
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }

    [dir="rtl"] .admin-sidebar {
        transform: translateX(100%);
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
    }

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

    .admin-content {
        padding: 1rem;
    }
}

.admin-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(6, 13, 26, .5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast);
}

.admin-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.admin-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    height: var(--admin-topbar-height);
    padding-inline: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
}

.admin-brand:hover {
    color: #fff;
}

.admin-brand .bi {
    color: var(--accent);
    font-size: 1.35rem;
}

.admin-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .75rem 2rem;
}

.admin-nav-heading {
    padding: 1rem .75rem .375rem;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .35);
}

[dir="rtl"] .admin-nav-heading {
    letter-spacing: 0;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    margin-bottom: .125rem;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, .72);
    text-decoration: none;
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.admin-nav-link .bi {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.admin-nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

/* The active item is marked with the gold accent, the one place in the
   chrome where it appears, so the eye finds it immediately. */
.admin-nav-link.is-active {
    background: rgba(201, 160, 56, .14);
    color: #fff;
}

.admin-nav-link.is-active .bi {
    color: var(--accent);
}

.admin-nav-badge {
    margin-inline-start: auto;
    font-size: .6875rem;
    font-weight: 700;
    padding: .15rem .45rem;
    border-radius: 999px;
    background: var(--accent);
    color: #1a1205;
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--admin-topbar-height);
    padding-inline: 1.5rem;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
}

@media (max-width: 991.98px) {
    .admin-topbar {
        padding-inline: 1rem;
    }
}

.admin-topbar-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.0625rem;
    color: var(--text-strong);
    margin: 0;
}

.admin-topbar-toggle {
    display: none;
    border: 0;
    background: transparent;
    font-size: 1.35rem;
    color: var(--text-body);
    padding: .25rem;
}

@media (max-width: 991.98px) {
    .admin-topbar-toggle {
        display: inline-flex;
    }
}

/* ==========================================================================
   KPI cards
   ==========================================================================
   A dashboard's job is to be scanned. The figure is the largest thing in
   the card, the label supports it, and the trend is subordinate to both.
   ========================================================================== */

.kpi-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.125rem 1.25rem;
    height: 100%;
    overflow: hidden;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.kpi-card:hover {
    box-shadow: var(--shadow-sm);
}

.kpi-card-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    margin-bottom: .875rem;
}

.kpi-card-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-strong);
}

.kpi-card-label {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

.kpi-card-meta {
    font-size: .75rem;
    margin-top: .625rem;
    color: var(--text-muted);
}

/* Tinted icon chips, one per KPI family. */
.tint-brand   { background: var(--navy-100);    color: var(--navy-700); }
.tint-accent  { background: var(--accent-soft); color: var(--gold-800); }
.tint-success { background: var(--emerald-100); color: var(--emerald-700); }
.tint-warning { background: var(--amber-100);   color: var(--amber-600); }
.tint-danger  { background: var(--rust-100);    color: var(--rust-600); }
.tint-neutral { background: var(--stone-100);   color: var(--stone-700); }

/* ==========================================================================
   Panels and tables
   ========================================================================== */

.admin-panel {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

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

.admin-panel-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: .9375rem;
    margin: 0;
    color: var(--text-strong);
}

.admin-panel-body {
    padding: 1.25rem;
}

.admin-panel-body.is-flush {
    padding: 0;
}

/* DataTables renders a lot of chrome; these calm it down so the data is
   what stands out rather than the controls around it. */
table.dataTable thead th {
    background: var(--stone-050);
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border-subtle) !important;
    white-space: nowrap;
}

[dir="rtl"] table.dataTable thead th {
    letter-spacing: 0;
}

table.dataTable tbody td {
    vertical-align: middle;
    border-bottom: 1px solid var(--stone-100);
}

table.dataTable tbody tr:hover > td {
    background: var(--stone-050);
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
div.dt-container .dt-search input,
div.dt-container .dt-length select {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: .375rem .625rem;
}

div.dt-container .dt-paging .page-link {
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Auth screen
   ==========================================================================
   Deliberately unlike the dashboard: full-bleed brand colour, one card,
   nothing else competing for attention.
   ========================================================================== */

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 20% -10%, rgba(201, 160, 56, .18), transparent 60%),
        linear-gradient(135deg, var(--navy-950) 0%, var(--navy-800) 100%);
}

.auth-card {
    width: 100%;
    max-width: 26rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 2rem;
}

/* A signup form is two fieldsets of paired inputs, not one column of
   three. It gets a card wide enough for the pairs to sit side by side. */
.auth-card-wide {
    max-width: 46rem;
    padding: 2.5rem;
}

.auth-card-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    color: var(--brand);
    margin: 0 0 .375rem;
}

.auth-fieldset-title {
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: .5rem;
    margin: 1.75rem 0 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.auth-card-wide .auth-fieldset-title:first-of-type {
    margin-top: 1.5rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .625rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--brand);
    margin-bottom: .375rem;
}

.auth-brand .bi {
    color: var(--accent);
    font-size: 1.4rem;
}

/* ==========================================================================
   Small parts
   ========================================================================== */

.avatar-circle {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 700;
    font-size: .8125rem;
    flex-shrink: 0;
}

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state .bi {
    font-size: 2.5rem;
    color: var(--stone-300);
    display: block;
    margin-bottom: .75rem;
}

/* Charts must not stretch to whatever height Chart.js feels like. */
.chart-frame {
    position: relative;
    height: 300px;
}

.chart-frame-sm {
    position: relative;
    height: 220px;
}

/* ==========================================================================
   CRUD pages
   ==========================================================================
   The shell every managed module renders into: a page heading with its
   actions, a server-side table, and a two-column form.
   ========================================================================== */

.admin-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-strong);
    margin: 0;
}

.admin-page-subtitle {
    margin: .375rem 0 0;
    font-size: .9375rem;
    color: var(--text-muted);
    max-width: 60ch;
}

.admin-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

/* The buttons at the end of a table row. Kept on one line so a row never
   grows taller than its text. */
.admin-row-actions {
    display: inline-flex;
    gap: .25rem;
    white-space: nowrap;
}

.admin-avatar,
.admin-thumb {
    object-fit: cover;
    border-radius: 50%;
    background: var(--surface-sunken);
}

.admin-avatar {
    width: 40px;
    height: 40px;
}

.admin-thumb {
    width: 64px;
    height: 40px;
    border-radius: var(--radius-sm);
}

.admin-avatar-empty,
.admin-thumb-empty {
    display: inline-grid;
    place-items: center;
    color: var(--text-muted);
}

.admin-rating {
    color: var(--accent);
    font-size: .8125rem;
    white-space: nowrap;
}

.admin-photo-preview {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
}

.admin-cover-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

/* A translated field is two inputs that belong together, so they are
   boxed rather than left looking like two unrelated controls. */
.admin-translatable {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.admin-translatable legend {
    float: none;
    width: auto;
    padding-inline: .5rem;
    margin: 0 0 .5rem;
    font-size: .9375rem;
}

/* Sticky, because a long form should never require scrolling back to
   the top to save. */
.admin-form-actions {
    position: sticky;
    inset-block-end: 0;
    z-index: 5;
    display: flex;
    gap: .5rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
    background: linear-gradient(to top, var(--stone-100) 70%, transparent);
}

/* ---- DataTables chrome ----
   DataTables 2.x renamed every wrapper class: dt-search, dt-length,
   dt-info and dt-paging replaced the dataTables_* names used by 1.x. */

.dt-search input,
.dt-length select {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: .375rem .625rem;
    margin-inline-start: .5rem;
}

.dt-search,
.dt-length,
.dt-info {
    font-size: .875rem;
    color: var(--text-muted);
    padding: .75rem 1rem;
}

.dt-paging {
    padding: .5rem 1rem 1rem;
}

table.dataTable {
    border-collapse: separate;
}

table.dataTable thead th {
    font-size: .8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

table.dataTable tbody td {
    vertical-align: middle;
}

/* The engine's own empty-state row, so it matches the panel rather than
   sitting flush against its edge. */
table.dataTable td.dt-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

/* ---- Moderation panel ---- */

/* The stripe carries the state, so a reviewer opening a listing knows
   where it stands before reading anything. */
.admin-moderation {
    border-inline-start: 4px solid var(--border-subtle);
}

.admin-moderation.is-pending_review { border-inline-start-color: var(--state-warning); }
.admin-moderation.is-approved { border-inline-start-color: var(--state-success); }
.admin-moderation.is-rejected { border-inline-start-color: var(--state-danger); }

.admin-rejection-reason {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--text-body);
    font-size: .9rem;
}

.admin-rejection-reason .bi {
    color: var(--state-danger);
    margin-top: .15rem;
}

/* ---- Read-only facts beside a form ---- */

.admin-meta-list {
    margin: 1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    font-size: .875rem;
}

.admin-meta-list > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .3rem 0;
}

.admin-meta-list dt {
    color: var(--text-muted);
    font-weight: 500;
}

.admin-meta-list dd {
    margin: 0;
    font-weight: 600;
    color: var(--text-strong);
}

.admin-amenity-group {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 1.25rem 0 .5rem;
}

.admin-amenity-group:first-of-type {
    margin-top: 0;
}

.admin-icon-cell {
    font-size: 1.125rem;
    color: var(--brand);
}

/* ---- Settings ---- */

.admin-settings-nav {
    display: grid;
    gap: .125rem;
}

.admin-settings-link {
    display: block;
    padding: .55rem .875rem;
    border-radius: var(--radius-sm);
    color: var(--text-body);
    text-decoration: none;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}

.admin-settings-link:hover {
    background: var(--surface-sunken);
    color: var(--brand);
}

.admin-settings-link.is-active {
    background: var(--brand);
    color: #fff;
}

/* A read-only row in a detail panel. */
.admin-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.admin-list-row:last-child {
    border-bottom: 0;
}

/* ---- Campaign budget bar ---- */

.admin-budget-bar {
    display: block;
    height: 4px;
    margin-top: .35rem;
    border-radius: 999px;
    background: var(--surface-sunken);
    overflow: hidden;
}

.admin-budget-bar > span {
    display: block;
    height: 100%;
    background: var(--brand);
}

/* The company a portal session belongs to. On a tool where every screen
   is scoped to one company, that name is not decoration. */
.admin-tenant {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 .75rem 1rem;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .82);
    font-size: .8125rem;
    font-weight: 500;
}

.admin-tenant .bi {
    flex-shrink: 0;
    opacity: .7;
}

.admin-tenant span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* One entry in a lead's history. */
.admin-timeline-entry {
    padding: .625rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.admin-timeline-entry:last-of-type {
    border-bottom: 0;
}

/* An advertising package, shown as an offer rather than a table row. */
.admin-package-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.25rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}

.admin-package-name {
    font-weight: 700;
    color: var(--text-strong);
}

.admin-package-price {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--brand);
    line-height: 1.3;
}

.admin-package-price small {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-muted);
}
