/* ───────────────────────────────────────────────────────────────
   Yard Toolkit — application shell stylesheet (spec §5).
   Custom CSS only, no framework. Tokens at :root drive everything;
   per-tenant brand overrides redefine a few --color-* on <html>.
   ─────────────────────────────────────────────────────────────── */

/* ─── Tokens ─────────────────────────────────────────────────── */
:root {
    /* Palette (spec §5.1) */
    --color-primary:        #2b824f;
    --color-primary-dark:   #256e43;
    --color-primary-darker: #1a2e1a;
    --color-gradient-a:     #2d7a4f;
    --color-gradient-b:     #3da066;

    --color-bg:             #ffffff;
    --color-bg-soft:        #f2f6f4;
    --color-bg-muted:       #efefef;
    --color-text:           #303030;
    --color-text-muted:     #727272;
    --color-text-mutest:    #a0a0a0;
    --color-border:         #e0e0e0;
    --color-border-soft:    #efefef;

    --color-danger:         #ee4343;
    --color-danger-soft:    #fdecec;
    --color-danger-border:  #f5c2c0;
    --color-warning:        #c77700;
    --color-warning-soft:   #fff5e6;
    --color-warning-border: #f0d9a8;
    --color-success:        #1f6b3f;
    --color-success-soft:   #eaf5ee;
    --color-success-border: #bfe3cd;

    /* Type */
    --font-sans:    'Outfit', system-ui, -apple-system, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-mono:    ui-monospace, 'Cascadia Code', 'JetBrains Mono', monospace;

    /* Shape — aligned with claude/demo/styles.css (12px primary, 8px tight) */
    --radius:      0.75rem;  /* 12px — cards, dropdowns, primary surfaces */
    --radius-sm:   0.5rem;   /* 8px — buttons, inputs, badges */
    --radius-pill: 999px;

    /* Shadow — two-layer soft, matches the demo's depth */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);

    /* Layout */
    --sidebar-w:   16.25rem; /* 260px — matches demo */
    --topbar-h:    4.5rem;   /* 72px  — matches demo (taller breathing room) */
    --content-pad: 1.5rem;
}

/* Admin shell — same palette today, distinct hooks for later. */
.theme-admin {
    --color-sidebar-bg:   #1a2e1a;
    --color-sidebar-text: #d9e6dc;
    --color-sidebar-text-active: #ffffff;
    --color-sidebar-active: rgba(255, 255, 255, 0.10);
    --color-sidebar-hover:  rgba(255, 255, 255, 0.06);
}
.theme-app {
    --color-sidebar-bg:   #1a2e1a;
    --color-sidebar-text: #cdd9d0;
    --color-sidebar-text-active: #ffffff;
    --color-sidebar-active: rgba(255, 255, 255, 0.10);
    --color-sidebar-hover:  rgba(255, 255, 255, 0.06);
}

/* ─── Reset / base ───────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--color-bg-soft);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; color: var(--color-primary-darker); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.0rem; }

.h-display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.005em; }

.muted { color: var(--color-text-muted); }
.tiny  { font-size: 0.78rem; }
.small { font-size: 0.85rem; }

/* ─── App layout: sidebar + topbar + content ─────────────────── */
.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar content";
}
.app__sidebar { grid-area: sidebar; }
.app__topbar  { grid-area: topbar; }
.app__content { grid-area: content; }

/* Mobile — sidebar becomes off-canvas drawer; layout collapses to single column */
@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }
    .app__sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-w);
        max-width: 80vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 50;
    }
    .app.is-sidebar-open .app__sidebar { transform: translateX(0); }
    .app__scrim {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 49;
    }
    .app.is-sidebar-open .app__scrim {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: sticky;
    top: 0;
}
.sidebar__brand {
    padding: 1.1rem 1.1rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar__mark {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--color-gradient-a), var(--color-gradient-b), var(--color-gradient-a));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}
.sidebar__name {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    line-height: 1.1;
}
.sidebar__sub {
    color: var(--color-sidebar-text);
    font-size: 0.72rem;
    opacity: 0.7;
    margin-top: 0.15rem;
}
.sidebar__nav { padding: 0.7rem 0.5rem; flex: 1; }
.sidebar__section {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.9rem 0.7rem 0.4rem;
}
.sidebar__item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    color: var(--color-sidebar-text);
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
    cursor: pointer;
}
.sidebar__item:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-text-active);
    text-decoration: none;
}
.sidebar__item.is-active {
    background: var(--color-sidebar-active);
    color: var(--color-sidebar-text-active);
    font-weight: 500;
}
.sidebar__item .icon { flex: none; opacity: 0.85; }
.sidebar__item .label { flex: 1; }
.sidebar__item .tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.05rem 0.4rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sidebar__foot {
    padding: 0.7rem 0.9rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0 1.1rem;
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar__burger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
}
.topbar__burger:hover { background: var(--color-bg-muted); }
@media (max-width: 900px) {
    .topbar__burger { display: inline-flex; }
}
.topbar__title {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--color-primary-darker);
}
.topbar__sub {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-left: 0.5rem;
}
.topbar__spacer { flex: 1; }

/* User menu */
.user-menu { position: relative; }
.user-menu__trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: none;
    border: 1px solid transparent;
    padding: 0.35rem 0.55rem 0.35rem 0.4rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    color: var(--color-text);
    font-size: 0.85rem;
}
.user-menu__trigger:hover { background: var(--color-bg-soft); border-color: var(--color-border-soft); }
.user-menu__avatar {
    width: 1.7rem; height: 1.7rem;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, var(--color-gradient-a), var(--color-gradient-b));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}
.user-menu__name { font-weight: 500; }
@media (max-width: 640px) {
    .user-menu__name { display: none; }
}
.user-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 14rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    display: none;
}
.user-menu.is-open .user-menu__panel { display: block; }
.user-menu__head {
    padding: 0.55rem 0.7rem 0.7rem;
    border-bottom: 1px solid var(--color-border-soft);
    margin-bottom: 0.4rem;
}
.user-menu__head .name { font-weight: 500; font-size: 0.9rem; }
.user-menu__head .email { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.1rem; }
.user-menu__item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--color-text);
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    width: 100%;
}
.user-menu__item:hover { background: var(--color-bg-soft); text-decoration: none; }
.user-menu__item.danger { color: var(--color-danger); }
.user-menu__divider { height: 1px; background: var(--color-border-soft); margin: 0.4rem 0; }

/* ─── Content / page ─────────────────────────────────────────── */
.content {
    padding: var(--content-pad);
    max-width: 1400px;
}
.page-head {
    margin-bottom: 1.5rem;
}
.page-head h1 { font-size: 1.4rem; }
.page-head .lede { color: var(--color-text-muted); margin-top: 0.25rem; }

/* ─── Components ─────────────────────────────────────────────── */

/* Card */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.4rem;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.card__head { margin-bottom: 0.9rem; }
.card__head h2 { font-size: 1.05rem; }
.card__head .sub { color: var(--color-text-muted); font-size: 0.82rem; margin-top: 0.15rem; }

/* Grid (dashboard cards) */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}
.btn:hover { background: var(--color-bg-soft); text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-outline { border-color: var(--color-border); }
.btn-outline:hover { background: var(--color-bg-soft); }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #d83a3a; }
.btn-ghost { background: none; }
.btn-ghost:hover { background: var(--color-bg-soft); }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Field (re-used from auth, generalised) */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.35rem; }
.field input, .field select, .field textarea {
    display: block;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    font-size: 0.92rem;
    color: var(--color-text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(43, 130, 79, 0.12);
}

/* Badges */
.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--color-success-soft);
    color: var(--color-success);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge.warn { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.muted { background: var(--color-bg-muted); color: var(--color-text-muted); }
.badge.danger { background: var(--color-danger-soft); color: var(--color-danger); }

/* Flash strip */
.flash-strip {
    padding: 0.7rem var(--content-pad) 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.flash {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    border: 1px solid;
}
.flash-error   { background: var(--color-danger-soft);  color: #b3261e; border-color: var(--color-danger-border); }
.flash-success { background: var(--color-success-soft); color: var(--color-success); border-color: var(--color-success-border); }
.flash-warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: var(--color-warning-border); }

/* Table */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
}
.table th, .table td {
    text-align: left;
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--color-border-soft);
}
.table th { color: var(--color-text-muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table tbody tr:hover { background: var(--color-bg-soft); }

/* Empty state */
.empty {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    background: var(--color-bg);
}
.empty strong { display: block; color: var(--color-text); font-size: 1rem; margin-bottom: 0.3rem; font-weight: 600; }

/* Firewood order form — the wood type that isn't being ordered (firewood-order.js) */
[data-category-group].is-locked { opacity: 0.5; }
