/* ═══════════════════════════════════════════════════
   Wine Pricer — Premium Dark Theme
   ═══════════════════════════════════════════════════ */

:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(18, 18, 30, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --text-primary: #f0f0f5;
    --text-secondary: #8b8ba3;
    --text-muted: #555570;

    /* Accent */
    --wine-red: #b8243e;
    --wine-red-glow: rgba(184, 36, 62, 0.35);
    --wine-red-soft: rgba(184, 36, 62, 0.12);
    --gold: #d4a54a;
    --gold-glow: rgba(212, 165, 74, 0.25);
    --green: #34c759;
    --green-soft: rgba(52, 199, 89, 0.12);
    --amber: #ff9f0a;
    --amber-soft: rgba(255, 159, 10, 0.12);
    --blue: #5e9eff;
    --blue-soft: rgba(94, 158, 255, 0.12);

    /* Catawiki / iDealwine / eBay branding */
    --catawiki-color: #fc4c02;
    --idealwine-color: #8c2060;
    --ebay-color: #0064d2;

    /* Typography */
    --font-main: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

    /* Sizing */
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --max-width: 900px;
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── Ambient Background ──────────────────────── */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    animation: floatOrb 20s ease-in-out infinite;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--wine-red) 0%, transparent 70%);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--gold) 0%, transparent 70%);
    bottom: -15%;
    right: -5%;
    animation-delay: -7s;
    opacity: 0.2;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #5e5eff 0%, transparent 70%);
    top: 40%;
    right: 20%;
    animation-delay: -14s;
    opacity: 0.12;
}

@keyframes floatOrb {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(40px, -30px) scale(1.08);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

/* ─── App Container ───────────────────────────── */
.app {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* ─── Header ──────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 48px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 36px;
    filter: drop-shadow(0 0 12px var(--wine-red-glow));
}

.logo-text h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.header-status.online .status-dot {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.header-status.online .status-text {
    color: var(--green);
}

.header-status.offline .status-dot {
    background: #ff453a;
    box-shadow: 0 0 8px #ff453a;
}

.header-status.offline .status-text {
    color: #ff453a;
}

/* ─── Search ──────────────────────────────────── */
.search-section {
    margin-bottom: 32px;
}

.search-container {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px 6px 4px 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(20px);
}

.search-container:focus-within {
    border-color: var(--wine-red);
    box-shadow: 0 0 0 3px var(--wine-red-soft), 0 8px 32px rgba(0, 0, 0, 0.3);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 12px;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 400;
    padding: 16px 0;
}

.search-input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.search-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--wine-red), #8b1a30);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}

.search-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px var(--wine-red-glow);
}

.search-btn:active {
    transform: scale(0.96);
}

.search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.search-hint {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.search-hint kbd {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

/* ─── Progress ────────────────────────────────── */
.progress-section {
    margin-bottom: 40px;
    animation: fadeIn 0.4s ease;
}

.progress-bar-track {
    height: 3px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--wine-red), var(--gold));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-steps {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    border-radius: var(--radius);
    background: var(--bg-glass);
    border: 1px solid var(--border);
    min-width: 120px;
    transition: all 0.3s ease;
}

.step.active {
    border-color: var(--wine-red);
    background: var(--wine-red-soft);
}

.step.done {
    border-color: var(--green);
    background: var(--green-soft);
}

.step.error {
    border-color: #ff453a;
    background: rgba(255, 69, 58, 0.1);
}

.step-icon {
    font-size: 1.3rem;
}

.step-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}

.step-status {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.step.active .step-status {
    color: var(--wine-red);
}

.step.done .step-status {
    color: var(--green);
}

/* ─── Aggregate Card ──────────────────────────── */
.aggregate-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    backdrop-filter: blur(20px);
    animation: slideUp 0.5s ease;
}

.agg-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.agg-wine-info h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.agg-vintage {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gold);
    background: rgba(212, 165, 74, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    margin-top: 6px;
}

.agg-best-price {
    text-align: right;
}

.agg-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.agg-value {
    font-size: 2.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold), #e8c76a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.agg-confidence-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agg-conf-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 80px;
}

.confidence-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.6s ease, background 0.3s;
}

.agg-conf-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* ─── Source Cards ─────────────────────────────── */
.source-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.source-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    backdrop-filter: blur(20px);
    animation: slideUp 0.5s ease;
    transition: border-color 0.3s;
}

.source-card:hover {
    border-color: var(--border-hover);
}

.catawiki-card {
    border-top: 3px solid var(--catawiki-color);
}

.idealwine-card {
    border-top: 3px solid var(--idealwine-color);
}

.ebay-card {
    border-top: 3px solid var(--ebay-color);
}

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

.card-icon {
    font-size: 1.1rem;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body .price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.card-body .price-row:last-child {
    border-bottom: none;
}

.price-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.price-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.price-value.sold {
    color: var(--green);
}

.price-value.estimate {
    color: var(--amber);
}

.price-value.median {
    color: var(--blue);
}

.lot-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-decoration: none;
    word-break: break-all;
    transition: color 0.2s;
}

.lot-link:hover {
    color: var(--text-primary);
}

.lot-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.lot-item:last-child {
    border-bottom: none;
}

/* ─── Notes ───────────────────────────────────── */
.notes-section {
    background: var(--amber-soft);
    border: 1px solid rgba(255, 159, 10, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 24px;
}

.notes-text {
    font-size: 0.82rem;
    color: var(--amber);
    line-height: 1.5;
}

/* ─── History ─────────────────────────────────── */
.history-section {
    margin-top: 48px;
}

.history-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.04);
}

.history-wine {
    font-size: 0.9rem;
    font-weight: 500;
}

.history-price {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--gold);
}

.history-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Animations ──────────────────────────────── */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.searching .step.active .step-status {
    animation: pulse 1.2s ease-in-out infinite;
}

/* ─── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
    .app {
        padding: 24px 16px 60px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .agg-header {
        flex-direction: column;
    }

    .agg-best-price {
        text-align: left;
    }

    .agg-value {
        font-size: 1.8rem;
    }

    .progress-steps {
        flex-direction: column;
        align-items: stretch;
    }

    .step {
        flex-direction: row;
        gap: 10px;
        min-width: auto;
    }

    .source-cards {
        grid-template-columns: 1fr;
    }
}

/* ─── Spinner ─────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--wine-red);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}