:root {
    --bg: #f7f7f8;
    --surface: #ffffff;
    --border: #e7e7ea;
    --border-soft: #eeeef1;
    --text: #222226;
    --text-muted: #6a6a72;
    --accent: #e0395c;
    --accent-soft: #fdeef1;
    --accent-hover: #c62c4c;
    --ink: #2f6fed;
    --ink-soft: #eef2ff;
    --danger: #d93025;
    --success: #1e8449;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05), 0 1px 1px rgba(20, 20, 30, 0.03);
    --shadow-md: 0 6px 20px rgba(20, 20, 30, 0.08), 0 2px 6px rgba(20, 20, 30, 0.04);
    --shadow-lg: 0 16px 40px rgba(20, 20, 30, 0.12), 0 4px 12px rgba(20, 20, 30, 0.05);
    --transition: 220ms cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-fast: 140ms cubic-bezier(0.25, 0.8, 0.25, 1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.45;
}

.hidden { display: none !important; }

.topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: box-shadow var(--transition);
}
.topnav.scrolled { box-shadow: var(--shadow-sm); }

.brand { font-weight: 800; display: flex; align-items: baseline; gap: 8px; letter-spacing: -0.01em; }
.brand-sub { font-weight: 400; color: var(--text-muted); font-size: 13px; }

.topnav nav { display: flex; align-items: center; }
.topnav nav a {
    position: relative;
    margin-left: 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 2px;
    transition: color var(--transition-fast);
}
.topnav nav a::after {
    content: "";
    position: absolute;
    left: 0; right: 100%;
    bottom: 2px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    transition: right var(--transition);
}
.topnav nav a:hover { color: var(--text); }
.topnav nav a:hover::after, .topnav nav a.active::after { right: 0; }
.topnav nav a.active { color: var(--text); font-weight: 600; }

.ai-spend-badge {
    background: #fff4e5;
    color: #92600a !important;
    border-radius: 999px;
    padding: 6px 14px !important;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.ai-spend-badge::after { display: none; }
.ai-spend-badge:hover { background: #ffe6c2; transform: translateY(-1px); }
.ai-spend-count { font-weight: 400; opacity: 0.75; font-size: 12px; }

.container {
    max-width: 1140px;
    margin: 28px auto;
    padding: 0 20px 56px;
}

h1 { font-size: 24px; margin-bottom: 18px; letter-spacing: -0.01em; font-weight: 700; }
h2 { letter-spacing: -0.01em; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

/* Barre de filtres unifiee, façon barre de recherche : un seul contenant
   arrondi qui englobe visuellement tous les champs, plutôt que des inputs
   séparés (chaque input perd son propre cadre et se sépare par un simple
   trait vertical fin). */
.filters, .inline-form {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    padding: 4px;
    transition: box-shadow var(--transition);
}
.filters:focus-within, .inline-form:focus-within { box-shadow: var(--shadow-md); }
.filters input, .filters select,
.inline-form input, .inline-form select {
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 999px;
    position: relative;
}
.filters input:not(:last-of-type), .filters select:not(:last-of-type) {
    border-right: 1px solid var(--border-soft);
    border-radius: 0;
}
.filters button, .inline-form button {
    border-radius: 999px;
    margin-left: 2px;
}

input[type=text], input[type=number], input[type=password], input[type=file], select, textarea {
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input[type=text]:focus, input[type=number]:focus, input[type=password]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea { width: 100%; font-family: inherit; }

button, .btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
button:hover, .btn:hover { border-color: var(--text-muted); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
button:active, .btn:active { transform: translateY(0); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary, button[type=submit] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover, button[type=submit]:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: var(--shadow-md); }

.btn-mini {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 999px;
    background: var(--ink-soft);
    border-color: transparent;
    color: var(--ink);
}
.btn-mini:hover { background: var(--ink); color: #fff; }
.btn-mini.link-danger { background: #fdecea; color: var(--danger); text-decoration: none; }
.btn-mini.link-danger:hover { background: var(--danger); color: #fff; }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-danger {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    text-decoration: underline;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table th, .data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    font-size: 14px;
}
.data-table th { background: #fcfcfd; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition-fast), box-shadow var(--transition-fast); }
.data-table tbody tr:hover { background: #fafafc; box-shadow: inset 0 0 0 1px var(--border-soft); }

.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow-sm); }

img.thumb, img.image-card-thumb, img.preview-thumb { cursor: zoom-in; transition: transform var(--transition-fast); }
img.thumb:hover, img.image-card-thumb:hover, img.preview-thumb:hover { transform: scale(1.06); }

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 20, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: zoom-out;
    padding: 40px;
    animation: toast-in 200ms cubic-bezier(0.25, 0.8, 0.25, 1);
}
.lightbox-overlay.hidden { display: none; }
.lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.badge {
    display: inline-block;
    background: var(--ink-soft);
    color: #3346a3;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 2px 0 0;
}

.actions a, .actions form { margin-right: 8px; }

.price-old { text-decoration: line-through; color: var(--text-muted); font-size: 13px; }
.price-sale { color: var(--accent); font-weight: 600; }

.product-form { display: flex; flex-direction: column; gap: 20px; max-width: 720px; }
.product-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.product-form fieldset {
    border: 1px solid var(--border-soft);
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.product-form legend {
    font-weight: 700;
    padding: 0 8px;
    font-size: 15px;
    letter-spacing: -0.01em;
}
.checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: normal !important; }
.form-row { display: flex; gap: 16px; }
.form-row label { flex: 1; }
.form-actions { display: flex; gap: 10px; }

.error { color: var(--danger); background: #fdecea; border: 1px solid #f5c6c2; padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.error::before { content: "⚠ "; }
.flash { background: #e9f7ee; border: 1px solid #bfe6cc; color: var(--success); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow-sm); animation: toast-in 220ms cubic-bezier(0.25, 0.8, 0.25, 1); }
.flash::before { content: "✓ "; }
.flash-key code { display: block; margin-top: 8px; padding: 8px; background: #fff; border-radius: 4px; word-break: break-all; }
.hint { color: var(--text-muted); font-size: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.log-box { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.log-box p { margin: 4px 0; font-size: 14px; }

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #fff5f2 0%, var(--bg) 55%);
}
.auth-box {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-xl);
    padding: 36px;
    width: 340px;
    box-shadow: var(--shadow-lg);
}
.auth-box h1 { font-size: 19px; margin-bottom: 18px; }
.auth-box form { display: flex; flex-direction: column; gap: 14px; }
.auth-box label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

.cat-picker { max-width: 420px; }
.cat-search { width: 100%; margin-bottom: 6px; }
.cat-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    background: var(--surface);
}
.cat-option {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 6px !important;
    font-weight: normal !important;
    padding: 4px 0;
}

.price-ttc-preview { font-size: 13px; color: var(--text-muted); margin-top: -8px; }
.price-cell { font-size: 13px; line-height: 1.6; }

.preview-thumb {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
}
.preview-thumb.hidden { display: none; }
.image-preview-row { margin-top: -8px; }
.gallery-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -8px; }

.badge.stock-in { background: #e7f6ec; color: #1e6b34; }
.badge.stock-out { background: #fdecea; color: #a02a20; }
.badge.stock-back { background: #fff4e0; color: #92600a; }

.danger-box {
    background: var(--surface);
    border: 1px solid #f5c6c2;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px;
    box-shadow: var(--shadow-sm);
}
.danger-box form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.danger-box label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

details.meta-details { margin-top: 8px; font-size: 13px; }
.meta-dump { max-height: 240px; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; font-size: 12px; }

fieldset.tech-fieldset .form-row { margin-bottom: 12px; }

/* ===== Champs personnalisés par site (ACF) — pivot 1 ligne/champ, 1 colonne/site ===== */

.acf-pivot-table th:first-child, .acf-pivot-table td:first-child { min-width: 200px; }
.acf-group-row td {
    background: #fcfcfd;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
}
.site-acf-empty { color: var(--text-muted); font-size: 13px; padding: 10px 16px; }

/* ===== Meilleures ventes ===== */

.rank-input { width: 64px; padding: 5px 8px; text-align: center; }
.trend-up { color: var(--success); font-weight: 600; }
.trend-down { color: var(--danger); font-weight: 600; }
.source-tag { font-size: 11px; color: var(--text-muted); }

.selection-bar {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    border-radius: 999px;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    font-size: 13px;
    animation: toast-in 220ms cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-wrap: wrap;
    justify-content: center;
}
.selection-bar.hidden { display: none; }
.selection-bar strong { color: #fff; }
.selection-bar .btn-mini { background: rgba(255,255,255,0.15); color: #fff; }
.selection-bar .btn-mini:hover { background: rgba(255,255,255,0.3); }

/* ===== Studio images IA ===== */

.gallery-section {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 26px;
    max-width: 1100px;
}
.gallery-section h2 { margin: 0 0 12px; font-size: 17px; }
.gallery-section h3 { margin: 0 0 10px; font-size: 14px; }

.ai-panel {
    background: linear-gradient(135deg, var(--accent-soft), #fdf2ff);
    border: 1px solid #f6dbe2;
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.ai-panel .form-row { margin-bottom: 8px; }
.ai-panel textarea { background: #fff; }

.upload-panel {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}
.upload-panel input[type=file] { display: block; margin-top: 6px; }

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.image-card {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
    transition: box-shadow var(--transition), transform var(--transition);
}
.image-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.image-card-new { animation: card-pop 320ms cubic-bezier(0.25, 0.8, 0.25, 1); }
@keyframes card-pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

.image-card-thumb-wrap { position: relative; }
.image-card-thumb { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--bg); }
.badge-main {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #fff8e1;
    color: #92600a;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.image-card-slug {
    padding: 4px 10px 0;
    font-size: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.image-card-meta { padding: 8px 10px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cost-tag { font-size: 11px; color: var(--text-muted); }
.image-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
}
.watermark-inline { display: flex; gap: 4px; }
.wm-input, .wm-select {
    flex: 1;
    min-width: 0;
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.gallery-columns { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.gallery-column { flex: 1 1 320px; min-width: 280px; }
.gallery-column h3 { display: flex; align-items: center; gap: 8px; }

.photo-pairs-table .base-photo-cell { width: 190px; vertical-align: top; }
.photo-pairs-table .ai-versions-cell { vertical-align: top; }
.photo-pairs-table td { padding: 14px; }
.ai-versions-cell { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.ai-versions-cell .image-card { width: 150px; }
.generate-from-btn { white-space: nowrap; }
.row-generate-controls { display: flex; flex-direction: column; gap: 6px; align-self: center; min-width: 220px; }
.row-prompt { width: 100%; font-size: 12px; font-family: inherit; }

/* ===== Bulk / barre de progression ===== */

.bulk-panel {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.progress-track {
    width: 100%;
    height: 10px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #7c5cff);
    transition: width 300ms cubic-bezier(0.25, 0.8, 0.25, 1);
}

.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px 24px;
    min-width: 150px;
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-value { font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.log-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.log-row .thumb { width: 32px; height: 32px; border-radius: 8px; }
.log-box p.log-ok { color: var(--success); margin: 3px 0; }
.log-box p.log-err { color: var(--danger); margin: 3px 0; }
.log-box p.log-warn { color: #92600a; margin: 3px 0; }
.log-box { max-height: 260px; overflow-y: auto; }
