/* ============================================================
   InfoProduit — design tokens
   ============================================================ */
:root {
    --color-brand: #03173d;
    --color-brand-soft: #1e3a8a;
    --color-accent: #2563eb;
    --color-accent-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-soft: #fee2e2;
    --color-success: #16a34a;
    --color-success-soft: #dcfce7;
    --color-warning: #d97706;
    --color-warning-soft: #fef3c7;
    --color-info-soft: #dbeafe;

    --color-bg: #f6f8fb;
    --color-surface: #ffffff;
    --color-surface-alt: #f1f5f9;
    --color-text: #0f172a;
    --color-text-muted: #475569;
    --color-border: #e2e8f0;

    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --max-content: 720px;

    --transition: 0.18s ease;
}

[data-theme="dark"] {
    --color-bg: #0b1220;
    --color-surface: #111a2e;
    --color-surface-alt: #1a2540;
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-border: #22314f;
    --color-brand: #93c5fd;
    --color-brand-soft: #60a5fa;
    --color-accent: #60a5fa;
    --color-accent-hover: #93c5fd;
    --color-danger: #f87171;
    --color-danger-soft: rgba(220, 38, 38, 0.15);
    --color-success: #4ade80;
    --color-success-soft: rgba(22, 163, 74, 0.15);
    --color-warning: #fbbf24;
    --color-warning-soft: rgba(217, 119, 6, 0.15);
    --color-info-soft: rgba(37, 99, 235, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   base
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.55;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 0.5rem;
    line-height: 1.25;
    color: var(--color-text);
}

img {
    max-width: 100%;
    height: auto;
}

input,
select,
button {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

[hidden] {
    display: none !important;
}

/* ============================================================
   layout — header / page / footer
   ============================================================ */
.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: var(--max-content);
    margin: 0 auto;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--color-brand);
    text-decoration: none;
    flex-shrink: 0;
}

.brand img {
    width: 32px;
    height: 32px;
}

.brand-label {
    font-size: 1.05rem;
}

.nav {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    align-items: center;
}

.nav-link {
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
    text-decoration: none;
}

.nav-link.is-active {
    background: var(--color-accent);
    color: #fff;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-alt);
    color: var(--color-text);
    font-size: 1.05rem;
    transition: background var(--transition), transform var(--transition);
}

.theme-toggle:hover {
    background: var(--color-border);
    transform: rotate(15deg);
}

.page {
    flex: 1;
    max-width: var(--max-content);
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

.hero {
    text-align: center;
    margin: 0.5rem 0 1.25rem;
}

.hero h1 {
    font-size: 1.75rem;
    color: var(--color-brand);
    margin-bottom: 0.25rem;
}

.hero-tagline {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.app-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.25rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.app-footer img {
    width: 40px;
    margin: 0.5rem auto;
    display: block;
}

.app-footer a {
    color: var(--color-text-muted);
}

/* ============================================================
   card
   ============================================================ */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0 0 1rem;
    box-shadow: var(--shadow-sm);
}

.card h2,
.card h3 {
    color: var(--color-brand);
}

/* ============================================================
   mode switcher
   ============================================================ */
.mode-switcher {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 110px;
    min-height: 92px;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    transition: all var(--transition);
}

.mode-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: var(--shadow);
}

.mode-btn[aria-pressed="true"] {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.mode-icon {
    font-size: 1.6rem;
    display: block;
}

/* ============================================================
   panels / forms
   ============================================================ */
.panel label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--color-text);
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

input[type="text"],
input[type="number"],
.select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
.select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-info-soft);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
}

.btn-secondary {
    background: var(--color-surface-alt);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-border);
}

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

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

/* ============================================================
   scanner
   ============================================================ */
.scanner-video {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: #000;
    margin-bottom: 0.75rem;
}

.camera-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.camera-row span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.hint {
    margin: 0 0 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--color-warning-soft);
    border-left: 3px solid var(--color-warning);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--color-text);
}

/* ============================================================
   intro card
   ============================================================ */
.intro {
    background: var(--color-surface-alt);
    border-style: dashed;
}

.intro h2 {
    font-size: 1rem;
    color: var(--color-brand);
}

.intro p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--color-text-muted);
}

/* ============================================================
   alerts
   ============================================================ */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0 0 1rem;
    border: 1px solid transparent;
}

.alert-info {
    background: var(--color-info-soft);
    border-color: var(--color-accent);
    color: var(--color-text);
}

.alert-warning {
    background: var(--color-warning-soft);
    border-color: var(--color-warning);
    color: var(--color-text);
}

.alert-success {
    background: var(--color-success-soft);
    border-color: var(--color-success);
    color: var(--color-text);
}

.alert-danger {
    background: var(--color-danger-soft);
    border-color: var(--color-danger);
    color: var(--color-text);
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
    vertical-align: -2px;
}

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

/* ============================================================
   product cards
   ============================================================ */
.product-card .card-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.product-card .card-header img {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    flex-shrink: 0;
}

.product-card .card-header h3 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}

.product-card .gtin {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.scores {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.75rem 0;
    align-items: center;
}

.scores img {
    height: 36px;
    width: auto;
}

.product-card .field {
    margin: 0.5rem 0;
    font-size: 0.92rem;
}

.product-card .field strong {
    color: var(--color-text);
}

.product-card h4 {
    margin-top: 1rem;
    color: var(--color-brand);
    font-size: 0.95rem;
}

/* recall card variant */
.recall-card .card-header h3 {
    color: var(--color-danger);
}

.recall-card .card-header img {
    width: 120px;
    height: 120px;
}

.recall-card h4 {
    color: var(--color-danger);
}

.recall-card ul {
    padding-left: 1.2rem;
    margin: 0.4rem 0;
}

/* recall list (when many results) */
.recall-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recall-list li {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--color-surface);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.recall-list li:hover {
    border-color: var(--color-accent);
    transform: translateX(2px);
}

.recall-list .date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

/* ============================================================
   pager
   ============================================================ */
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.pager span {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ============================================================
   prose (about, etc.)
   ============================================================ */
.prose h2 {
    font-size: 1.1rem;
    margin-top: 1.25rem;
}

.prose ul {
    padding-left: 1.2rem;
}

.text-center {
    text-align: center;
}

/* ============================================================
   filter bar (recent page)
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-field {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 480px) {
    .brand-label {
        display: none;
    }

    .nav-link {
        padding: 0.4rem 0.5rem;
        font-size: 0.85rem;
    }

    .hero h1 {
        font-size: 1.4rem;
    }

    .mode-btn {
        width: 96px;
        min-height: 80px;
        font-size: 0.72rem;
    }

    .mode-icon {
        font-size: 1.4rem;
    }

    .product-card .card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .input-row {
        flex-direction: column;
    }
}
