/* ============================================================
   PARTNER PORTAL — DARK THEME
   Shared styles for login, onboarding, dashboard, topbar.
   Mirrors the brand palette from /internal (coral #ff575f on near-
   black #0a0a0a) and uses the Haffer/RZA font stack.
   ============================================================ */

@font-face {
    font-family: 'Haffer';
    src: url('/fonts/Haffer-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Haffer';
    src: url('/fonts/Haffer-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'RZA';
    src: url('/fonts/RzaRegular-Desktop.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg:            #0a0a0a;
    --bg-elev:       #141414;
    --bg-elev-2:     #1a1a1a;
    --border:        rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --text:          #fafafa;
    --text-muted:    #a0a0a0;
    --text-dim:      #6e6e6e;
    --coral:         #ff575f;
    --coral-hover:   #ff3d47;
    --coral-soft:    rgba(255,87,95,0.12);
    --green:         #34d399;
    --amber:         #fbbf24;
    --red:           #f87171;
    --blue:          #60a5fa;
    --radius:        14px;
    --radius-sm:     8px;
    --ease:          cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Haffer', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-feature-settings: 'ss01', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Ambient background glow — subtle, motionless */
body.portal-bg::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 15% 10%, rgba(255,87,95,0.08), transparent 45%),
        radial-gradient(circle at 85% 90%, rgba(96,165,250,0.05), transparent 50%);
    z-index: 0;
}
body.portal-bg > * { position: relative; z-index: 1; }

/* ============================================================
   TOP BAR
   ============================================================ */

.portal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(10,10,10,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}
.portal-topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'RZA', 'Haffer', sans-serif;
    font-size: 18px;
    letter-spacing: 0.02em;
    color: var(--text);
}
.portal-topbar-brand img {
    height: 22px;
    width: auto;
    display: block;
}
.portal-topbar-brand .divider {
    color: var(--text-dim);
    font-family: 'Haffer', sans-serif;
    font-weight: 400;
}
.portal-topbar-brand .sub {
    color: var(--text-muted);
    font-family: 'Haffer', sans-serif;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: uppercase;
}

.portal-topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.portal-topbar-store {
    font-size: 13px;
    color: var(--text-muted);
    margin-right: 12px;
    padding: 6px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms var(--ease);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover {
    border-color: var(--border-strong);
    background: var(--bg-elev-2);
    transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--coral);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px -6px rgba(255,87,95,0.4);
}
.btn-primary:hover {
    background: var(--coral-hover);
    box-shadow: 0 6px 20px -6px rgba(255,87,95,0.5);
}
.btn-primary:disabled,
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover {
    background: var(--bg-elev);
    border-color: var(--border);
    color: var(--text);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 14px 18px;
    font-size: 14px;
}

/* ============================================================
   CARD / PANEL
   ============================================================ */

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.03) inset,
        0 20px 60px -20px rgba(0,0,0,0.6);
}
.card h1 {
    font-family: 'RZA', 'Haffer', sans-serif;
    font-size: 26px;
    letter-spacing: 0.01em;
    margin-bottom: 8px;
    font-weight: 400;
}
.card .lede {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 28px;
}

/* ============================================================
   CENTERED AUTH LAYOUT (login, onboarding)
   ============================================================ */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    animation: rise 520ms var(--ease) both;
}
.auth-card.wide { max-width: 520px; }

@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 28px;
    opacity: 0;
    animation: fade 600ms var(--ease) 120ms forwards;
}
.auth-brand img { height: 22px; width: auto; }
.auth-brand .sub {
    font-size: 12px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */

.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}
.input {
    width: 100%;
    padding: 13px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 180ms var(--ease), background 180ms var(--ease);
}
.input:hover { border-color: var(--border-strong); }
.input:focus {
    outline: none;
    border-color: var(--coral);
    background: var(--bg-elev-2);
    box-shadow: 0 0 0 3px var(--coral-soft);
}
.input::placeholder { color: var(--text-dim); }

.error-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(248,113,113,0.08);
    border: 1px solid rgba(248,113,113,0.25);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 13px;
    display: none;
    animation: rise 260ms var(--ease) both;
}
.error-box.active { display: block; }

/* ============================================================
   SEARCHABLE STORE LIST (onboarding)
   ============================================================ */

.store-list {
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}
.store-list::-webkit-scrollbar { width: 8px; }
.store-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.store-list::-webkit-scrollbar-track { background: transparent; }

.store-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 160ms var(--ease), padding 160ms var(--ease);
}
.store-option:last-child { border-bottom: none; }
.store-option:hover { background: var(--bg-elev-2); padding-left: 20px; }
.store-option.selected {
    background: var(--coral-soft);
    color: var(--text);
    padding-left: 20px;
}
.store-option.selected::after {
    content: '✓';
    color: var(--coral);
    font-weight: 700;
}
.store-option.new {
    background: rgba(96,165,250,0.06);
    color: var(--blue);
    font-weight: 600;
}
.store-option.new:hover { background: rgba(96,165,250,0.12); }

.empty {
    padding: 24px 16px;
    color: var(--text-dim);
    font-size: 13px;
    text-align: center;
}

.manual-entry {
    margin-top: 12px;
    padding: 14px;
    background: rgba(96,165,250,0.05);
    border: 1px solid rgba(96,165,250,0.18);
    border-radius: var(--radius-sm);
    display: none;
    animation: rise 260ms var(--ease) both;
}
.manual-entry.active { display: block; }
.manual-entry p {
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard-wrap {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 32px;
    animation: fade 360ms var(--ease) both;
}
.dashboard-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}
.dashboard-header h1 {
    font-family: 'RZA', 'Haffer', sans-serif;
    font-size: 32px;
    font-weight: 400;
    letter-spacing: 0.01em;
}
.dashboard-header .count {
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.quotes-panel {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 60px -30px rgba(0,0,0,0.5);
}

table.quotes {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.quotes thead th {
    text-align: left;
    padding: 16px 20px;
    background: var(--bg-elev-2);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border);
}
table.quotes tbody td {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
table.quotes tbody tr {
    transition: background 160ms var(--ease);
}
table.quotes tbody tr:hover { background: rgba(255,255,255,0.02); }
table.quotes tbody tr:last-child td { border-bottom: none; }
table.quotes tbody td strong {
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}
table.quotes .muted { color: var(--text-muted); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.badge-pending    { color: var(--amber);  border-color: rgba(251,191,36,0.28);  background: rgba(251,191,36,0.08); }
.badge-approved,
.badge-offer-sent,
.badge-accepted   { color: var(--green);  border-color: rgba(52,211,153,0.28);  background: rgba(52,211,153,0.08); }
.badge-purchased,
.badge-completed,
.badge-collected  { color: var(--blue);   border-color: rgba(96,165,250,0.28);  background: rgba(96,165,250,0.08); }
.badge-rejected,
.badge-declined,
.badge-cancelled  { color: var(--red);    border-color: rgba(248,113,113,0.28); background: rgba(248,113,113,0.08); }

.empty-state {
    padding: 80px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state .big {
    font-family: 'RZA', 'Haffer', sans-serif;
    font-size: 24px;
    color: var(--text);
    margin-bottom: 10px;
    font-weight: 400;
}
.empty-state .hint { font-size: 14px; margin-bottom: 22px; }

/* ============================================================
   LOADING (subtle spinner dot)
   ============================================================ */

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--coral);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
    .portal-topbar { padding: 14px 18px; }
    .portal-topbar-store { display: none; }
    .dashboard-wrap { padding: 0 18px; margin: 24px auto; }
    .dashboard-header h1 { font-size: 26px; }
    .card { padding: 24px; }
    table.quotes thead { display: none; }
    table.quotes tbody tr {
        display: block;
        padding: 14px 18px;
        border-bottom: 1px solid var(--border);
    }
    table.quotes tbody tr:last-child { border-bottom: none; }
    table.quotes tbody td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 4px 0;
        border: none;
        font-size: 13px;
    }
    table.quotes tbody td::before {
        content: attr(data-label);
        color: var(--text-dim);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }
}
