/**
 * Widget de remplissage des palettes - Styles
 *
 * Charte graphique : food-line.fr
 *   - Bleu signature        #0059e4
 *   - Bleu marine           #002d72
 *   - Bleu lavande clair    #e1e6ef
 *   - Vert action           #16a34a
 *   - Blanc pur             #ffffff
 *   - Anthracite neutre     #0f172a
 *
 * Direction : B2B clean. Sans-serif moderne (Manrope), bordures nettes,
 * arrondis modérés, palette froide et lisible alignée sur le site principal.
 *
 * Charge automatiquement par palette-widget.php via wp_enqueue_style().
 */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════════════════════════════════
 * Variables — palette food-line.fr
 * ═══════════════════════════════════════════════════════════════════ */
.pw-root {
    /* Bleus food-line */
    --pw-blue:       #0059e4;
    --pw-blue-hover: #0048bd;
    --pw-blue-dark:  #002d72;
    --pw-blue-soft:  #e1e6ef;
    --pw-blue-bg:    #f0f4fa;

    /* Neutres */
    --pw-ink:        #0f172a;
    --pw-ink-soft:   #334155;
    --pw-mute:       #64748b;
    --pw-mute-soft:  #94a3b8;
    --pw-line:       #e2e8f0;
    --pw-line-soft:  #f1f5f9;
    --pw-paper:      #f8fafc;
    --pw-card:       #ffffff;

    /* Sémantique (statuts) */
    --pw-good:       #16a34a;
    --pw-good-soft:  #dcfce7;
    --pw-warn:       #d97706;
    --pw-warn-soft:  #fef3c7;
    --pw-bad:        #dc2626;
    --pw-bad-soft:   #fee2e2;
    --pw-full:       #059669;
    --pw-full-soft:  #d1fae5;

    /* Accents par section */
    --pw-froid:      var(--pw-blue);
    --pw-froid-soft: var(--pw-blue-soft);
    --pw-sec:        #16a34a;
    --pw-sec-soft:   #dcfce7;

    /* Tokens */
    --pw-radius:     8px;
    --pw-radius-sm:  6px;
    --pw-radius-lg:  10px;
    --pw-shadow:     0 1px 2px rgba(15, 23, 42, 0.05);
    --pw-shadow-md:  0 4px 12px -2px rgba(15, 23, 42, 0.08);
    --pw-shadow-lg:  0 8px 24px -8px rgba(0, 89, 228, 0.18);

    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    color: var(--pw-ink);
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    transition: opacity .25s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.pw-root.pw-loading { opacity: .55; pointer-events: none; }
.pw-root.pw-loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 28px; height: 28px;
    margin: -14px 0 0 -14px;
    border: 2.5px solid var(--pw-line);
    border-top-color: var(--pw-blue);
    border-radius: 50%;
    animation: pw-spin .65s linear infinite;
    z-index: 10;
}
@keyframes pw-spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════════
 * État vide
 * ═══════════════════════════════════════════════════════════════════ */
.pw-empty {
    text-align: center;
    padding: 48px 24px;
    background: var(--pw-card);
    border: 1px solid var(--pw-line);
    border-radius: var(--pw-radius-lg);
    color: var(--pw-mute);
}
.pw-empty-icon {
    display: block;
    font-size: 28px;
    margin-bottom: 12px;
    color: var(--pw-mute-soft);
}
.pw-empty p {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
    color: var(--pw-ink-soft);
}

/* ═══════════════════════════════════════════════════════════════════════
 * SECTION (vue unifiée Froid + Sec)
 * ═══════════════════════════════════════════════════════════════════ */
.pw-section {
    margin-bottom: 40px;
    --pw-accent: var(--pw-blue);
    --pw-accent-soft: var(--pw-blue-soft);
}
.pw-section-mixed {
    --pw-accent: var(--pw-blue);
    --pw-accent-soft: var(--pw-blue-soft);
}
/* Conservées pour rétro-compat ; non utilisées par le rendu unifié */
.pw-section-froid {
    --pw-accent: var(--pw-blue);
    --pw-accent-soft: var(--pw-blue-soft);
}
.pw-section-sec {
    --pw-accent: #16a34a;
    --pw-accent-soft: var(--pw-sec-soft);
}

.pw-section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--pw-line);
    flex-wrap: wrap;
}

.pw-section-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}
.pw-section-icon {
    font-size: 16px;
    width: 38px; height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pw-accent-soft);
    color: var(--pw-accent);
    border-radius: var(--pw-radius);
    flex-shrink: 0;
}
.pw-section-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pw-section-title {
    font-family: 'Manrope', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--pw-ink);
    letter-spacing: -0.015em;
    line-height: 1.2;
}
.pw-section-sub {
    font-size: 12.5px;
    color: var(--pw-mute);
    font-weight: 500;
}

.pw-section-meta-right {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--pw-mute);
    letter-spacing: 0.04em;
    flex-wrap: wrap;
}
.pw-section-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}
.pw-section-stat strong {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    color: var(--pw-ink);
    font-size: 14px;
    margin-right: 4px;
    letter-spacing: -0.01em;
}
/* Icône inline (Froid/Sec) dans le récap droit — ANNULE la version 38×38 */
.pw-section-meta-right .pw-section-icon {
    width: auto; height: auto;
    background: transparent;
    border-radius: 0;
    padding: 0;
    font-size: 12px;
    align-self: center;
}
.pw-section-meta-right .pw-tag-froid { color: var(--pw-blue); }
.pw-section-meta-right .pw-tag-sec   { color: #16a34a; }
.pw-section-cartons {
    opacity: 0.7;
    font-size: 10.5px;
    margin-left: 2px;
}
.pw-section-sep { opacity: 0.4; }

/* ═══════════════════════════════════════════════════════════════════════
 * SCROLL HORIZONTAL — alignement à gauche (Palette 01 à gauche, suivantes à droite)
 * ═══════════════════════════════════════════════════════════════════ */
.pw-scroll-wrap {
    position: relative;
    margin: 0 -4px;
    padding-bottom: 4px;
}

.pw-scroll-wrap::before,
.pw-scroll-wrap::after {
    content: '';
    position: absolute;
    top: 0; bottom: 18px;
    width: 36px;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity .25s ease;
}
.pw-scroll-wrap::before {
    left: 0;
    background: linear-gradient(90deg, var(--pw-paper) 0%, transparent 100%);
}
.pw-scroll-wrap::after {
    right: 0;
    background: linear-gradient(-90deg, var(--pw-paper) 0%, transparent 100%);
}
/* Fade droit visible quand il reste à scroller vers la droite */
.pw-scroll-wrap.pw-has-overflow.pw-not-end::after { opacity: 1; }
/* Fade gauche visible quand l'utilisateur a déjà scrollé un peu (overflow) */
.pw-scroll-wrap.pw-has-overflow.pw-scrolled::before { opacity: 1; }

.pw-row {
    list-style: none;
    margin: 0;
    padding: 4px 4px 16px;
    display: flex;
    /* Alignement naturel : la première palette est à gauche */
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 4px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--pw-mute-soft) transparent;
}
.pw-row::-webkit-scrollbar { height: 6px; }
.pw-row::-webkit-scrollbar-track { background: transparent; }
.pw-row::-webkit-scrollbar-thumb {
    background: var(--pw-mute-soft);
    border-radius: 3px;
}
.pw-row::-webkit-scrollbar-thumb:hover { background: var(--pw-mute); }

/* Indicateur "Faire défiler →" */
.pw-scroll-hint {
    position: absolute;
    top: -28px; right: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'DM Mono', monospace;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pw-blue);
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}
.pw-scroll-wrap.pw-has-overflow.pw-not-end .pw-scroll-hint { opacity: 1; }
.pw-scroll-hint-arrow {
    display: inline-block;
    /* Flèche vers la droite (sens du scroll naturel) */
    animation: pw-scroll-arrow-right 1.6s ease-in-out infinite;
}
@keyframes pw-scroll-arrow-right {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════════════════
 * CARTE PALETTE
 * ═══════════════════════════════════════════════════════════════════ */
.pw-card {
    flex: 0 0 320px;
    width: 320px;
    /* Snap au début (scroll naturel : la 1re carte est à gauche) */
    scroll-snap-align: start;
    list-style: none;

    background: var(--pw-card);
    /* État "hover" appliqué par défaut : bordure + ombre prononcées */
    border: 1px solid var(--pw-mute-soft);
    border-radius: var(--pw-radius-lg);
    padding: 0 20px 16px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--pw-shadow-lg);

    display: flex;
    flex-direction: column;

    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity .4s ease,
        transform .4s cubic-bezier(.34,1.3,.64,1),
        box-shadow .25s ease,
        border-color .25s ease;
}
.pw-card.pw-vis { padding:10px; opacity: 1; transform: translateY(0); }
/* Léger renforcement au vrai survol (optionnel — peut être supprimé) */
.pw-card:hover {
    border-color: var(--pw-ink-soft);
}

/* Bordure colorée selon le type pour les cartes pleines
   (l'info "type" est désormais sur la carte, pas la section) */
.pw-card-type-froid[data-status="full"] {
    border-color: var(--pw-blue);
    border-width: 1.5px;
}
.pw-card-type-sec[data-status="full"] {
    border-color: #16a34a;
    border-width: 1.5px;
}

/* Bande latérale colorée (composition produits) ────────────── */
.pw-card-spine {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    display: flex;
    flex-direction: column-reverse;
    background: var(--pw-line-soft);
    overflow: hidden;
}
.pw-spine-seg {
    width: 100%;
    transition: height .6s cubic-bezier(.22,1,.36,1);
}

/* En-tête : numéro de palette + badges (type + statut) ─────── */
.pw-card-head {
    padding: 18px 0 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--pw-line);
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.pw-num-block {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.pw-num-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--pw-mute);
}
.pw-num-value {
    font-family: 'Manrope', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
    color: var(--pw-ink);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

/* Container des badges (type + statut), empilés en colonne à droite */
.pw-card-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
}

/* Badge de type Froid / Sec ─────────────────────────────────── */
.pw-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
    border: 1px solid;
    white-space: nowrap;
}
.pw-type-badge .pw-type-icon {
    font-size: 11px;
    line-height: 1;
    font-family: 'Manrope', sans-serif;
}
.pw-type-badge-froid {
    color: var(--pw-blue);
    background: var(--pw-blue-soft);
    border-color: color-mix(in srgb, var(--pw-blue) 20%, transparent);
}
.pw-type-badge-sec {
    color: #15803d;
    background: var(--pw-sec-soft);
    border-color: color-mix(in srgb, #16a34a 25%, transparent);
}

.pw-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.005em;
    border: 1px solid;
    white-space: nowrap;
    flex-shrink: 0;
}
.pw-status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.pw-status-full    { color: #047857; background: var(--pw-full-soft); border-color: #a7f3d0; }
.pw-status-good    { color: #15803d; background: var(--pw-good-soft); border-color: #bbf7d0; }
.pw-status-partial { color: #b45309; background: var(--pw-warn-soft); border-color: #fde68a; }
.pw-status-low     { color: #b91c1c; background: var(--pw-bad-soft);  border-color: #fecaca; }

/* Visuel SVG isométrique ─────────────────────────────────── */
.pw-visual {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin: 5px;
    background: linear-gradient(180deg, transparent 0%, var(--pw-paper) 100%);
    border-radius: var(--pw-radius-sm);
    padding: 4px;
    min-height: 150px;
    position: relative;
}
.pw-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center 75%,
        color-mix(in srgb, var(--pw-accent) 6%, transparent) 0%,
        transparent 65%);
    pointer-events: none;
    border-radius: inherit;
}
.pw-visual svg {
    width: 100%;
    max-width: 240px;
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.10));
    position: relative;
    z-index: 1;
}

/* Stats : 3 colonnes ─────────────────────────────────────── */
.pw-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    margin: 12px 0 10px;
    padding: 10px 4px;
    background: var(--pw-paper);
    border-radius: var(--pw-radius-sm);
}
.pw-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    position: relative;
}
.pw-stat + .pw-stat::before {
    content: '';
    position: absolute;
    left: 0; top: 18%;
    bottom: 18%;
    width: 1px;
    background: var(--pw-line);
}
.pw-stat-lbl {
    font-family: 'DM Mono', monospace;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pw-mute);
    margin: 0;
    order: 2;
}
.pw-stat-val {
    font-family: 'Manrope', sans-serif;
    font-size: 19px;
    font-weight: 700;
    line-height: 1;
    color: var(--pw-ink);
    margin: 0;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    order: 1;
}
.pw-stat-val small {
    font-size: 11px;
    font-weight: 500;
    color: var(--pw-mute);
    margin-left: 1px;
}
.pw-stat-pct .pw-stat-val { color: var(--pw-accent); }

/* Jauge ─────────────────────────────────────────────────── */
.pw-gauge { margin: 0 0 14px; }
.pw-gauge-track {
    position: relative;
    background: var(--pw-line);
    border-radius: 100px;
    height: 6px;
    overflow: hidden;
}
.pw-gauge-bar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0;
    border-radius: 100px;
    transition: width 1.1s cubic-bezier(.22,1,.36,1);
    z-index: 1;
}
.pw-gauge-tick {
    position: absolute;
    top: 0; bottom: 0;
    width: 1px;
    background: var(--pw-card);
    opacity: 0.8;
    z-index: 2;
}
.pw-gauge-full    { background: linear-gradient(90deg, #10b981, #047857); }
.pw-gauge-good    { background: linear-gradient(90deg, #22c55e, #15803d); }
.pw-gauge-partial { background: linear-gradient(90deg, #f59e0b, #b45309); }
.pw-gauge-low     { background: linear-gradient(90deg, #ef4444, #b91c1c); }

/* Liste produits ────────────────────────────────────────── */
.pw-produits {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.pw-produit-row {
    display: grid;
    grid-template-columns: 10px 1fr 14px;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: var(--pw-radius-sm);
    border: 1px solid color-mix(in srgb, var(--pw-border) 25%, var(--pw-line));
    background: color-mix(in srgb, var(--pw-bg) 40%, var(--pw-card));
    color: var(--pw-text);
    text-decoration: none;
    transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.pw-produit-row:hover {
    transform: translateX(3px);
    background: var(--pw-bg);
    border-color: var(--pw-border);
    box-shadow: var(--pw-shadow);
}
.pw-produit-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--pw-border);
    flex-shrink: 0;
}
.pw-produit-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.pw-produit-line1 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.pw-produit-line2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.pw-pname {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pw-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    letter-spacing: -0.005em;
}
.pw-pqty {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--pw-text);
    opacity: 0.8;
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.pw-pqty small {
    font-size: 9px;
    opacity: 0.7;
    margin-left: 1px;
}
.pw-pkg {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--pw-text);
    opacity: 0.65;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.pw-pkg-empty::before { content: '\2014'; opacity: 0.3; }
.pw-pkg .woocommerce-Price-amount { font-family: inherit; }
.pw-pprix {
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--pw-text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.015em;
}
.pw-pprix .woocommerce-Price-amount { font-family: inherit; }
.pw-arrow {
    font-size: 13px;
    color: var(--pw-text);
    opacity: 0.3;
    transition: opacity .15s, transform .15s;
    align-self: center;
}
.pw-produit-row:hover .pw-arrow { opacity: 0.9; transform: translateX(2px); }

/* Footer total ──────────────────────────────────────────── */
.pw-card-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 12px;
    border-top: 1px solid var(--pw-line);
    margin-top: auto;
}
.pw-total-lbl {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pw-mute);
}
.pw-total-val {
    font-family: 'Manrope', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--pw-blue);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.pw-total-val .woocommerce-Price-amount { font-family: inherit; }

/* ═══════════════════════════════════════════════════════════════════════
 * RESPONSIVE
 * ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .pw-section-title { font-size: 17px; }
    .pw-num-value { font-size: 22px; }
    .pw-card { flex-basis: 290px; width: 290px; padding: 0 18px 16px; }
    .pw-stat-val { font-size: 17px; }
    .pw-type-badge { font-size: 9.5px; padding: 2px 6px; }
}

@media (max-width: 480px) {
    .pw-section-meta-right { font-size: 10px; }
    .pw-card { flex-basis: 270px; width: 270px; }
}

/* Réduit l'animation pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
    .pw-card, .pw-gauge-bar, .pw-scroll-hint-arrow, .pw-spine-seg {
        transition: none !important;
        animation: none !important;
    }
    .pw-row { scroll-behavior: auto; }
}
