/* ============================================================
   Amazon Ads Bot — Refined Dark UI
   ============================================================ */

:root {
    /* Background layers */
    --bg-base: #0a0e1a;
    --bg-elevated: #131826;
    --bg-card: #1a1f2e;
    --bg-hover: #232838;

    /* Text */
    --text-primary: #e8eaf0;
    --text-secondary: #9aa0b3;
    --text-muted: #5d6276;

    /* Borders */
    --border-subtle: #1f2536;
    --border-default: #2a3046;
    --border-strong: #3a4060;

    /* Brand */
    --accent: #ff9500;          /* Amazon orange */
    --accent-glow: #ff9500;
    --accent-soft: rgba(255, 149, 0, 0.12);

    /* Semantic */
    --success: #00d68f;
    --success-soft: rgba(0, 214, 143, 0.1);
    --danger: #ff3d71;
    --danger-soft: rgba(255, 61, 113, 0.1);
    --warning: #ffaa00;

    /* Typography */
    --font-display: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-glow: 0 0 30px var(--accent-soft);
}

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

html, body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, select, textarea {
    font-family: inherit;
}

/* ============================================================
   Background pattern (subtle)
   ============================================================ */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 149, 0, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(0, 214, 143, 0.03) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

.container-narrow {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #0a0e1a;
    box-shadow: 0 0 0 0 var(--accent-soft);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255, 149, 0, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

/* PATCH 9.37.9: Reload Table / Reload A10 Layer get the same saturated green
   look as the completed A10 stage buttons. They're permanently green (no
   state lifecycle) — the freshness pill below tells the user when the data
   was last refreshed. Specific selector via .reload-cell so we don't paint
   every btn-secondary in the project green. */
.reload-cell .btn-secondary {
    background: #16a34a !important;
    color: #ffffff !important;
    border: 1px solid #16a34a !important;
    font-weight: 600 !important;
    transition: all 0.2s ease;
}
.reload-cell .btn-secondary:hover {
    background: #15803d !important;
    border-color: #15803d !important;
}

/* PATCH 9.20: A10 stage button states - clear visual feedback */
.a10-stage-btn { transition: all 0.2s ease; position: relative; }

/* PATCH 9.37.8: API marker — small "API" pill in the top-right corner of
   any stage button that actually calls Amazon SP-API or Ads API. Buttons
   for purely-local computations (recompute_scores, extract_keywords) do
   NOT get this marker, so the user can tell at a glance which clicks cost
   Amazon-side rate-limit budget vs which are free local DB work. */
.a10-stage-btn[data-amazon-api="1"]::before {
    content: "API";
    position: absolute;
    top: -8px;
    right: -6px;
    background: #1e40af;
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid #1e3a8a;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    z-index: 1;
}

.a10-stage-btn.a10-stage-idle {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-default) !important;
    box-shadow: none !important;
    transform: none !important;
}
.a10-stage-btn.a10-stage-idle:hover {
    background: var(--bg-hover) !important;
    border-color: var(--border-strong) !important;
    transform: none !important;
    box-shadow: none !important;
}

.a10-stage-btn.a10-stage-running {
    background: var(--accent) !important;
    color: #0a0e1a !important;
    border: 1px solid var(--accent) !important;
    cursor: wait !important;
}
.a10-stage-btn.a10-stage-running:hover {
    transform: none !important;
    box-shadow: 0 4px 20px rgba(255, 149, 0, 0.4) !important;
}

.a10-stage-btn.a10-stage-done {
    background: #16a34a !important;
    color: #ffffff !important;
    border: 1px solid #16a34a !important;
    box-shadow: none !important;
    font-weight: 600 !important;
}
.a10-stage-btn.a10-stage-done:hover {
    background: #15803d !important;
    border-color: #15803d !important;
    transform: none !important;
}
/* PATCH 9.37.8: keep the "X ago" sub-line readable on the saturated fill —
   slightly faded white instead of opacity 0.72 grey-on-grey. */
.a10-stage-btn.a10-stage-done .a10-stage-when {
    color: rgba(255, 255, 255, 0.85);
    opacity: 1;
}

.a10-stage-btn.a10-stage-warn {
    background: rgba(255, 184, 77, 0.16) !important;
    color: #ffd29a !important;
    border: 1px solid rgba(255, 184, 77, 0.45) !important;
    box-shadow: none !important;
}
.a10-stage-btn.a10-stage-warn:hover {
    background: rgba(255, 184, 77, 0.26) !important;
    transform: none !important;
}

.a10-stage-btn.a10-stage-failed {
    background: rgba(255, 77, 141, 0.18) !important;
    color: #ff9abf !important;
    border: 1px solid rgba(255, 77, 141, 0.45) !important;
    box-shadow: none !important;
}
.a10-stage-btn.a10-stage-failed:hover {
    background: rgba(255, 77, 141, 0.28) !important;
    transform: none !important;
}

/* PATCH 9.29: pending_external - Amazon is still generating report (info, not error) */
.a10-stage-btn.a10-stage-pending {
    background: rgba(80, 165, 255, 0.18) !important;
    color: #9bc7ff !important;
    border: 1px solid rgba(80, 165, 255, 0.45) !important;
    box-shadow: none !important;
}
.a10-stage-btn.a10-stage-pending:hover {
    background: rgba(80, 165, 255, 0.28) !important;
    transform: none !important;
}

/* PATCH 9.37.3: Sync Base Products keeps the orange "primary" look in idle
   state so users still recognize it as the recommended-first action.
   Other states (running/done/failed/pending/warn) use the standard A10
   colour lifecycle defined above — same visual language as every other stage. */
.a10-stage-btn#spapi-sync-btn.a10-stage-idle {
    background: var(--accent) !important;
    color: #0a0e1a !important;
    border: 1px solid var(--accent) !important;
    font-weight: 700 !important;
}
.a10-stage-btn#spapi-sync-btn.a10-stage-idle:hover {
    background: #ffb84a !important;
    border-color: #ffb84a !important;
}

.btn-ghost {
    color: var(--text-secondary);
    padding: 8px 16px;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.btn-block {
    width: 100%;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
}

/* ============================================================
   Brand / Logo
   ============================================================ */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a0e1a;
    font-weight: 900;
    font-size: 18px;
    box-shadow: 0 4px 16px rgba(255, 149, 0, 0.3);
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-link {
    padding: 8px 16px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-weight: 500;
}

.navbar-link:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.navbar-link.active {
    color: var(--accent);
}

/* ============================================================
   Alerts / Messages
   ============================================================ */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(255, 61, 113, 0.3);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(0, 214, 143, 0.3);
}

/* ============================================================
   Utilities
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.text-sm { font-size: 13px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; }
.text-2xl { font-size: 32px; }
.text-3xl { font-size: 44px; }

.font-mono { font-family: var(--font-mono); }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    html { font-size: 15px; }
    .text-3xl { font-size: 36px; }
    .text-2xl { font-size: 26px; }
    .navbar-nav { display: none; }
    .navbar-nav.mobile-open {
        display: flex;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-base);
        flex-direction: column;
        padding: 20px;
        gap: 0;
        border-bottom: 1px solid var(--border-subtle);
    }
}
