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

:root {
    --bg:       #120f0a;
    --surface:  #1c1712;
    --border:   #33291b;
    --accent:   #f97316;
    --accent-h: #fb923c;
    --green:    #22c55e;
    --red:      #ef4444;
    --text:     #f3ede4;
    --muted:    #a89a83;
    --radius:   12px;
    --shadow:   0 4px 32px rgba(0,0,0,.4);
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
}

a { color: var(--accent); }

/* ── Layout ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    width: 100%;
    max-width: 560px;
    margin: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 2rem;
}
.logo svg { flex-shrink: 0; }
.logo-text { font-size: 1.35rem; font-weight: 700; letter-spacing: -.5px; }
.logo-text span { color: var(--accent); }

h1 { font-size: 1.15rem; font-weight: 700; margin-bottom: .35rem; }
.subtitle { font-size: .875rem; color: var(--muted); margin-bottom: 2rem; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 1.25rem;
}
.back-link:hover { color: var(--text); }

/* ── Form ── */
.search-form { display: flex; gap: .6rem; margin-bottom: .5rem; }
input[type=text], input[type=search] {
    flex: 1;
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1.05rem;
    letter-spacing: .02em;
    padding: .75rem 1rem;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color .15s;
}
input[type=text]:focus, input[type=search]:focus { border-color: var(--accent); }

.hint { font-size: .78rem; color: var(--muted); margin-top: .6rem; }

/* ── Button ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: var(--accent);
    color: #1c0f00;
    border: none;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 700;
    padding: .8rem 1.4rem;
    cursor: pointer;
    transition: background .15s, transform .1s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover  { background: var(--accent-h); }
.btn:active { transform: scale(.98); }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-ghost:hover { background: var(--border); }
.btn-block { width: 100%; }

/* ── Alert ── */
.alert {
    border-radius: 8px;
    padding: .85rem 1rem;
    font-size: .875rem;
    margin: 1.5rem 0;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}
.alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-info  { background: rgba(249,115,22,.1); border: 1px solid rgba(249,115,22,.3); color: #fdba74; }

/* ── Result card ── */
.product {
    display: flex;
    gap: 1.25rem;
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.product-image {
    position: relative;
    width: 110px; height: 110px;
    flex-shrink: 0;
    border-radius: 8px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border);
}
.product-image img {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    background: #fff;
}
.product-image-fallback { color: #c4c4c4; }

.product-info { min-width: 0; }
.product-name { font-size: 1.1rem; font-weight: 700; line-height: 1.35; margin-bottom: .3rem; }
.product-brand { font-size: .85rem; color: var(--accent); font-weight: 600; margin-bottom: .3rem; }
.product-desc { font-size: .82rem; color: var(--muted); line-height: 1.55; margin-bottom: .5rem; }
.product-meta { font-size: .76rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: .28rem .6rem; border-radius: 999px;
    background: rgba(249,115,22,.15); color: var(--accent);
}

/* ── Fallback search links ── */
.fallback-links { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; }
.fallback-links a {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: .88rem;
    transition: border-color .15s, background .15s;
}
.fallback-links a:hover { border-color: var(--accent); background: var(--bg); }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.code-display {
    font-family: 'Courier New', monospace;
    font-size: .82rem;
    color: var(--muted);
    letter-spacing: .04em;
}

footer {
    margin-top: 2rem;
    font-size: .78rem;
    color: var(--muted);
    text-align: center;
    max-width: 560px;
}

/* ── Scanner caméra ── */
.scanner-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.scanner-overlay.open { display: flex; }

.scanner-frame {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 520px;
    max-height: 100dvh;
    margin: 0 auto;
}
.scanner-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}
.scanner-viewfinder {
    position: absolute;
    left: 8%; right: 8%;
    top: 36%; height: 26%;
    border: 3px solid var(--accent);
    border-radius: 14px;
    box-shadow: 0 0 0 2000px rgba(0,0,0,.45);
    pointer-events: none;
}
.scanner-close {
    position: absolute;
    top: 1rem; right: 1rem;
    width: 42px; height: 42px;
    border-radius: 999px;
    background: rgba(0,0,0,.55);
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.scanner-status {
    position: absolute;
    bottom: 2rem; left: 1rem; right: 1rem;
    text-align: center;
    color: #fff;
    font-size: .9rem;
    text-shadow: 0 1px 4px rgba(0,0,0,.9);
}

/* ── Petits écrans (mobile) ── */
@media (max-width: 480px) {
    body { padding: 1rem; }
    .card { padding: 1.5rem; }
    .search-form { flex-direction: column; }
    .product { flex-direction: column; align-items: center; text-align: center; }
    .product-image { width: 140px; height: 140px; }
    .product-meta { justify-content: center; }
}
