/* ─────────────────────────────────────────────────────────────────────────
   Off-Grid Marketplace Theme — main.css
   Light + dark theme via CSS variables on html[data-theme].
   BEM naming, wireframe-light, mobile-first. Vanilla — no framework.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Theme tokens ─────────────────────────────────────────────────────── */
:root {
    --ogm-accent: #2f8a3a;      /* overridden inline from settings */
    --ogm-accent-hover: #266c2e;
    --ogm-bg: #ffffff;
    --ogm-bg-elev: #f7f8f6;
    --ogm-bg-soft: #f0f2ed;
    --ogm-text: #1d2117;
    --ogm-text-muted: #5e6557;
    --ogm-border: #d6dad0;
    --ogm-border-strong: #b4baa7;
    --ogm-danger: #b13a3a;
    --ogm-warning: #b58117;
    --ogm-radius: 4px;
    --ogm-radius-lg: 8px;
    --ogm-shadow: 0 1px 2px rgba(0,0,0,.05);
    --ogm-shadow-lg: 0 6px 24px rgba(0,0,0,.08);
    --ogm-maxw: 1240px;
    --ogm-gap: 16px;
    --ogm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
    --ogm-accent: #5ed66a;      /* overridden inline from settings */
    --ogm-accent-hover: #7be785;
    --ogm-bg: #161a14;
    --ogm-bg-elev: #1f241c;
    --ogm-bg-soft: #252b21;
    --ogm-text: #eaeee1;
    --ogm-text-muted: #97a08a;
    --ogm-border: #2c3327;
    --ogm-border-strong: #3a4234;
    --ogm-danger: #e8746e;
    --ogm-warning: #d8b35a;
    --ogm-shadow: 0 1px 2px rgba(0,0,0,.4);
    --ogm-shadow-lg: 0 6px 24px rgba(0,0,0,.5);
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.ogm-body {
    font-family: var(--ogm-font);
    background: var(--ogm-bg);
    color: var(--ogm-text);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--ogm-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.ogm-main { max-width: var(--ogm-maxw); margin: 0 auto; padding: 24px 16px 64px; min-height: 60vh; }
.ogm-container { max-width: var(--ogm-maxw); margin: 0 auto; padding: 0 16px; }

/* ── Header / global nav ──────────────────────────────────────────────── */
.ogm-header {
    background: var(--ogm-bg-elev);
    border-bottom: 1px solid var(--ogm-border);
    position: sticky; top: 0; z-index: 100;
}
.ogm-header__inner {
    max-width: var(--ogm-maxw);
    margin: 0 auto;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: auto 1fr 1fr auto;
    gap: 16px;
    align-items: center;
}
.ogm-header__brand {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--ogm-text);
    white-space: nowrap;
}
.ogm-header__brand:hover { text-decoration: none; }
.ogm-header__nav { display: flex; gap: 4px; flex-wrap: wrap; }
.ogm-header__nav a {
    color: var(--ogm-text);
    padding: 6px 10px;
    border-radius: var(--ogm-radius);
    font-weight: 500;
}
.ogm-header__nav a:hover { background: var(--ogm-bg-soft); text-decoration: none; color: var(--ogm-accent); }
.ogm-header__search {
    display: flex;
    background: var(--ogm-bg);
    border: 1px solid var(--ogm-border);
    border-radius: var(--ogm-radius);
    overflow: hidden;
}
.ogm-header__search input { flex: 1; border: 0; padding: 8px 10px; background: transparent; color: var(--ogm-text); outline: none; }
.ogm-header__search button { border: 0; background: var(--ogm-accent); color: #fff; padding: 0 12px; cursor: pointer; }
.ogm-header__actions { display: flex; gap: 6px; align-items: center; }

@media (max-width: 900px) {
    .ogm-header__inner { grid-template-columns: auto auto; grid-template-areas: "brand actions" "nav nav" "search search"; }
    .ogm-header__brand   { grid-area: brand; }
    .ogm-header__actions { grid-area: actions; justify-self: end; }
    .ogm-header__nav     { grid-area: nav; }
    .ogm-header__search  { grid-area: search; }
}

/* ── Theme toggle button ──────────────────────────────────────────────── */
.ogm-theme-toggle {
    background: var(--ogm-bg);
    border: 1px solid var(--ogm-border);
    border-radius: var(--ogm-radius);
    width: 32px; height: 32px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ogm-text);
}
.ogm-theme-toggle__light, .ogm-theme-toggle__dark { display: none; }
html[data-theme="light"] .ogm-theme-toggle__dark { display: inline; }
html[data-theme="dark"]  .ogm-theme-toggle__light { display: inline; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.ogm-btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--ogm-radius);
    border: 1px solid transparent;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    font-size: .95rem;
    white-space: nowrap;
    line-height: 1.2;
}
.ogm-btn:hover { text-decoration: none; }
.ogm-btn--primary { background: var(--ogm-accent); color: #fff; }
.ogm-btn--primary:hover { background: var(--ogm-accent-hover); color: #fff; }
.ogm-btn--ghost { background: transparent; color: var(--ogm-text); border-color: var(--ogm-border); }
.ogm-btn--ghost:hover { background: var(--ogm-bg-soft); color: var(--ogm-text); }
.ogm-btn--danger { background: transparent; color: var(--ogm-danger); border-color: var(--ogm-danger); }
.ogm-btn--block { display: block; width: 100%; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.ogm-field { margin-bottom: 14px; }
.ogm-field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
.ogm-field input[type=text], .ogm-field input[type=email], .ogm-field input[type=password], .ogm-field input[type=number], .ogm-field input[type=tel], .ogm-field input[type=search], .ogm-field textarea, .ogm-field select {
    width: 100%; padding: 9px 10px; font-size: 1rem;
    background: var(--ogm-bg); color: var(--ogm-text);
    border: 1px solid var(--ogm-border); border-radius: var(--ogm-radius);
}
.ogm-field textarea { min-height: 140px; resize: vertical; }
.ogm-field .help { color: var(--ogm-text-muted); font-size: .85rem; margin-top: 4px; }
.ogm-form-error { background: rgba(177,58,58,.12); color: var(--ogm-danger); padding: 8px 12px; border-radius: var(--ogm-radius); margin-bottom: 12px; }
.ogm-form-ok    { background: rgba(47,138,58,.12); color: var(--ogm-accent); padding: 8px 12px; border-radius: var(--ogm-radius); margin-bottom: 12px; }

/* ── Section heroes ───────────────────────────────────────────────────── */
.ogm-hero { padding: 36px 0 16px; }
.ogm-hero h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.ogm-hero p  { color: var(--ogm-text-muted); max-width: 60ch; }

/* ── Listings: grid + list view ───────────────────────────────────────── */
.ogm-toolbar {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--ogm-border);
    margin-bottom: 16px;
}
.ogm-toolbar__spacer { flex: 1; }
.ogm-view-toggle button {
    background: var(--ogm-bg); border: 1px solid var(--ogm-border); padding: 6px 10px; cursor: pointer; color: var(--ogm-text);
}
.ogm-view-toggle button.is-active { background: var(--ogm-accent); color: #fff; border-color: var(--ogm-accent); }

.ogm-listings--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.ogm-listings--list { display: flex; flex-direction: column; gap: 12px; }
.ogm-listing-card {
    background: var(--ogm-bg-elev);
    border: 1px solid var(--ogm-border);
    border-radius: var(--ogm-radius-lg);
    overflow: hidden;
    box-shadow: var(--ogm-shadow);
    transition: transform .08s ease, box-shadow .15s ease;
}
.ogm-listing-card:hover { transform: translateY(-1px); box-shadow: var(--ogm-shadow-lg); }
.ogm-listing-card__img { aspect-ratio: 4/3; background: var(--ogm-bg-soft) center/cover; }
.ogm-listing-card__body { padding: 12px 14px; }
.ogm-listing-card__title { font-weight: 700; margin: 0 0 4px; color: var(--ogm-text); }
.ogm-listing-card__meta { font-size: .85rem; color: var(--ogm-text-muted); }
.ogm-listing-card__price { font-weight: 700; color: var(--ogm-accent); font-size: 1.1rem; margin-top: 6px; }
.ogm-listing-card--featured { outline: 2px solid var(--ogm-accent); }
.ogm-listing-card--highlight { box-shadow: 0 0 0 3px rgba(245, 197, 24, .35); }

.ogm-listings--list .ogm-listing-card { display: grid; grid-template-columns: 220px 1fr; }
.ogm-listings--list .ogm-listing-card__img { aspect-ratio: auto; height: 100%; }
@media (max-width: 600px) {
    .ogm-listings--list .ogm-listing-card { grid-template-columns: 1fr; }
    .ogm-listings--list .ogm-listing-card__img { aspect-ratio: 16/9; }
}

/* ── Featured carousel (every section gets one at the top of browse) ──── */
.ogm-featured {
    position: relative;
    margin: 16px 0 28px;
    background: var(--ogm-bg-soft);
    border-radius: var(--ogm-radius-lg);
    padding: 18px;
}
.ogm-featured__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ogm-featured__title { font-weight: 700; }
.ogm-featured__nav { display: flex; gap: 6px; }
.ogm-featured__nav button { background: var(--ogm-bg); border: 1px solid var(--ogm-border); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; color: var(--ogm-text); font-size: 1rem; }
.ogm-featured__viewport { overflow: hidden; }
.ogm-featured__track { display: flex; gap: 14px; transition: transform .4s ease; }
.ogm-featured__slide { flex: 0 0 calc(25% - 14px); min-width: 220px; }
@media (max-width: 900px) { .ogm-featured__slide { flex-basis: calc(50% - 14px); } }
@media (max-width: 600px) { .ogm-featured__slide { flex-basis: calc(100% - 0px); } }
.ogm-featured__dots { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.ogm-featured__dots button { width: 8px; height: 8px; border-radius: 50%; border: 0; padding: 0; background: var(--ogm-border-strong); cursor: pointer; }
.ogm-featured__dots button.is-active { background: var(--ogm-accent); }

/* ── Sidebar (filters) ────────────────────────────────────────────────── */
.ogm-layout--with-sidebar { display: grid; grid-template-columns: 280px 1fr; gap: 24px; }
@media (max-width: 900px) { .ogm-layout--with-sidebar { grid-template-columns: 1fr; } }
.ogm-sidebar {
    background: var(--ogm-bg-elev);
    border: 1px solid var(--ogm-border);
    border-radius: var(--ogm-radius-lg);
    padding: 16px;
    align-self: start;
    position: sticky; top: 80px;
}
.ogm-sidebar h3 { font-size: 1rem; margin-top: 16px; }
.ogm-sidebar h3:first-child { margin-top: 0; }

/* ── Map container ────────────────────────────────────────────────────── */
.ogm-map { width: 100%; height: 520px; border-radius: var(--ogm-radius-lg); border: 1px solid var(--ogm-border); margin-bottom: 16px; }
@media (max-width: 600px) { .ogm-map { height: 360px; } }

/* ── Dashboard ────────────────────────────────────────────────────────── */
.ogm-dashboard { display: grid; grid-template-columns: 240px 1fr; gap: 24px; }
@media (max-width: 800px) { .ogm-dashboard { grid-template-columns: 1fr; } }
.ogm-dashboard__tabs { display: flex; flex-direction: column; gap: 2px; background: var(--ogm-bg-elev); border: 1px solid var(--ogm-border); border-radius: var(--ogm-radius-lg); padding: 8px; }
.ogm-dashboard__tabs a { padding: 8px 12px; border-radius: var(--ogm-radius); color: var(--ogm-text); }
.ogm-dashboard__tabs a:hover { background: var(--ogm-bg-soft); text-decoration: none; }
.ogm-dashboard__tabs a.is-active { background: var(--ogm-accent); color: #fff; }
.ogm-dashboard__panel { background: var(--ogm-bg-elev); border: 1px solid var(--ogm-border); border-radius: var(--ogm-radius-lg); padding: 20px; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.ogm-footer { background: var(--ogm-bg-elev); border-top: 1px solid var(--ogm-border); padding: 36px 16px; margin-top: 64px; }
.ogm-footer__inner { max-width: var(--ogm-maxw); margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 32px; }
.ogm-footer__col h4 { margin-top: 0; margin-bottom: 8px; }
.ogm-footer__col ul { list-style: none; padding: 0; margin: 0; line-height: 2; }
.ogm-footer__col a { color: var(--ogm-text); }
.ogm-footer__col a:hover { color: var(--ogm-accent); }
.ogm-footer__copy { max-width: var(--ogm-maxw); margin: 24px auto 0; color: var(--ogm-text-muted); font-size: .85rem; }

/* ── Pills / chips / badges ──────────────────────────────────────────── */
.ogm-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.ogm-pill--accent { background: var(--ogm-accent); color: #fff; }
.ogm-pill--muted  { background: var(--ogm-bg-soft); color: var(--ogm-text-muted); }

/* ── Utilities ────────────────────────────────────────────────────────── */
.ogm-muted { color: var(--ogm-text-muted); }
.ogm-center { text-align: center; }
.ogm-stack > * + * { margin-top: var(--ogm-gap); }
.ogm-flex { display: flex; gap: var(--ogm-gap); align-items: center; }
.ogm-flex--wrap { flex-wrap: wrap; }
