/**
 * Almada — Admin Panel Styles
 * Same design language as the public site: dark void, acid lime accent,
 * hairline borders, Inter / Cairo.
 */

:root {
    --void: #08090a;
    --carbon: #0f1011;
    --obsidian: #161718;
    --graphite: #23252a;
    --smoke: #383b3f;
    --ash: #62666d;
    --fog: #8a8f98;
    --mist: #d0d6e0;
    --bone: #e5e5e6;
    --paper: #ffffff;
    --lime: #e4f222;
    --green: #27a644;
    --red: #eb5757;
    --teal: #02b8cc;
    --violet: #6366f1;
    --amber: #f5a524;
    --hairline: rgba(255, 255, 255, 0.08);
    --radius: 10px;
    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-ar: 'Cairo', 'Inter', sans-serif;
}

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

html[dir="rtl"] { --font: 'Cairo', 'Inter', sans-serif; }

body {
    font-family: var(--font);
    background: var(--void);
    color: var(--bone);
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Shell ---------- */

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

.sidebar {
    width: 236px;
    flex-shrink: 0;
    background: var(--carbon);
    border-inline-end: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--hairline);
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--lime);
    color: var(--void);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.brand-text strong { display: block; font-size: 14px; font-weight: 600; }
.brand-text span { display: block; font-size: 11px; color: var(--ash); }

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--fog);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: start;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--obsidian); color: var(--bone); }
.nav-item.active { background: var(--graphite); color: var(--paper); }

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-badge {
    margin-inline-start: auto;
    background: var(--red);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 20px;
    min-width: 18px;
    text-align: center;
}

.side-foot {
    padding: 12px 10px;
    border-top: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.side-user {
    padding: 10px 12px;
    font-size: 11.5px;
    color: var(--ash);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Main ---------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 28px;
    border-bottom: 1px solid var(--hairline);
    background: rgba(8, 9, 10, 0.85);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar h1 { font-size: 19px; font-weight: 600; letter-spacing: -0.2px; }
.topbar p { font-size: 12.5px; color: var(--ash); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.content { padding: 28px; flex: 1; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 7px;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    color: var(--bone);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover { background: var(--graphite); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--lime); color: #0a0b0c; border-color: var(--lime); font-weight: 600; }
.btn-primary:hover { background: #eeff4a; }

.btn-danger { color: var(--red); border-color: rgba(235, 87, 87, 0.3); }
.btn-danger:hover { background: rgba(235, 87, 87, 0.12); }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ---------- Stat cards ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--carbon);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--ash);
    font-weight: 500;
}

.stat-value {
    font-size: 27px;
    font-weight: 600;
    letter-spacing: -0.9px;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.lime { color: var(--lime); }

/* ---------- Card / panel ---------- */

.panel {
    background: var(--carbon);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--hairline);
    flex-wrap: wrap;
}

.panel-head h2 { font-size: 15px; font-weight: 600; }
.panel-head p { font-size: 12px; color: var(--ash); margin-top: 2px; }

.search {
    padding: 7px 12px;
    border-radius: 7px;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    color: var(--bone);
    font-size: 13px;
    font-family: inherit;
    min-width: 220px;
}

.search:focus { outline: none; border-color: var(--smoke); }
.search::placeholder { color: var(--ash); }

/* ---------- Table ---------- */

.table-wrap { overflow-x: auto; }

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

th {
    text-align: start;
    padding: 10px 16px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--ash);
    font-weight: 600;
    border-bottom: 1px solid var(--hairline);
    white-space: nowrap;
    background: var(--carbon);
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
    font-size: 13px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.018); }

/* A product on hold is dimmed so the eye catches the difference */
tbody tr.row-hold { opacity: 0.55; }
tbody tr.row-hold:hover { opacity: 0.85; }

.cell-main { font-weight: 500; color: var(--bone); }
.cell-sub { font-size: 11.5px; color: var(--ash); margin-top: 1px; }
.cell-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }

html[dir="rtl"] .cell-actions { justify-content: flex-start; }

.empty {
    padding: 56px 24px;
    text-align: center;
    color: var(--ash);
    font-size: 13.5px;
}

.loading { padding: 56px 24px; text-align: center; color: var(--ash); font-size: 13.5px; }

/* ---------- Pills ---------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.pill-green  { background: rgba(39, 166, 68, 0.14);  color: #4ade80; border-color: rgba(39, 166, 68, 0.3); }
.pill-red    { background: rgba(235, 87, 87, 0.14);  color: #f87171; border-color: rgba(235, 87, 87, 0.3); }
.pill-amber  { background: rgba(245, 165, 36, 0.14); color: #fbbf24; border-color: rgba(245, 165, 36, 0.3); }
.pill-blue   { background: rgba(99, 102, 241, 0.14); color: #a5b4fc; border-color: rgba(99, 102, 241, 0.3); }
.pill-grey   { background: rgba(255, 255, 255, 0.05); color: var(--fog); border-color: var(--hairline); }
.pill-lime   { background: rgba(228, 242, 34, 0.13); color: var(--lime); border-color: rgba(228, 242, 34, 0.28); }

.dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ---------- Modal ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.active { display: flex; }

.modal-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(3px); }

.modal-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--carbon);
    border: 1px solid var(--graphite);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--hairline);
    position: sticky;
    top: 0;
    background: var(--carbon);
    z-index: 1;
}

.modal-head h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    color: var(--ash);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    font-family: inherit;
}

.modal-close:hover { color: var(--bone); }

.modal-body { padding: 20px; }

.modal-foot {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--hairline);
}

html[dir="rtl"] .modal-foot { justify-content: flex-start; }

/* ---------- Form ---------- */

.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--fog);
    margin-bottom: 5px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: 7px;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    color: var(--bone);
    font-size: 13.5px;
    font-family: inherit;
}

.field textarea { resize: vertical; min-height: 72px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--smoke);
    background: var(--graphite);
}

.field input::placeholder, .field textarea::placeholder { color: var(--ash); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field-hint { font-size: 11px; color: var(--ash); margin-top: 4px; }

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--fog);
    cursor: pointer;
    user-select: none;
}

.check input { width: 15px; height: 15px; accent-color: var(--lime); cursor: pointer; }

/* ---------- Messages ---------- */

.msg-list { display: flex; flex-direction: column; }

.msg {
    padding: 16px 18px;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.msg:last-child { border-bottom: none; }
.msg.unread { background: rgba(228, 242, 34, 0.028); }

.msg-body { flex: 1; min-width: 0; }

.msg-top {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.msg-name { font-weight: 600; font-size: 13.5px; }
.msg-email { font-size: 12px; color: var(--teal); }
.msg-subject { font-size: 13px; color: var(--mist); margin-bottom: 4px; font-weight: 500; }
.msg-text { font-size: 13px; color: var(--fog); white-space: pre-wrap; word-break: break-word; }
.msg-time { font-size: 11px; color: var(--ash); white-space: nowrap; flex-shrink: 0; }

/* ---------- Access denied ---------- */

.denied {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    text-align: center;
}

.denied-card {
    max-width: 420px;
    padding: 40px 32px;
    background: var(--carbon);
    border: 1px solid var(--hairline);
    border-radius: 14px;
}

.denied-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(235, 87, 87, 0.13);
    color: var(--red);
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
}

.denied-card h1 { font-size: 19px; font-weight: 600; margin-bottom: 8px; }
.denied-card p { font-size: 13.5px; color: var(--ash); margin-bottom: 22px; }

.denied-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.denied-card .btn-block { width: 100%; justify-content: center; }

.denied-note {
    margin-top: 18px;
    padding: 10px 12px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    background: rgba(245, 165, 36, 0.07);
    color: #fbbf24;
    font-size: 11.5px;
    line-height: 1.5;
    text-align: start;
}

.denied-note code {
    font-family: var(--font);
    background: rgba(255, 255, 255, 0.07);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    bottom: 24px;
    inset-inline-end: 24px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 18px;
    border-radius: 9px;
    background: var(--obsidian);
    border: 1px solid var(--graphite);
    color: var(--bone);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.toast.active { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(39, 166, 68, 0.5); }
.toast.error { border-color: rgba(235, 87, 87, 0.5); }
.toast .dot { width: 7px; height: 7px; border-radius: 50%; }
.toast.success .dot { background: var(--green); }
.toast.error .dot { background: var(--red); }
.toast.info .dot { background: var(--teal); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-inline-end: none;
        border-bottom: 1px solid var(--hairline);
    }
    .nav { flex-direction: row; overflow-x: auto; }
    .nav-item { white-space: nowrap; }
    .side-foot { flex-direction: row; align-items: center; gap: 8px; }
    .side-user { flex: 1; }
    .topbar { padding: 16px 18px; }
    .content { padding: 18px; }
    .field-row { grid-template-columns: 1fr; }
    .panel-head { flex-direction: column; align-items: stretch; }
    .search { min-width: 0; width: 100%; }
}

/* ============================================
   Display tab — editing the public page
   ============================================ */

.search-wrap { flex-shrink: 0; }

.display-filters {
    display: flex;
    gap: 6px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--hairline);
    flex-wrap: wrap;
}

.chip {
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    color: var(--fog);
    font-size: 12.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover { background: var(--graphite); color: var(--bone); }
.chip.active { background: var(--lime); color: #0a0b0c; border-color: var(--lime); font-weight: 600; }

.content-editor { padding: 0; }

.content-group { border-bottom: 1px solid var(--hairline); }
.content-group:last-child { border-bottom: none; }

.group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.015);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ash);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    backdrop-filter: blur(6px);
}

.content-row {
    display: grid;
    grid-template-columns: 190px 1fr 1fr;
    gap: 14px;
    padding: 14px 18px;
    border-top: 1px solid var(--hairline);
    align-items: start;
}

.content-row:first-of-type { border-top: none; }

.content-key { padding-top: 22px; min-width: 0; }

.content-key code {
    display: block;
    font-family: var(--font);
    font-size: 11.5px;
    color: var(--teal);
    word-break: break-all;
    line-height: 1.4;
}

.content-key .is-custom {
    display: inline-block;
    margin-top: 5px;
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: rgba(2, 184, 204, 0.14);
    color: var(--teal);
    border: 1px solid rgba(2, 184, 204, 0.3);
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 600;
}

.content-field label {
    display: block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--ash);
    font-weight: 600;
    margin-bottom: 5px;
}

.content-field input,
.content-field textarea {
    width: 100%;
    padding: 8px 11px;
    border-radius: 7px;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    color: var(--bone);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
}

.content-field textarea { resize: vertical; min-height: 40px; }

.content-field input:focus,
.content-field textarea:focus {
    outline: none;
    border-color: var(--smoke);
    background: var(--graphite);
}

.content-field input::placeholder,
.content-field textarea::placeholder { color: var(--ash); opacity: 0.7; }

.dirty input, .dirty textarea { border-color: rgba(245, 165, 36, 0.55); }

html[dir="rtl"] .content-field textarea[dir="ltr"] { text-align: left; }
html[dir="ltr"] .content-field textarea[dir="rtl"] { text-align: right; }

.stat-edit {
    display: grid;
    grid-template-columns: 110px 70px 1fr 1fr 40px;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--hairline);
}

.stat-edit:last-child { border-bottom: none; }

.stat-edit input[type="text"],
.stat-edit input[type="number"] {
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    color: var(--bone);
    font-size: 13px;
    font-family: inherit;
    width: 100%;
}

.stat-edit input:focus { outline: none; border-color: var(--smoke); }

.stat-edit .stat-label-en { border-color: rgba(99, 102, 241, 0.25); }
.stat-edit .stat-label-ar { border-color: rgba(228, 242, 34, 0.2); }

.stat-edit-head {
    display: grid;
    grid-template-columns: 110px 70px 1fr 1fr 40px;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--graphite);
    margin-bottom: 4px;
}

.stat-edit-head span {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--ash);
    font-weight: 600;
}

.stat-vis-toggle { display: grid; place-items: center; cursor: pointer; }
.stat-vis-toggle input { width: 15px; height: 15px; accent-color: var(--lime); cursor: pointer; }

@media (max-width: 980px) {
    .content-row { grid-template-columns: 1fr; gap: 10px; }
    .content-key { padding-top: 0; }
    .stat-edit, .stat-edit-head { grid-template-columns: 1fr 1fr; }
    .stat-edit-head { display: none; }
}

.counter-live {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--ash);
}

.counter-live .pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============================================
   Panel footer — save bar
   ============================================ */

.panel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 18px;
    border-top: 1px solid var(--hairline);
    background: rgba(255, 255, 255, 0.012);
    flex-wrap: wrap;
}

.counter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.counter-controls label {
    font-size: 12px;
    color: var(--ash);
    white-space: nowrap;
}

.counter-controls input {
    width: 108px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    color: var(--bone);
    font-size: 13px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.counter-controls input:focus { outline: none; border-color: var(--smoke); }

@media (max-width: 620px) {
    .panel-foot { flex-direction: column; align-items: stretch; }
    .panel-foot .btn { justify-content: center; }
    .counter-controls { justify-content: space-between; }
}

/* ============================================
   Product image field
   ============================================ */

.upload-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.upload-status {
    font-size: 12px;
    color: var(--ash);
}

.upload-status.ok { color: #4ade80; }
.upload-status.busy { color: #fbbf24; }
.upload-status.err { color: #f87171; }

.image-preview {
    margin-top: 12px;
    width: 100%;
    height: 168px;
    border-radius: 9px;
    border: 1px dashed var(--hairline);
    background: var(--obsidian);
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
}

.image-preview-empty {
    font-size: 12px;
    color: var(--ash);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.image-thumb {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--hairline);
    background: var(--obsidian);
    display: block;
}

.image-thumb-empty {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    border: 1px dashed var(--hairline);
    display: grid;
    place-items: center;
    color: var(--ash);
    font-size: 9px;
}

.product-cell {
    display: flex;
    align-items: center;
    gap: 11px;
}

.product-cell .image-thumb,
.product-cell .image-thumb-empty {
    flex-shrink: 0;
}
