/* ============================================================
   Viewer - Catalogue impressions 3D
   Même système de tokens que admin.css (cohérence visuelle globale)
   ============================================================ */

:root {
    --bg: #F4F6F8;
    --surface: #FFFFFF;
    --border: #D8DCE2;
    --text: #1A1D23;
    --text-muted: #5C6470;
    --accent: #E8631C;

    --font-body: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 40px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.5;
}

.page-header {
    margin-bottom: 32px;
    padding-bottom: 0;
    border-bottom: none;
}
.page-header-actions {
    padding-bottom: 16px;
    border-bottom: 2px solid var(--text);
    margin-top: 15px;
}
.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
/* Header : logo JibLex Factory | séparateur | titre + sous-titre */
.page-header-identity {
    display: flex;
    align-items: center;
    gap: 22px;
}
.header-logo {
    height: 120px;
    width: auto;
    object-fit: contain;
    display: block;
}
.page-header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    min-height: 100px;
    padding-left: 22px;
    border-left: 1px solid var(--border);
}
.page-header .page-header-text h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.1;
}
.page-header-text .subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
@media (max-width: 600px) {
    .page-header-identity { flex-direction: column; align-items: flex-start; gap: 14px; }
    .header-logo { height: 90px; }
    .page-header-text { min-height: 0; padding-left: 0; border-left: none; gap: 4px; }
    .page-header .page-header-text h1 { font-size: 24px; }
}
.btn-admin-access {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease;
    line-height: 1;
}
.btn-admin-access svg {
    flex-shrink: 0;
    align-self: center;
}
.btn-admin-access span {
    line-height: 1;
}
.btn-admin-access:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-admin-connected {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-admin-connected:hover {
    background: rgba(232, 99, 28, 0.06);
}
.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 4px;
}
.subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.empty-state {
    color: var(--text-muted);
    font-size: 14px;
}

.catalogue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 300px);
    gap: 20px;
}

.card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    overflow: hidden;
    width: 300px;
    transition: border-color 0.15s ease, transform 0.1s ease;
}
.card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card-image {
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    background: #EFF1F3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-image-placeholder {
    font-size: 12px;
    color: var(--text-muted);
}
/* Item masqué (items.visible = 0), affiché seulement si le paramètre "Affichage items masqués" l'autorise :
   voile blanc sur l'image + oeil barré rouge en filigrane. Sous le caddie et le badge vues (z-index 2). */
.card-image { position: relative; }
.card-masque-voile {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}
.card-masque-voile svg { width: 40px; height: 40px; }

.card-body {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
}
.card-reference {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.card-title {
    flex-shrink: 0;
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 4px;
    padding-top: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
    min-height: calc(15px * 1.35 * 2);
}
.card-label {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-specs {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
    margin: 0 0 4px;
}
.card-spec {
    display: flex;
    align-items: center;
    gap: 3px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}
.card-spec + .card-spec::before {
    content: '·';
    color: var(--border);
    margin: 0;
}
.card-icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    stroke: var(--text-muted);
}
.card-badges {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
    margin-bottom: 4px;
}
.badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 3px 8px;
    white-space: nowrap;
}
.card-prix {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    color: var(--accent);
    margin: 5px 0 0;
}

/* --- Badge état annonce sur les cartes --- */
.card-annonce-badge {
    display: inline-block;
    align-self: flex-start;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    margin-bottom: 4px;
    width: auto;
}
.card-annonce-initiée   { background: #E8F0FE; color: #3B6FD4; border-color: #3B6FD4; }
.card-annonce-postée    { background: #E7F3EC; color: #2F7D52; border-color: #2F7D52; }
.card-stock {
    background: var(--surface);
    color: var(--text-muted);
    border-color: var(--border);
}
.stock-zero     { background: #FBEAEA !important; color: #C23B3B !important; border-color: #C23B3B !important; }
.stock-positive { background: #E7F3EC !important; color: #2F7D52 !important; border-color: #2F7D52 !important; }
.card-annonce-vide { background: #EAEDF0; color: #8A919E; border-color: #C8CDD5; }

/* --- Barre de recherche --- */
.search-bar-wrap {
    margin: 0 0 16px;
}
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 12px;
    transition: border-color 0.15s ease;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: var(--text-muted);
}
.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--text);
    padding: 11px 0;
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    flex-shrink: 0;
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear:hover { color: var(--accent); }
.search-empty-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 40px 0;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 32px 0 16px;
    flex-wrap: wrap;
}
.pagination-btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.pagination-btn:not(.pagination-disabled):hover { border-color: var(--accent); color: var(--accent); }
.pagination-disabled { opacity: 0.4; cursor: default; }
.pagination-pages { display: flex; gap: 4px; }
.pagination-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.pagination-page:hover { border-color: var(--accent); color: var(--accent); }
.pagination-current {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    cursor: default;
}
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--text-muted);
    font-size: 13px;
}

/* --- Toolbar haut catalogue (recherche + per page) --- */
.pagination-footer {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    width: 100%;
}
.per-page-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.per-page-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.per-page-select {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    font-size: 12px;
    font-family: var(--font-body);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease;
    height: auto;
    line-height: 1.4;
}
.per-page-select:focus { outline: none; border-color: var(--accent); }
.result-count-pager {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* --- Logo cliquable (QR sur le catalogue, retour sur demande.php), sans effet de survol --- */
.header-logo-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: block;
    line-height: 0;
}

/* --- Bouton Espace admin sous le header identity --- */
.admin-access-wrap {
    margin-top: -20px;
    margin-bottom: 16px;
}


/* --- Styles modale QR (réutilisés depuis admin.css) --- */
.modal-qr-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.modal-qr-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 340px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-qr-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.modal-qr-title { font-size: 14px; font-weight: 700; color: #111; margin-bottom: 2px; }
.modal-qr-ref { font-size: 12px; color: #888; }
.modal-qr-close {
    width: 28px; height: 28px;
    border: none; background: none; cursor: pointer;
    color: #888; display: flex; align-items: center; justify-content: center;
}
.modal-qr-close svg { width: 16px; height: 16px; }
.modal-qr-body {
    display: flex; align-items: center; justify-content: center;
    padding: 24px; background: #fff;
}
.modal-qr-body canvas { display: block; width: 256px; height: 256px; }
.modal-qr-footer {
    padding: 14px 20px;
    border-top: 1px solid #eee;
    display: flex; flex-direction: column; gap: 10px;
}
.modal-qr-url { font-size: 11px; color: #888; word-break: break-all; margin: 0; }
