/* ==========================================================================
   App boilerplate — design tokens
   --------------------------------------------------------------------------
   Everything below reads from the custom properties in :root. Re-skinning
   an app built from this boilerplate should mostly mean editing this block
   and nothing else.
   ========================================================================== */

:root {
    --brand-50: #f4f1ee;
    --brand-100: #e8e1da;
    --brand-200: #cfc0b1;
    --brand-300: #ac9683;
    --brand-400: #8a715c;
    --brand-500: #6b5643;
    --brand-600: #5b4636;
    --brand-700: #47372a;

    --bg: #f6f4f1;
    --surface: #fdfcfb;
    --surface-strong: #ffffff;
    --line: #e2ddd5;
    --line-soft: #ece8e1;
    --text: #221e1a;
    --muted: #6f6862;
    --accent: var(--brand-500);
    --accent-dark: var(--brand-700);
    --success: #e7f6ec;
    --success-text: #205a34;
    --danger: #a63b31;
    --danger-bg: #fff0ee;

    --shadow-sm: 0 1px 2px rgba(30, 24, 16, 0.06), 0 2px 8px rgba(30, 24, 16, 0.04);
    --shadow-md: 0 4px 12px rgba(30, 24, 16, 0.08), 0 12px 28px rgba(30, 24, 16, 0.07);

    --radius: 14px;
    --radius-sm: 10px;

    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
    --bg: #1b1815;
    --surface: #232019;
    --surface-strong: #29251e;
    --line: #3a352c;
    --line-soft: #322e26;
    --text: #f1ede6;
    --muted: #b3a99b;
    --success: #16321f;
    --success-text: #8fd6a4;
    --danger-bg: #3a1c18;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1b1815;
        --surface: #232019;
        --surface-strong: #29251e;
        --line: #3a352c;
        --line-soft: #322e26;
        --text: #f1ede6;
        --muted: #b3a99b;
        --success: #16321f;
        --success-text: #8fd6a4;
        --danger-bg: #3a1c18;
    }
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

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

img {
    display: block;
    max-width: 100%;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.shell {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

/* ==========================================================================
   Header / nav
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    margin: -24px -24px 24px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
    backdrop-filter: blur(12px);
}

.site-header-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 16px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.site-search {
    display: flex;
    flex: 1 1 260px;
    max-width: 420px;
    min-width: 0;
}

.site-search input {
    min-width: 0;
    border-radius: 999px 0 0 999px;
    border-right: 0;
}

.site-search button {
    display: grid;
    place-items: center;
    width: 44px;
    border: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 999px 999px 0;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}

.site-search button:hover {
    color: var(--accent-dark);
}

.site-search svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 720px) {
    .site-search {
        order: 3;
        flex-basis: 100%;
        max-width: none;
    }
}

.brand {
    display: inline-flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.brand-lockup {
    display: grid;
    line-height: 1.1;
}

.brand-name {
    font-weight: 700;
}

.brand-tagline {
    color: var(--muted);
    font-size: 0.78rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.site-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 9px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    transition: background-color 0.15s ease;
}

.site-nav-link:hover {
    background: var(--line-soft);
}

.site-footer {
    display: flex;
    justify-content: center;
    gap: 18px;
    padding: 8px 4px 24px;
    color: var(--muted);
    font-size: 0.9rem;
}

.locale-bar {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.language-switch select {
    width: auto;
    min-height: 36px;
    padding: 6px 10px;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4 {
    font-weight: 800;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.15; }
h2 { font-size: clamp(1.1rem, 2vw, 1.35rem); line-height: 1.25; }
h3 { font-size: 1.02rem; line-height: 1.3; font-weight: 700; }

.eyebrow {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-dark);
}

.muted { color: var(--muted); }

/* ==========================================================================
   Page layout
   ========================================================================== */

.page {
    display: grid;
    gap: 24px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.section-head.compact {
    align-items: flex-start;
}

.section-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.detail-panel {
    padding: 24px;
    border-radius: var(--radius);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    display: grid;
    gap: 18px;
}

.danger-panel {
    border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}

/* ==========================================================================
   Hero (home page)
   ========================================================================== */

.hero {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 32px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--surface-strong), var(--brand-50));
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}

.hero-copy {
    flex: 1 1 320px;
}

.hero-copy p {
    max-width: 56ch;
    color: var(--muted);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.hero-card {
    flex: 1 1 280px;
    padding: 24px;
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    align-self: center;
}

.hero-card ul {
    margin: 12px 0 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.button.small {
    min-height: 34px;
    padding: 0 14px;
    font-size: 0.85rem;
}

.button:active {
    transform: translateY(1px);
}

.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.button.primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.button.ghost {
    background: var(--surface);
}

.button.ghost:hover {
    background: var(--line-soft);
}

.button.danger {
    color: var(--danger);
}

.button.danger:hover {
    background: var(--danger-bg);
    border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}

.button[disabled] {
    opacity: 0.55;
    pointer-events: none;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form {
    display: grid;
    gap: 18px;
    padding: 0;
}

.auth-wrap {
    display: grid;
    place-items: center;
    padding: 24px 0;
}

.auth-card {
    width: min(100%, 480px);
    padding: 28px;
    border-radius: var(--radius);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

label, .checkbox {
    display: grid;
    gap: 6px;
}

label > span {
    font-size: 0.86rem;
    font-weight: 600;
}

label small {
    color: var(--muted);
    font-size: 0.8rem;
}

input, textarea, select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

input[disabled], textarea[disabled], select[disabled] {
    opacity: 0.6;
}

.checkbox {
    grid-auto-flow: column;
    justify-content: start;
    align-items: center;
}

.checkbox input {
    width: auto;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-row input {
    width: auto;
}

.flash, .error-box, .field-hint {
    padding: 16px 18px;
    border-radius: var(--radius-sm);
}

.flash-success, .field-hint-success {
    background: var(--success);
    color: var(--success-text);
}

.flash-error, .error-box, .field-hint-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.field-hint {
    padding: 10px 14px;
    font-size: 0.88rem;
}

.empty-state {
    display: grid;
    gap: 10px;
    place-items: center;
    text-align: center;
    padding: 40px 20px;
    min-height: 200px;
    border-radius: var(--radius);
    background: var(--surface-strong);
    border: 1px solid var(--line);
}

/* ==========================================================================
   Tags / status badges
   ========================================================================== */

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--line-soft);
    font-size: 0.76rem;
    font-weight: 600;
    transition: background-color 0.15s ease;
}

a.tag:hover {
    background: color-mix(in srgb, var(--accent) 14%, var(--line-soft));
}

.tag.muted {
    background: var(--line-soft);
    color: var(--muted);
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.plain-list {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
}

.status-badge.status-disabled {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ==========================================================================
   Admin table
   ========================================================================== */

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

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

.admin-table th, .admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.admin-table small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-actions form {
    margin: 0;
}

.user-search {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.user-search label {
    flex: 1 1 260px;
    min-width: 0;
}

/* ==========================================================================
   Autocomplete widget
   --------------------------------------------------------------------------
   Generic — used anywhere a text input needs live suggestions. Pair with
   createAutocompletePanel() / installFillAutocomplete() in app.js.
   ========================================================================== */

.search-autocomplete {
    position: relative;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 30;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    box-shadow: var(--shadow-md);
    transform-origin: top center;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-suggestions.is-hidden {
    display: none;
}

.search-suggestions.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.search-suggestion {
    display: grid;
    width: 100%;
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid var(--line-soft);
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.search-suggestion:last-child {
    border-bottom: 0;
}

.search-suggestion:hover, .search-suggestion.is-active {
    background: var(--line-soft);
}

.search-suggestion-body {
    display: grid;
    gap: 3px;
}

.search-suggestion-label {
    font-weight: 700;
    line-height: 1.2;
}

.search-suggestion-meta {
    color: var(--muted);
    font-size: 0.86rem;
}

/* ==========================================================================
   Cookie banner
   ========================================================================== */

.cookie-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    box-shadow: var(--shadow-md);
}

.cookie-banner p {
    margin: 0;
    max-width: 56ch;
    font-size: 0.9rem;
}

.cookie-banner a {
    color: var(--accent-dark);
    text-decoration: underline;
}

.cookie-banner-actions {
    display: flex;
    gap: 10px;
}

.cookie-banner-actions form {
    margin: 0;
}

/* ==========================================================================
   Maintenance page
   ========================================================================== */

.maintenance-panel {
    display: grid;
    gap: 12px;
    place-items: center;
    text-align: center;
    padding: 80px 20px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
    .shell {
        padding: 16px;
    }

    .site-header {
        margin: -16px -16px 20px;
        padding: 12px 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 22px;
    }
}

/* ==========================================================================
   Bulk list editor
   --------------------------------------------------------------------------
   Add/remove rows of parallel inputs (e.g. category slug + name), backed by
   a <template> and the generic delegated handler in app.js
   (data-add-row / data-remove-row / data-template).
   ========================================================================== */

.parameter-editor-list {
    display: grid;
    gap: 12px;
}

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

/* A variable number of per-locale name fields, so it can't use a fixed
   column count like the plain .parameter-row above. */
.category-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.category-row > input[name="category_slug[]"] {
    flex: 1 1 160px;
}

.category-name-field {
    flex: 1 1 160px;
    display: grid;
    gap: 6px;
}

.category-name-field span {
    font-size: 0.86rem;
    font-weight: 600;
}

/* ==========================================================================
   Business directory: category grid, business cards, pagination
   ========================================================================== */

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.category-tile {
    display: grid;
    gap: 4px;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.category-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.category-tile strong {
    font-size: 1rem;
}

.business-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.business-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.business-card-logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--line-soft);
}

.business-card-body {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.business-card-body h3 {
    margin: 0;
}

.business-profile {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: start;
}

.business-profile-logo {
    width: 96px;
    height: 96px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--line-soft);
}

.business-contact-list {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.pagination-info {
    color: var(--muted);
    font-size: 0.88rem;
}

@media (max-width: 640px) {
    .business-profile {
        grid-template-columns: 1fr;
    }

    .parameter-row {
        grid-template-columns: 1fr;
    }
}
