/* ════════════════════════════════════════════════════════════
   THEME.CSS — shared design tokens + chrome used by BOTH
   catalog.html (public) and editor.html (internal admin tool)
   ════════════════════════════════════════════════════════════ */

:root {
    --navy: #0D2840;
    --ink: #0A1E26;
    --slate: #475459;
    --silver: #92A0A6;
    --cloud: #F2F2F2;
    --white: #FFFFFF;
    --black: #060F14;
    --divider: rgba(71, 84, 89, 0.14);

    /* Destructive / warning accent — kept muted so it sits quietly
       inside the navy/slate palette instead of fighting it */
    --danger: #8C3A35;
    --danger-strong: #732C28;
    --danger-tint: rgba(140, 58, 53, 0.08);
    --success: #2F6B4F;
    --success-tint: rgba(47, 107, 79, 0.09);

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-ar: 'Cairo', Arial, sans-serif;

    --r-sm: 4px;
    --r-md: 10px;
    --r-lg: 18px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur: 0.3s;
    --nav-h: 62px;
    --sidebar-w: 240px;
}

/* ─── RESET ─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--white);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

html[lang="ar"] body,
html[lang="ar"] p,
html[lang="ar"] span,
html[lang="ar"] button,
html[lang="ar"] a,
html[lang="ar"] input {
    font-family: var(--font-ar);
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3 {
    font-family: var(--font-ar);
    line-height: 1.35;
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    line-height: 1.15;
}

img {
    max-width: 100%;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
}

/* Visible keyboard focus everywhere */
:focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: 2px;
}

/* Slim themed scrollbar utility */
.themed-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--cloud) transparent;
}

.themed-scroll::-webkit-scrollbar {
    width: 4px;
}

.themed-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.themed-scroll::-webkit-scrollbar-thumb {
    background: var(--cloud);
    border-radius: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ─── TOPBAR (shared shell for both pages) ────────────── */
#topbar {
    position: fixed;
    top: 0;
    inset-inline: 0;
    z-index: 500;
    height: var(--nav-h);
    background: var(--ink);
    border-bottom: 1px solid rgba(146, 160, 166, 0.1);
    display: flex;
    align-items: center;
}

.topbar-inner {
    width: 100%;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.tb-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
}

.tb-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    border: 1.5px dashed rgba(146, 160, 166, 0.35);
    background: rgba(13, 40, 64, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--silver);
    font-size: 0.42rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: center;
    flex-direction: column;
}

.tb-logo i {
    font-size: 0.85rem;
    margin-bottom: 1px;
    opacity: 0.45;
}

.tb-name {
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--white);
}

html[lang="ar"] .tb-name {
    font-family: var(--font-ar);
    font-size: 0.96rem;
}

.tb-divider {
    width: 1px;
    height: 20px;
    background: rgba(146, 160, 166, 0.2);
    flex-shrink: 0;
}

.tb-page {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--silver);
    opacity: 0.7;
}

html[lang="ar"] .tb-page {
    letter-spacing: 0;
    font-size: 0.78rem;
}

.tb-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.tb-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--silver);
    border: 1px solid rgba(146, 160, 166, 0.2);
    border-radius: var(--r-sm);
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    background: none;
    transition: color var(--dur), border-color var(--dur), background var(--dur);
}

html[lang="ar"] .tb-back {
    letter-spacing: 0;
    font-size: 0.78rem;
}

.tb-back:hover {
    color: var(--cloud);
    border-color: rgba(146, 160, 166, 0.45);
    background: rgba(255, 255, 255, 0.05);
}

.lang-pill {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 2rem;
    padding: 3px;
    gap: 2px;
}

.lbtn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.2rem 0.7rem;
    border-radius: 2rem;
    transition: background var(--dur), color var(--dur);
}

.lbtn.active {
    background: var(--navy);
    color: var(--white);
}

/* ─── SHARED SIDEBAR (brand nav — catalog + editor) ───── */
#sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    overflow-x: hidden;
    background: #f7f8f9;
    border-inline-end: 1px solid var(--divider);
    padding: 1.75rem 0 2rem;
}

@media (max-width: 860px) {
    #sidebar {
        display: none;
    }
}

.sb-heading {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--silver);
    padding: 0 1.25rem 0.85rem;
    border-bottom: 1px solid var(--divider);
    margin-bottom: 0.5rem;
}

html[lang="ar"] .sb-heading {
    letter-spacing: 0;
    font-size: 0.67rem;
}

.sb-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--slate);
    cursor: pointer;
    border-inline-start: 2.5px solid transparent;
    transition: color var(--dur), background var(--dur), border-color var(--dur);
    text-align: start;
    background: none;
    border-top: none;
    border-bottom: none;
    border-inline-end: none;
    width: 100%;
}

.sb-link-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.sb-link-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sb-logo {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--cloud);
    border: 1px solid var(--divider);
}

.sb-link:hover {
    background: rgba(13, 40, 64, 0.04);
    color: var(--navy);
}

.sb-link.active {
    border-inline-start-color: var(--navy);
    color: var(--navy);
    background: rgba(13, 40, 64, 0.05);
    font-weight: 600;
}

.sb-count {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--silver);
    opacity: 0.7;
    background: var(--cloud);
    padding: 0.1rem 0.45rem;
    border-radius: 2rem;
    flex-shrink: 0;
}

/* Mobile pill bar (brand filter) */
#pill-bar {
    display: none;
    position: sticky;
    top: var(--nav-h);
    z-index: 400;
    background: var(--white);
    border-bottom: 1px solid var(--divider);
    padding: 0.75rem 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

#pill-bar::-webkit-scrollbar {
    display: none;
}

.pill-row {
    display: flex;
    gap: 0.5rem;
    width: max-content;
}

.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 1rem;
    border-radius: 2rem;
    border: 1.5px solid var(--divider);
    background: transparent;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur), color var(--dur), border-color var(--dur);
}

.brand-pill.active {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

.brand-pill .pill-logo {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}

.brand-pill .pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 0.6rem;
    font-weight: 700;
}

.brand-pill:not(.active) .pill-count {
    background: var(--cloud);
    color: var(--slate);
}

@media (max-width: 860px) {
    #pill-bar {
        display: block;
    }
}

/* ─── BUTTONS ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.65rem 1.25rem;
    border-radius: var(--r-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background var(--dur), color var(--dur), border-color var(--dur), transform var(--dur), opacity var(--dur);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--navy);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--ink);
}

.btn-ghost {
    background: transparent;
    color: var(--slate);
    border-color: var(--divider);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--silver);
    color: var(--navy);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-strong);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.7rem;
}

.btn-block {
    width: 100%;
}

.btn .fa-spin-loader {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    border: 1.5px solid var(--divider);
    background: var(--white);
    color: var(--slate);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background var(--dur), border-color var(--dur), color var(--dur);
    flex-shrink: 0;
}

.icon-btn:hover {
    border-color: var(--silver);
    color: var(--navy);
}

.icon-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-tint);
}

/* ─── FORM FIELDS ──────────────────────────────────────── */
.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.1rem;
}

.field label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--slate);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field textarea {
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.7rem 0.85rem;
    border: 1.5px solid var(--divider);
    border-radius: var(--r-sm);
    background: var(--white);
    color: var(--ink);
    transition: border-color var(--dur);
    width: 100%;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--navy);
    outline: none;
}

.field textarea {
    resize: vertical;
    min-height: 84px;
    font-family: var(--font-body);
}

.field-hint {
    font-size: 0.74rem;
    color: var(--silver);
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    background: var(--danger-tint);
    border: 1px solid rgba(140, 58, 53, 0.18);
    border-radius: var(--r-sm);
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
}

/* File / image dropzone */
.dropzone {
    border: 1.5px dashed var(--divider);
    border-radius: var(--r-md);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    cursor: pointer;
    transition: border-color var(--dur), background var(--dur);
    position: relative;
}

.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--navy);
    background: rgba(13, 40, 64, 0.03);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dz-preview {
    width: 56px;
    height: 56px;
    border-radius: var(--r-sm);
    background: var(--cloud);
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--divider);
}

.dz-text {
    font-size: 0.82rem;
    color: var(--slate);
}

.dz-text strong {
    color: var(--navy);
}

.dz-filename {
    font-size: 0.74rem;
    color: var(--silver);
    margin-top: 2px;
}

/* ─── MODAL ────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(6, 15, 20, 0.62);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-card {
    background: var(--white);
    border-radius: var(--r-lg);
    max-width: 460px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 1.75rem;
    transform: scale(0.95) translateY(8px);
    transition: transform 0.2s var(--ease);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.35);
}

.modal-overlay.open .modal-card {
    transform: scale(1) translateY(0);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.modal-head h3 {
    font-size: 1.15rem;
    color: var(--navy);
    font-weight: 700;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.confirm-card {
    text-align: center;
    max-width: 380px;
}

.confirm-card i {
    font-size: 1.9rem;
    color: var(--danger);
    background: var(--danger-tint);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.confirm-card h3 {
    font-size: 1.05rem;
    color: var(--ink);
    margin-bottom: 0.5rem;
}

.confirm-card p {
    font-size: 0.86rem;
    color: var(--slate);
    line-height: 1.6;
}

.confirm-card .modal-actions {
    justify-content: center;
    margin-top: 1.5rem;
}

/* ─── TOAST ────────────────────────────────────────────── */
#toastContainer {
    position: fixed;
    bottom: 1.5rem;
    inset-inline-end: 1.5rem;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 340px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: var(--ink);
    color: var(--cloud);
    padding: 0.8rem 1rem;
    border-radius: var(--r-md);
    font-size: 0.82rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    animation: toast-in 0.25s var(--ease);
}

.toast.success {
    border-inline-start: 3px solid var(--success);
}

.toast.error {
    border-inline-start: 3px solid var(--danger);
}

.toast i {
    margin-top: 1px;
}

.toast.success i {
    color: #5FBF8F;
}

.toast.error i {
    color: #E08A85;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Generic spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.spinner.dark {
    border-color: rgba(13, 40, 64, 0.2);
    border-top-color: var(--navy);
}

[hidden] {
    display: none !important;
}