/* ==========================================================================
   Linea - admin styles
   Calm, dense and readable. Shares the storefront's palette.
   ========================================================================== */

:root {
    --bg: #f3f0ea;
    --panel: #ffffff;
    --ink: #1d1b18;
    --muted: #6c665d;
    --line: #e5e0d6;
    --soft: #efeae0;
    --gold: #c29d5a;
    --accent: #8a6a2a;
    --accent-dark: #6f5320;
    --bad: #9a3b2c;
    --warn: #a0691f;
    --ok: #3f6b4f;
    --side: #1d1b18;
    --side-w: 252px;

    --serif: "Cormorant Garamond", Georgia, serif;
    --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 3px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 14px/1.55 var(--sans);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; font-weight: 500; }
p { margin: 0 0 1em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Shell ---------- */
.admin { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }

.side {
    background: var(--side);
    color: #d8d1c4;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem 1rem;
}
.side-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.1;
    text-decoration: none;
    color: #fff;
    padding: 0.25rem 0.75rem 1.5rem;
}
.side-brand img { width: 40px; height: 40px; flex: none; }
.side-brand small {
    display: block;
    font-family: var(--sans);
    font-size: 10.5px;
    letter-spacing: 0.22em;
    color: #a39a8b;
    margin-top: 0.15rem;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
    text-decoration: none;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius);
    color: #cfc7b9;
    transition: background 0.2s, color 0.2s;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-nav a.active { background: rgba(255, 255, 255, 0.11); color: #fff; font-weight: 500; }

.side-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 1rem; display: grid; gap: 0.4rem; }
.side-foot a, .side-signout {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    font: inherit;
    color: #bdb5a6;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    cursor: pointer;
    border-radius: var(--radius);
}
.side-foot a:hover, .side-signout:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.side-signout span { display: block; font-size: 12px; color: #8d8577; }

.main { min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem clamp(1rem, 3vw, 2.25rem);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-family: var(--serif); font-size: 1.9rem; flex: 1; line-height: 1.1; }
.topbar-actions { display: flex; gap: 0.5rem; }
.side-toggle { display: none; }

.content { padding: clamp(1rem, 3vw, 2.25rem); max-width: 1300px; }

/* ---------- Components ---------- */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.4rem;
}
.panel h2 { font-family: var(--serif); font-size: 1.45rem; margin-bottom: 1rem; }
.panel.flush { padding: 0; overflow: hidden; }
.pad { padding: 1.2rem 1.4rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; }
.panel-head a { font-size: 13px; color: var(--accent); }
.panel.flush .panel-head { margin: 0; border-bottom: 1px solid var(--line); }

.stack { display: grid; gap: 1.25rem; align-content: start; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.narrow-form { max-width: 620px; display: grid; gap: 1.25rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; display: grid; gap: 0.15rem; }
.stat-label { font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--serif); font-size: 2.2rem; line-height: 1.1; }
.stat-note { font-size: 12.5px; color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid #cfc8bb;
    border-radius: var(--radius);
    font: 500 13px/1.2 var(--sans);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { padding: 0.42rem 0.8rem; font-size: 12.5px; }
.btn-block { width: 100%; }

.alert { padding: 0.8rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; border: 1px solid; }
.alert-ok { background: #eef5ef; border-color: #c9ddcd; color: #2f553c; }
.alert-error { background: #fbeeeb; border-color: #efccc5; color: #7d2d21; }
.alert-error ul { margin: 0; padding-left: 1.1rem; }
.validation-summary-valid { display: none; }

.hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 0.35rem; }
.hint a { color: var(--accent); }
.intro { margin: 0 0 1.25rem; max-width: 70ch; font-size: 13.5px; }
.empty-note { color: var(--muted); margin: 0; }
.empty-note.pad { padding: 1.5rem 1.4rem; }
.empty-note a { color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.8rem 1rem;
    background: #faf8f4;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfbf8; }
.table .right, .right { text-align: right; }
.nowrap { white-space: nowrap; }
.w-thumb { width: 64px; }
.strong { font-weight: 600; text-decoration: none; }
a.strong:hover { color: var(--accent); }
.sub { font-size: 12.5px; color: var(--muted); }
.thumb { width: 44px; height: 54px; object-fit: cover; border-radius: 2px; background: var(--soft); }
.thumb-empty { display: grid; place-items: center; font-family: var(--serif); font-size: 1.4rem; color: #a79f90; }
.text-bad { color: var(--bad); font-weight: 600; }
.text-warn { color: var(--warn); font-weight: 600; }
form.inline { display: inline; }

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list a { text-decoration: none; font-weight: 500; }
.plain-list a:hover { color: var(--accent); }

/* Pills */
.pill {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--soft);
    color: var(--muted);
    white-space: nowrap;
}
.pill-pending { background: #f7ecd6; color: #8a5c12; }
.pill-confirmed { background: #e3ecf5; color: #2c557f; }
.pill-shipped { background: #ece4f4; color: #5a3d80; }
.pill-delivered { background: #e2efe5; color: #2f6140; }
.pill-cancelled { background: #f5e0dc; color: #8a3326; }

/* Filters, tabs, pager */
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.filters input[type="search"] { flex: 1 1 260px; }
.filters select { flex: 0 1 220px; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.tabs a {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    background: var(--panel);
    font-size: 13px;
}
.tabs a:hover { border-color: var(--ink); }
.tabs a.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; color: var(--muted); }
.pager a { text-decoration: none; color: var(--accent); font-weight: 500; }

/* Forms */
input, select, textarea {
    font: inherit;
    color: inherit;
    background: #fff;
    border: 1px solid #d3ccbf;
    border-radius: var(--radius);
    padding: 0.62rem 0.75rem;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(29, 27, 24, 0.07); }
textarea { resize: vertical; }
input[type="file"] { padding: 0.5rem; background: var(--soft); }
.input-validation-error { border-color: var(--bad); }

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-weight: 500; margin-bottom: 0.35rem; }
.field-error { display: block; color: var(--bad); font-size: 12.5px; margin-top: 0.3rem; }

.check { display: flex; align-items: center; gap: 0.55rem; margin: 0 0 0.6rem; cursor: pointer; font-weight: 400; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--ink); flex: none; }
.check.small { font-size: 12.5px; margin: 0.35rem 0 0; }
.check.danger span { color: var(--bad); }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.actions .btn-primary { flex: 1; min-width: 160px; padding: 0.85rem 1.2rem; }

/* Product form extras */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.img-grid:empty { display: none; }
.img-tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.45rem; background: #fcfbf8; }
.img-tile img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 2px; background: var(--soft); }

.spec-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 0.5rem; margin-bottom: 0.5rem; }
.icon-btn {
    width: 38px;
    background: #fff;
    border: 1px solid #d3ccbf;
    border-radius: var(--radius);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}
.icon-btn:hover { color: var(--bad); border-color: var(--bad); }
#specs { margin-bottom: 0.75rem; }

/* Order detail */
.totals { margin: 0; }
.totals > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; }
.totals dt, .totals dd { margin: 0; }
.totals .grand { border-top: 1px solid var(--line); margin-top: 0.4rem; padding-top: 0.7rem; font-weight: 600; font-size: 15px; }
.detail { margin: 0 0 1rem; line-height: 1.6; }
.detail a { color: var(--accent); }
.mini-head {
    font-family: var(--sans);
    font-size: 11.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 1.1rem 0 0.3rem;
}

/* ---------- Login ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.25rem; background: var(--bg); }
.auth-card { width: min(100%, 400px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 2.25rem 2rem; }
.auth-logo { margin: 0 auto 0.5rem; }
.auth-brand { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; color: var(--accent-dark); text-align: center; margin: 0 0 1.5rem; }
.auth-card h1 { font-family: var(--serif); font-size: 2rem; margin-bottom: 0.2rem; }
.auth-card .hint { margin: 0 0 1.5rem; }
.auth-card .btn-block { padding: 0.85rem; margin-top: 0.5rem; }
.auth-back { text-align: center; margin: 1.5rem 0 0; font-size: 13px; }
.auth-back a { color: var(--muted); text-decoration: none; }
.auth-back a:hover { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .form-grid, .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .admin { grid-template-columns: 1fr; }
    .side {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(82vw, 290px);
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
    }
    .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); }
    .side-toggle {
        display: inline-flex;
        padding: 0.5rem 0.8rem;
        background: none;
        border: 1px solid #cfc8bb;
        border-radius: var(--radius);
        font: 500 13px var(--sans);
        cursor: pointer;
    }
    .topbar h1 { font-size: 1.5rem; }
}

@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    .spec-row { grid-template-columns: 1fr auto; }
    .spec-row input:nth-child(2) { grid-column: 1; grid-row: 2; }
    .spec-row .icon-btn { grid-row: 1 / span 2; grid-column: 2; height: auto; }
    .topbar-actions .btn { padding: 0.55rem 0.8rem; }
}
