@import url("/assets/fonts.css");

/* =========================================================================
   Amma Admin — "backstage" theme.
   Brand pastels from the marketing site, recomposed for an operator console:
   a deep plum rail (the control room), a warm-white workspace, and one pastel
   per metric. Signature: dashboard metrics rendered as Amma chat bubbles.
   ========================================================================= */

:root {
    /* Brand */
    --peach: #ECADA0;
    --lavender: #C3B1E1;
    --mint: #A8E6CF;
    --sky: #AEDFF7;
    --ink: #2B2330;

    /* Workspace neutrals (warm, derived from ink + peach) */
    --bg: #F7F3F1;
    --surface: #FFFFFF;
    --surface-2: #FBF8F7;
    --line: #ECE3DF;
    --line-strong: #DED2CC;
    --text: #2B2330;
    --text-soft: #6F6675;
    --text-faint: #9C939F;

    /* Rail (deep plum derived from ink) */
    --rail: #221C29;
    --rail-soft: #322A3A;
    --rail-text: #E9E2EC;
    --rail-faint: #9D93A6;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(43, 35, 48, .04), 0 8px 24px rgba(43, 35, 48, .06);

    --font-display: "Bricolage Grotesque", "Plus Jakarta Sans", system-ui, sans-serif;
    --font-body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
    --font-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ---- App shell --------------------------------------------------------- */

.shell {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 100vh;
}

.rail {
    background: var(--rail);
    color: var(--rail-text);
    padding: 26px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 6px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex: none;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -.01em;
    color: #fff;
}

.brand-name small {
    display: block;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--rail-faint);
    margin-top: 2px;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--rail-faint);
    padding: 0 12px 8px;
}

.nav-label.spaced { margin-top: 10px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--rail-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 14.5px;
    transition: background .15s ease;
}

.nav-item:hover { background: var(--rail-soft); }

.nav-item[aria-current="page"] {
    background: var(--rail-soft);
    color: #fff;
}

.nav-item[aria-current="page"] .nav-dot { opacity: 1; transform: scale(1); }

.nav-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
    opacity: .35;
    transform: scale(.7);
    transition: all .15s ease;
}

.nav-dot.dash { background: var(--peach); }
.nav-dot.user { background: var(--sky); }
.nav-dot.prod { background: var(--lavender); }
.nav-dot.rest { background: var(--mint); }

.rail-foot { margin-top: auto; }

.logout {
    width: 100%;
    background: transparent;
    border: 1px solid var(--rail-soft);
    color: var(--rail-faint);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
}

.logout:hover { color: #fff; border-color: var(--rail-text); }

/* ---- Main -------------------------------------------------------------- */

.main { min-width: 0; }

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 34px 40px 22px;
}

.page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 27px;
    letter-spacing: -.02em;
    margin: 0;
}

.page-sub {
    color: var(--text-soft);
    margin: 4px 0 0;
    font-size: 14px;
}

.now {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
}

.content { padding: 6px 40px 56px; }

/* ---- Signature: metric chat bubbles ------------------------------------ */

.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 30px;
}

.metric {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    padding: 18px 18px 20px;
    box-shadow: var(--shadow);
}

/* the bubble tail — Amma is a chat bot, so each number is a message */
.metric::after {
    content: "";
    position: absolute;
    left: 16px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    transform: rotate(45deg) skew(-6deg, -6deg);
    border-bottom-right-radius: 3px;
}

.metric-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.metric-key {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
}

.metric-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: .01em;
}

.metric-value {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 38px;
    line-height: 1;
    letter-spacing: -.02em;
}

.metric-foot {
    margin-top: 9px;
    font-size: 12.5px;
    color: var(--text-faint);
}

.metric-foot b { color: var(--text-soft); font-weight: 600; }

.metric.peach   { border-top: 3px solid var(--peach); }
.metric.peach   .metric-key { background: var(--peach); }
.metric.lavender{ border-top: 3px solid var(--lavender); }
.metric.lavender .metric-key { background: var(--lavender); }
.metric.mint    { border-top: 3px solid var(--mint); }
.metric.mint    .metric-key { background: var(--mint); }
.metric.sky     { border-top: 3px solid var(--sky); }
.metric.sky     .metric-key { background: var(--sky); }

/* ---- Panels & tables --------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.panel-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    margin: 0;
}

.panel-count {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-faint);
}

.table-wrap { width: 100%; overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.data th {
    text-align: left;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    background: var(--surface-2);
}

table.data td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.product-cell { max-width: 360px; }

.product-title {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-title:hover { text-decoration: underline; }

.product-host {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-faint);
}

.host-chip {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--lavender);
    flex: none;
}

/* counts of watchers */
.watchers {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.watchers .bar {
    width: 38px; height: 5px; border-radius: 3px;
    background: var(--line-strong);
    overflow: hidden;
}

.watchers .bar i {
    display: block; height: 100%;
    width: 0;
    background: var(--peach);
}

/* Bucketed widths — keeps a strict CSP (no inline style attributes). */
.watchers .bar i.w-0   { width: 0; }
.watchers .bar i.w-10  { width: 10%; }
.watchers .bar i.w-20  { width: 20%; }
.watchers .bar i.w-30  { width: 30%; }
.watchers .bar i.w-40  { width: 40%; }
.watchers .bar i.w-50  { width: 50%; }
.watchers .bar i.w-60  { width: 60%; }
.watchers .bar i.w-70  { width: 70%; }
.watchers .bar i.w-80  { width: 80%; }
.watchers .bar i.w-90  { width: 90%; }
.watchers .bar i.w-100 { width: 100%; }

/* badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge::before {
    content: "";
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    opacity: .8;
}

.badge.in_stock   { color: #2f7d57; background: #E7F6EE; border-color: #CBEBDA; }
.badge.out_of_stock { color: #b04b3f; background: #FBE9E5; border-color: #F3D2CB; }
.badge.preorder   { color: #4a63ad; background: #E9EEFB; border-color: #D3DDF4; }
.badge.unknown    { color: var(--text-soft); background: var(--surface-2); border-color: var(--line-strong); }

/* user status */
.badge.active   { color: #2f7d57; background: #E7F6EE; border-color: #CBEBDA; }
.badge.blocked  { color: #b04b3f; background: #FBE9E5; border-color: #F3D2CB; }

/* identity */
.who { display: flex; align-items: center; gap: 11px; }

.avatar {
    width: 32px; height: 32px;
    flex: none;
    border-radius: 10px 10px 10px 3px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--ink);
}

.avatar.c0 { background: var(--peach); }
.avatar.c1 { background: var(--lavender); }
.avatar.c2 { background: var(--mint); }
.avatar.c3 { background: var(--sky); }
.avatar.c4 { background: #F3D9A6; }

.who-name { font-weight: 600; }

.who-id {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 1px;
}

.chan {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-soft);
    text-transform: capitalize;
}

.kind-tags { display: inline-flex; gap: 5px; }

.tag {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    color: var(--text-soft);
    white-space: nowrap;
}

.tag.price   { background: #F4EFFA; border-color: #E4D8F2; color: #6a4f93; }
.tag.restock { background: #EAF8F1; border-color: #D2EEE0; color: #3a7a5b; }

.err { color: #b04b3f; font-family: var(--font-mono); font-size: 12px; }

/* empty states */
.empty {
    padding: 56px 24px;
    text-align: center;
    color: var(--text-soft);
}

.empty-mark {
    width: 44px; height: 44px;
    margin: 0 auto 14px;
    border-radius: 14px 14px 14px 4px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    display: grid; place-items: center;
    font-size: 20px;
}

.empty h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    margin: 0 0 4px;
    color: var(--text);
}

.empty p { margin: 0; font-size: 13.5px; }

/* ---- Login ------------------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(195,177,225,.25), transparent 60%),
        radial-gradient(800px 480px at 100% 110%, rgba(236,173,160,.22), transparent 55%),
        var(--bg);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 384px;
}

.login-bubble {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
    padding: 30px 30px 32px;
    position: relative;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 22px;
}

.login-brand .brand-mark { width: 38px; height: 38px; }

.login-brand .t {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
}

.login-brand .t small {
    display: block;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-top: 1px;
}

.login-bubble h1 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px;
}

.login-bubble .lead {
    color: var(--text-soft);
    font-size: 13.5px;
    margin: 0 0 20px;
}

.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus {
    outline: none;
    border-color: var(--lavender);
    box-shadow: 0 0 0 3px rgba(195,177,225,.3);
    background: var(--surface);
}

.btn {
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: #fff;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: transform .08s ease, background .15s ease;
}

.btn:hover { background: #1a1520; }
.btn:active { transform: translateY(1px); }

.login-error {
    background: #FBE9E5;
    border: 1px solid #F3D2CB;
    color: #b04b3f;
    font-size: 13px;
    font-weight: 500;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.login-foot {
    text-align: center;
    margin-top: 18px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .04em;
    color: var(--text-faint);
}

/* ---- A11y & motion ----------------------------------------------------- */

:focus-visible {
    outline: 2px solid var(--lavender);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 920px) {
    .shell { grid-template-columns: 1fr; }
    .rail {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 18px;
        padding: 14px 18px;
        flex-wrap: wrap;
    }
    .rail .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-label { display: none; }
    .rail-foot { margin-left: auto; margin-top: 0; }
    .logout { width: auto; }
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .topbar, .content { padding-left: 22px; padding-right: 22px; }
}

@media (max-width: 520px) {
    .metrics { grid-template-columns: 1fr; }
}
