/* =====================================================
   Pokémon Card Scanner – Classic Palette
   Yellow #FFCB05 | Blue #3D7DCA | Red #FF0000
   White #FFFFFF  | Black #000000
   ===================================================== */

:root {
    --yellow: #FFCB05;
    --blue: #3D7DCA;
    --red: #FF0000;
    --white: #FFFFFF;
    --black: #000000;
    --dark-blue: #2a5a9a;
    --light-gray: #f5f5f5;
    --border: #ddd;
    --text: #222;
    --muted: #666;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--light-gray);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ========== TOP BANNER ========== */
.top-banner {
    width: 100%;
    background: var(--black);
    text-align: center;
    overflow: hidden;
}

.top-banner img {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: cover;
}

/* ========== HEADER + MENU ========== */
.site-header {
    background: var(--blue);
    border-bottom: 4px solid var(--yellow);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--white);
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--yellow);
}

.main-nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: var(--white);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.15);
}

.nav-link.active {
    background: var(--yellow);
    color: var(--black);
}

/* ========== PAGE LAYOUT (ads + content) ========== */
.page-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: grid;
    grid-template-columns: 160px 1fr 160px;
    gap: 1.5rem;
    align-items: start;
}

/* Ad spaces */
.ad-space {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: sticky;
    top: 80px;
}

.ad-label { display: none !important; 
    background: var(--black);
    color: var(--white);
    font-size: 0.7rem;
    text-align: center;
    padding: 0.25rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.ad-content {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.ad-placeholder {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 1rem;
}

.ad-placeholder p {
    font-weight: 600;
    margin-bottom: 0.35rem;
}

/* Main content */
.main-content {
    min-width: 0;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* ========== CARDS & FORMS ========== */
.card, .form-card, .intro-box {
    background: var(--white);
    border: 2px solid var(--black);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 4px 4px 0 var(--blue);
}

.intro-box {
    text-align: center;
    border-color: var(--yellow);
    box-shadow: 4px 4px 0 var(--yellow);
}

.intro-box h1 {
    color: var(--blue);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.intro-box p {
    color: var(--muted);
    max-width: 520px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--black);
}

.optional {
    font-weight: 400;
    color: var(--muted);
    font-size: 0.9rem;
}

.required {
    color: var(--red);
}

input[type="text"],
input[type="file"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--black);
    border-radius: 6px;
    background: var(--white);
    color: var(--text);
    font-size: 1rem;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(61, 125, 202, 0.25);
}

small {
    display: block;
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.image-preview {
    margin-top: 0.75rem;
    max-width: 240px;
}

.image-preview img {
    max-width: 100%;
    border-radius: 6px;
    border: 2px solid var(--black);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border: 2px solid var(--black);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
    transform: translateY(2px);
}

.btn-primary {
    background: var(--red);
    color: var(--white);
    width: 100%;
    box-shadow: 3px 3px 0 var(--black);
}

.btn-primary:hover:not(:disabled) {
    background: #e60000;
}

.btn-secondary {
    background: var(--yellow);
    color: var(--black);
    box-shadow: 3px 3px 0 var(--black);
    margin-top: 1rem;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* ========== RESULTS ========== */
.results-section h2 {
    color: var(--blue);
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
}

.results-info {
    color: var(--muted);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

.result-card {
    background: var(--white);
    border: 2px solid var(--black);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 3px 3px 0 var(--blue);
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 5px 5px 0 var(--yellow);
}

.result-card img {
    width: 100%;
    aspect-ratio: 2.5 / 3.5;
    object-fit: cover;
    background: #eee;
    display: block;
    border-bottom: 2px solid var(--black);
}

.result-body {
    padding: 0.9rem;
}

.result-body h3 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
    line-height: 1.3;
    color: var(--black);
}

.meta {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.65rem;
}

.prices {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.price-label {
    color: var(--muted);
}

.price-value {
    font-weight: 700;
}

.price-value.usd { color: #1a7a1a; }
.price-value.eur { color: var(--blue); }

.no-price {
    color: var(--muted);
    font-style: italic;
}

/* Status messages */
.status-message {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-weight: 600;
    border: 2px solid;
}

.status-message.error {
    background: #ffe0e0;
    border-color: var(--red);
    color: #a00;
}

.status-message.success {
    background: #e0ffe0;
    border-color: #1a7a1a;
    color: #1a7a1a;
}

/* Recent scans */
.section-desc {
    color: var(--muted);
    margin-bottom: 1rem;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--light-gray);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.recent-item:hover {
    background: #e8f0fe;
    border-color: var(--blue);
}

.recent-item .query {
    font-weight: 600;
}

.recent-item .time {
    font-size: 0.8rem;
    color: var(--muted);
}

.empty-state {
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 1.5rem;
}

/* ========== FOOTER ========== */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 1rem;
    background: var(--blue);
    color: var(--white);
    border-top: 4px solid var(--yellow);
    font-size: 0.85rem;
}

.site-footer a {
    color: var(--yellow);
    text-decoration: none;
    font-weight: 600;
}

.site-footer a:hover {
    text-decoration: underline;
}

.disclaimer {
    margin-top: 0.4rem;
    opacity: 0.85;
    font-size: 0.8rem;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
    .page-wrapper {
        grid-template-columns: 1fr;
    }

    .ad-space {
        display: none; /* hide side ads on smaller screens */
    }
}

@media (max-width: 600px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-nav {
        width: 100%;
        justify-content: space-between;
    }

    .nav-link {
        flex: 1;
        text-align: center;
        padding: 0.5rem 0.4rem;
        font-size: 0.85rem;
    }

    .intro-box h1 {
        font-size: 1.35rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== OCR + OR DIVIDER ========== */
.or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.25rem 0;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.9rem;
}

.or-divider::before,
.or-divider::after {
    content: "";
    flex: 1;
    border-bottom: 2px solid var(--border);
}

.or-divider span {
    padding: 0 1rem;
    background: var(--white);
    color: var(--blue);
}

.ocr-status {
    margin-top: 0.6rem;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid;
}

.ocr-status.working {
    background: #e8f0fe;
    border-color: var(--blue);
    color: var(--dark-blue);
}

.ocr-status.success {
    background: #e0ffe0;
    border-color: #1a7a1a;
    color: #1a7a1a;
}

.ocr-status.error {
    background: #ffe0e0;
    border-color: var(--red);
    color: #a00;
}

.price-value.cad { color: #c60; }
.ad-label { display: none !important; }


/* Auto-scan UI */
.drop-zone {
    position: relative;
    border: 3px dashed var(--blue, #3D7DCA);
    border-radius: 12px;
    padding: 2rem 1rem;
    text-align: center;
    background: #f8fbff;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.drop-zone.drag-over {
    border-color: var(--yellow, #FFCB05);
    background: #fffbeb;
}
.drop-zone input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.drop-title { font-weight: 700; color: var(--blue, #3D7DCA); margin: 0 0 .35rem; }
.drop-hint { margin: 0; font-size: .85rem; color: #666; }

.scan-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    padding: 1rem;
    background: #e8f0fe;
    border-radius: 10px;
    border: 2px solid var(--blue, #3D7DCA);
}
.scan-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #c5d8f5;
    border-top-color: var(--blue, #3D7DCA);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.scan-progress p { margin: 0; font-weight: 600; color: #1a4a8a; }

.scan-result { margin-top: 1.5rem; }
.provider-attribution {
    margin: .65rem 0 0;
    text-align: right;
    font-size: .78rem;
    color: #777;
}
.provider-attribution a {
    color: #555;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.provider-attribution a:hover { color: var(--blue, #3D7DCA); }
.confidence-badge {
    display: inline-block;
    padding: .35rem .85rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: .75rem;
}
.conf-high { background: #d4edda; color: #155724; }
.conf-mid { background: #fff3cd; color: #856404; }
.conf-low { background: #f8d7da; color: #721c24; }

.hero-result {
    display: flex;
    gap: 1.25rem;
    background: #fff;
    border: 3px solid var(--blue, #3D7DCA);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.hero-thumb {
    width: 140px;
    max-width: 35%;
    aspect-ratio: 2.5/3.5;
    object-fit: cover;
    border-radius: 8px;
    background: #eee;
}
.hero-body { flex: 1; min-width: 0; }
.hero-body h2 { margin: 0 0 .35rem; color: #111; font-size: 1.4rem; }
.hero-meta { margin: 0 0 .75rem; color: #555; font-size: .95rem; }
.hero-price {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: #0a7a2f;
}
.hero-price-sub { margin: .25rem 0 0; color: #666; font-size: .9rem; }
.hero-note { margin: .75rem 0 0; font-size: .8rem; color: #888; }

.alt-results { margin-top: 1.5rem; }
.alt-results h3 { margin: 0 0 .75rem; font-size: 1rem; color: #333; }

.manual-search {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fafafa;
    border-radius: 10px;
    border: 1px solid #ddd;
}
.manual-search summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--blue, #3D7DCA);
}
.manual-form {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
    flex-wrap: wrap;
}
.manual-form input {
    flex: 1;
    min-width: 180px;
    padding: .55rem .75rem;
    border: 2px solid #ccc;
    border-radius: 8px;
}

@media (max-width: 600px) {
    .hero-result { flex-direction: column; align-items: center; text-align: center; }
    .hero-thumb { width: 160px; max-width: 50%; }
}

.card-queue + #clearCompletedScans { margin-top: .75rem; }

/* Multi-card queue */
.card-queue {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}
.queue-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .75rem;
    background: #fff;
    border: 2px solid #d0d8e8;
    border-radius: 10px;
}
.queue-item.is-active {
    border-color: var(--blue, #3D7DCA);
    box-shadow: 0 0 0 2px rgba(61,125,202,.2);
}
.queue-thumb {
    width: 48px;
    height: 68px;
    object-fit: cover;
    border-radius: 4px;
    background: #eee;
    flex-shrink: 0;
}
.queue-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.queue-name {
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.q-status {
    font-size: .8rem;
    font-weight: 700;
}
.q-queued { color: #666; }
.q-scanning { color: var(--blue, #3D7DCA); }
.q-done { color: #0a7a2f; }
.q-failed { color: #c00; }
.queue-error {
    font-size: .75rem;
    color: #a33;
}
.queue-actions {
    flex-shrink: 0;
}
.btn-sm {
    padding: .35rem .65rem;
    font-size: .8rem;
}

/* Half-size alternative result cards */
.results-grid-half {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .65rem;
}
.result-card-half img {
    max-height: none;
}
.results-grid-half .result-card {
    font-size: .85rem;
}
.results-grid-half .result-card img {
    width: 100%;
    aspect-ratio: 2.5 / 3.5;
    /* roughly half visual size vs main grid */
    max-width: 110px;
    margin: 0 auto;
    display: block;
}
.results-grid-half .result-body h3 {
    font-size: .85rem;
}

.conf-selected {
    background: #e7f1ff;
    color: #1a4a8a;
    border: 1px solid #3D7DCA;
}
.alt-clickable {
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.alt-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(61,125,202,.25);
    border-color: var(--blue, #3D7DCA);
}
.about-card h1 {
    color: var(--blue, #3D7DCA);
    margin-top: 0;
}
.about-lead {
    font-size: 1.15rem;
    font-weight: 600;
    color: #333;
}
.about-tagline {
    font-style: italic;
    color: #555;
    margin: 1.25rem 0;
    padding: .75rem 1rem;
    background: #fff8e0;
    border-left: 4px solid var(--yellow, #FFCB05);
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox.hidden { display: none !important; }
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.65);
}
.lightbox-panel {
    position: relative;
    z-index: 1;
    max-width: min(92vw, 420px);
    max-height: 90vh;
    padding: .5rem;
    background: #111;
    border-radius: 12px;
    border: 3px solid #FFCB05;
    box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.lightbox-img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 6px;
}
.lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #FF0000;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.lightbox-close:hover { background: #c00; }
body.lightbox-open { overflow: hidden; }

.queue-thumb { cursor: zoom-in; }
.queue-item.is-selectable .queue-info { cursor: pointer; }
.queue-item.is-selectable:hover { border-color: #3D7DCA; }

.original-match-block {
    margin-bottom: 1rem;
}
.original-match-block h3 {
    margin: 0 0 .5rem;
    font-size: .95rem;
    color: #1a4a8a;
}
.original-match-card {
    border: 2px solid #FFCB05 !important;
    cursor: pointer;
    max-width: 140px;
}
.hero-thumb { cursor: zoom-in; }

.manual-hint {
    margin: .65rem 0 0;
    font-size: .85rem;
    color: #444;
    line-height: 1.45;
}
.manual-hint code {
    background: #eee;
    padding: .1rem .35rem;
    border-radius: 4px;
    font-size: .8rem;
}

/* Original + alternatives in one horizontal row */
.matches-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-start;
}
.match-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
}
.match-tile-label {
    font-size: .75rem;
    font-weight: 700;
    color: #1a4a8a;
    text-align: center;
}
.match-tile .result-card {
    max-width: 130px;
}

.btn-xs {
    padding: .2rem .4rem;
    font-size: .7rem;
    margin-top: .35rem;
}
.ebay-btn { margin-top: .5rem; }

.ebay-lightbox .ebay-panel {
    max-width: min(94vw, 640px);
    background: #fff;
    color: #222;
    border-color: #3D7DCA;
    padding: 1rem 1.1rem 1.2rem;
}
.ebay-title {
    margin: 0 1.5rem .75rem 0;
    color: #1a4a8a;
    font-size: 1.15rem;
}
.ebay-body { max-height: 70vh; overflow: auto; }
.ebay-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 600px) {
    .ebay-cols { grid-template-columns: 1fr; }
}
.ebay-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.ebay-list li {
    padding: .45rem 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: .85rem;
}
.ebay-list a { color: #1a4a8a; text-decoration: none; display: block; }
.ebay-list a:hover { text-decoration: underline; }
.ebay-price {
    display: block;
    font-weight: 700;
    color: #0a7a2f;
    margin-top: .15rem;
}
.ebay-more {
    display: inline-block;
    margin-top: .5rem;
    font-size: .8rem;
    color: #3D7DCA;
}
.ebay-note, .ebay-empty, .ebay-loading, .ebay-query {
    font-size: .85rem;
    color: #555;
}
.ebay-error { color: #a00; }

.ebay-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 1rem 0;
}
.ebay-cta-row .btn { text-decoration: none; }


/* Workspace actions */
.queue-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-top: 0.75rem;
}
