/* ============================================================================
   Form kit — shared chrome for admin forms
   ----------------------------------------------------------------------------
   Section headers, collapsible boxes, toggle switches, validation states, the
   upload dropzone and the sticky save bar. First built for the product form;
   lifted here so every form on the platform looks the same instead of each
   page re-inventing (and drifting from) the same handful of components.

   Sizing/typography deliberately lives in ui-density.css, which loads after
   this file. Anything here that sets a font-size is a deliberate exception.
   ========================================================================== */

/* ── Section header ──────────────────────────────────────────────────────── */

.sec-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 16px;
}
.sec-title { font-weight: 600; color: #111827; }
.dark .sec-title { color: #fff; }
.sec-hint  { color: #9ca3af; margin-top: 2px; }
.dark .sec-hint { color: rgba(255,255,255,.45); }

/* ── Collapsible sections ────────────────────────────────────────────────
   Add data-collapsible="key" (and optionally data-collapsed="1") to a .box.
   form-kit.js wires the caret, wraps the body and remembers the state. */

.box[data-collapsible] .sec-head,
.box[data-collapsible] > .box-body > .sec-title { cursor: pointer; user-select: none; }
.box.is-collapsed .sec-head { margin-bottom: 0; }
.box.is-collapsed > .box-body > .sec-title { margin-bottom: 0 !important; }
.box.is-collapsed .sec-hint { display: none; }

.sec-collapse { display: block; }
.box.is-collapsed .sec-collapse { display: none; }

.sec-caret {
    margin-left: auto; width: 26px; height: 26px; flex-shrink: 0; border: none; cursor: pointer;
    background: transparent; color: #9ca3af; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .18s, background .15s;
}
.sec-caret:hover { background: #f3f4f6; color: #374151; }
.dark .sec-caret:hover { background: rgba(255,255,255,.07); }
.box.is-collapsed .sec-caret { transform: rotate(-90deg); }

.sec-badge {
    font-weight: 600; color: #6b7280; background: #f3f4f6;
    padding: 2px 8px; border-radius: 999px; margin-left: 10px; white-space: nowrap;
}
.dark .sec-badge { background: rgba(255,255,255,.07); color: #9ca3af; }

/* ── iOS-style toggle ────────────────────────────────────────────────────
   MUST be a <label class="sw">, not a <span> — only a label forwards its
   click to the hidden checkbox. */

.sw { position: relative; display: inline-block; width: 38px; height: 21px; flex-shrink: 0; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span {
    position: absolute; inset: 0; background: #d1d5db; border-radius: 999px;
    cursor: pointer; transition: background .18s;
}
.sw span::before {
    content: ''; position: absolute; height: 15px; width: 15px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .18s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.sw input:checked + span { background: #4f46e5; }
.sw input:checked + span::before { transform: translateX(17px); }
.sw input:focus-visible + span { box-shadow: 0 0 0 2px rgba(99,102,241,.35); }

/* A toggle with its caption. */
.sw-row { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 0; }
.sw-row .sw-label { color: #4b5563; line-height: 1.4; }
.dark .sw-row .sw-label { color: #d1d5db; }
.sw-row .sw-sub { display: block; color: #9ca3af; }

/* ── Combobox (typeahead select) ──────────────────────────────────────────
   Look only — height, padding and font come from Common/css/ui-density.css so
   every combobox on the platform stays on the same scale. Lives here rather
   than in a page's own <style> because both layouts load this file, so any
   screen can use the widget: the product form, the Control Panel category
   manager, and anything added later. */

.combo { position: relative; }
.combo-control {
    display: flex; flex-wrap: wrap; align-items: center;
    border: 1px solid #d1d5db; border-radius: var(--ui-radius, 6px); background: #fff;
    cursor: text; transition: border-color .15s, box-shadow .15s;
}
.combo-control.is-focused { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,.15); }
.dark .combo-control { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.12); }
.combo-input {
    flex: 1; border: none !important; outline: none !important; box-shadow: none !important;
    background: transparent; color: #111827;
}
.combo-input:focus { border: none !important; outline: none !important; box-shadow: none !important; }
.dark .combo-input { color: #fff; }
.combo-chip { display: inline-flex; align-items: center; gap: 6px; background: #eef2ff; color: #4338ca; border-radius: 5px; font-weight: 500; line-height: 1.4; }
.dark .combo-chip { background: rgba(99,102,241,.2); color: #c7d2fe; }
.combo-chip .chip-x { cursor: pointer; font-size: 14px; line-height: 1; opacity: .7; }
.combo-chip .chip-x:hover { opacity: 1; }
.combo-dropdown {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; background: #fff;
    border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,.14); overflow: hidden; display: none; max-height: 260px; overflow-y: auto;
}
.combo-dropdown.is-open { display: block; }
.dark .combo-dropdown { background: #1f2937; border-color: rgba(255,255,255,.1); }
.combo-opt { color: #374151; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.combo-opt:hover, .combo-opt.is-active { background: #f3f4f6; }
.dark .combo-opt { color: #e5e7eb; }
.dark .combo-opt:hover, .dark .combo-opt.is-active { background: rgba(255,255,255,.06); }
.combo-add { font-weight: 600; color: #fff; background: #6d28d9; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.combo-add:hover { background: #5b21b6; }
.combo-opt small { color: #9ca3af; flex: 0 0 auto; }
.combo-note { color: #9ca3af; text-align: center; }

/* ── Validation ──────────────────────────────────────────────────────────── */

.input-error { border-color: #ef4444 !important; box-shadow: 0 0 0 1px rgba(239,68,68,.25) !important; }
.combo.input-error .combo-control { border-color: #ef4444 !important; }
.field-error { color: #ef4444; margin-top: 4px; }
.form-error-box { background: #fef2f2; color: #dc2626; padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; }
.dark .form-error-box { background: rgba(239,68,68,.12); }

.req { color: #ef4444; }

/* ── Upload dropzone ─────────────────────────────────────────────────────── */

.upload-dropzone {
    border: 1.5px dashed #d1d5db; border-radius: 10px; padding: 18px 16px; text-align: center;
    cursor: pointer; transition: all .2s; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px; background: #fafafa;
}
.upload-dropzone:hover { border-color: #6366f1; background: rgba(99,102,241,.03); }
.dark .upload-dropzone { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.02); }
.upload-dropzone .dz-icon  { color: #9ca3af; font-size: 24px; }
.upload-dropzone .dz-links { color: #6b7280; }
.upload-dropzone .dz-links .dz-link { color: #4f46e5; font-weight: 600; }
.upload-dropzone .dz-hint  { color: #9ca3af; }
.upload-dropzone.has-file  { border-style: solid; background: #fff; }

/* Square preview used next to a file input. */
.file-preview {
    width: 72px; height: 72px; border-radius: 8px; object-fit: cover;
    border: 1px solid #e5e7eb; background: #f3f4f6; flex-shrink: 0;
}
.dark .file-preview { border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.05); }

/* ── Sticky save bar ─────────────────────────────────────────────────────── */

.save-bar {
    position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; padding: 10px 14px; margin-top: 20px;
    background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
    border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 -4px 16px rgba(0,0,0,.05);
}
.dark .save-bar { background: rgba(31,41,55,.92); border-color: rgba(255,255,255,.1); }
.save-meta { color: #6b7280; }
.dark .save-meta { color: #9ca3af; }

/* ── Read-only info callout ──────────────────────────────────────────────── */

.info-note { padding: 10px 12px; border-radius: 8px; line-height: 1.5; }
.info-note.is-info    { background: rgba(59,130,246,.10); color: #1d4ed8; }
.info-note.is-warn    { background: rgba(245,158,11,.12); color: #b45309; }
.info-note.is-success { background: rgba(34,197,94,.12);  color: #15803d; }
.dark .info-note.is-info    { color: #93c5fd; }
.dark .info-note.is-warn    { color: #fcd34d; }
.dark .info-note.is-success { color: #86efac; }

/* ── Subscription gate overlay (shared by product + brand forms) ─────────── */

.subscription-locked { position: relative; pointer-events: none; opacity: .6; filter: blur(3px); }
.subscription-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.4); z-index: 1;
}
.subscription-message {
    background: #fff; padding: 14px 22px; position: absolute; top: 20vh; border-radius: 8px;
    font-weight: 600; box-shadow: 0 4px 10px rgba(0,0,0,.15);
}

/* ── Breadcrumb used on the newer form pages ─────────────────────────────── */

.form-crumbs { display: flex; align-items: center; gap: 8px; color: #9ca3af; margin-bottom: 6px; }
.form-crumbs a { color: #6b7280; text-decoration: none; }
.form-crumbs a:hover { color: #4f46e5; }
.form-crumbs .current {
    font-weight: 500; background: #374151; color: #fff; padding: 2px 10px; border-radius: 4px;
}
.dark .form-crumbs .current { background: rgba(255,255,255,.2); }
