/* ==========================================================================
   STYLE AFFICHE - VEGAPP V2.2
   ==========================================================================
   1. Configuration & Conteneur (Papier & Canvas)
   2. Mode Impression (Print)
   3. Éléments Communs (Textes, Images, Logos)
   4. Module : Conseil (Infos & Icônes)
   5. Module : Prix (Végétal & Manufacturé)
   6. Module : Promo (Bandeaux, Lots, Remises)
   7. Module : Textes & Horaires
   8. Utilitaires & Helpers
   ========================================================================== */

/* --- 1. CONFIGURATION & CONTENEUR --- */

#affiche-wrapper {
    background-color: #ffffff; /* LE PAPIER EST BLANC */
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    width: min-content; 
    height: min-content;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); /* Ombre portée du papier */
    position: absolute;
    top: 0; 
    left: 0;
    transform-origin: center center;
}

#affiche {
    width: 794px; 
    height: 1123px; 
    background: white;
    position: relative;
    flex-shrink: 0;
    overflow: hidden; 
    display: flex;
    flex-direction: column; 
    align-items: center;
    font-size: 14pt;
    box-shadow: none; /* L'ombre est sur le wrapper */
    border: none !important;

    /* Variables CSS par défaut (Surchargées par JS selon config) */
    --font-primary: 'Poppins', sans-serif; 
    --font-primary-weight: 700;
    --font-secondary: 'Open Sans', sans-serif; 
    --font-secondary-weight: 400;
    --font-price: 'Poppins', sans-serif;
    
    --color-primary: #1B5E20; 
    --color-text: #333333; 
    --color-promo: #D75000;
    --color-latin: #ffffff;
    --color-promo-title: #ffffff;
    
    --bg-affiche: #ffffff;
    --bg-promo: #ffffff;
}

#affiche.landscape {
    width: 1123px; 
    height: 794px;
}

/* Calque de bordure indépendant (Injecté par JS) */
.affiche-border-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 500;
    box-sizing: border-box;
}

#safe-margin-overlay { display: none !important; }
.exporting #affiche { box-shadow: none !important; }


/* --- 2. MODE IMPRESSION (PRINT) --- */

@media print {
    #affiche { box-shadow: none !important; }
    #loginModal, .config-panel, .input-panel, #pdfBtnGroup, .modal-overlay, #settingsPanel, .app-header { display: none !important; }
    
    body, .container, .main-content, .preview-wrapper, .printContainer, .preview-area-refined { 
        background: none !important; 
        margin: 0 !important; 
        padding: 0 !important; 
        border: none !important; 
        height: auto !important; 
        overflow: visible !important; 
    }
    
    #affiche, #affiche * { 
        visibility: visible !important; 
        print-color-adjust: exact !important; 
        -webkit-print-color-adjust: exact !important; 
    }
    
    #affiche { 
        position: relative !important; 
        top: 0 !important; 
        left: 0 !important; 
        margin: 0 !important; 
        padding: 0 !important; 
        transform: none !important; 
        page-break-after: always; 
    }
    
    @page { margin: 0; }
}


/* --- 3. ÉLÉMENTS COMMUNS --- */

/* Textes Principaux */
.latin-name {
    font-family: var(--font-secondary);
    font-weight: 600;
    padding: 0.3em 0.6em;
    text-align: center;
    width: 100%;
    font-size: 1.7em;
    height: 1.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    background-color: var(--color-primary);
    color: var(--color-latin);
}

.common-name {
    font-family: var(--font-primary);
    font-weight: var(--font-primary-weight);
    font-size: 2.8em;
    text-align: center;
    line-height: 1.1;
    min-height: 1.5em;
    word-break: break-word;
    display: flex;
    padding: 0 0.5em;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    color: var(--color-text);
}

.affiche:not(.non-vegetal) .common-name { height: 3em; }

/* Images & Logos */
.image-wrapper {
    width: 100%;
    height: 70mm;
    position: relative;
    overflow: hidden;
    flex-grow: 1;
    display: block;
}

.plant-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.style-logo {
    position: absolute;
    top: 1.5em;
    width: 7em;
    border-radius: 5px;
    z-index: 10;
    transition: transform 0.2s;
    transform-origin: top right;
}

.style-logo-filigrane {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 20em;
    z-index: 1;
    opacity: 0.2;
    border-radius: 5px;
}

/* Headers Non-Végétal (Manufacturé) */
.non-vegetal-header {
    width: 100%;
    padding: 1em;
    text-align: center;
    position: relative;
    flex-shrink: 0;
    background-color: var(--color-primary);
    display: flex;
    justify-content: flex-end; /* Défaut */
}

.affiche.landscape .non-vegetal-header { padding: 0.5em; }

.style-logo-nv {
    height: 6em;
    width: auto;
    filter: brightness(0) invert(1);
}

.affiche.landscape .style-logo-nv { height: 4em; }

/* Conteneurs de Contenu */
.vegetal-content, .non-vegetal-content {
    flex-grow: 1;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    align-content: space-between;
    padding: 1em;
    flex-direction: column;
}

.non-vegetal-content { padding: 2em; }
.affiche.landscape .non-vegetal-content { padding: 0.5em; }


/* --- 4. MODULE : CONSEIL --- */

/* Type: Détail (Liste) */
.type-conseil #infoGrid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 0.5em;
    grid-gap: 0.3em;
    flex-shrink: 0;
    width: 100%;
}

.type-conseil .info-item {
    display: flex;
    padding: 0.2em;
    gap: 0.05em;
    flex-direction: column;
    /* Styles dynamiques (Border/Shadow) injectés par JS */
}

.type-conseil .info-icon {
    width: 2.2em;
    height: 2.2em;
}

.info-details {
    display: flex;
    flex: 1;
    justify-content: flex-start;
    flex-direction: row;
    text-align: center;
    align-items: center;
}

.info-header {
    margin-bottom: 0em;
    align-content: center;
    text-align: left;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.info-header hr {
    height: 4px;
    border: none;
    border-radius: 2px;
    margin: 2px 0 0 0.5em;
    width: 80%;
}

.info-header span {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.9em;
    margin-left: 0.5em;
    text-transform: uppercase;
}

.type-conseil .info-text {
    font-family: var(--font-secondary);
    font-weight: 400;
    font-size: 0.85em;
    line-height: 1.2;
    flex-grow: 1;
    padding: 0.2em 0.5em;
    text-align: left;
}

/* Type: Icônes (Grid) */
.poster-grid-icones {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 0.3em;
    padding: 0.5em;
    width: 100%;
    flex-grow: 1;
    align-content: space-around;
}

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 12.5%;
    min-width: 3.5em;
    padding: 0.2em;
}

.icon-item-img {
    width: 100%;
    max-width: 5em;
    height: auto;
    aspect-ratio: 1/1;
    object-fit: contain;
    margin-bottom: 0.5em;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.1));
}

.icon-item-text {
    font-family: var(--font-secondary);
    font-size: 0.6em;
    line-height: 1.2;
    color: var(--color-text);
    margin: 0;
    word-break: break-word;
}

.resume-text {
    font-family: var(--font-secondary);
    font-style: italic;
    text-align: center;
    padding: 1em;
    font-size: 1.1em;
    color: var(--color-text);
}

/* Ajustements grille pour autres modes */
.type-promo .poster-grid-icones, 
.type-prix .poster-grid-icones {
    gap: 0.5em;
}

.type-promo .icon-item, 
.type-prix .icon-item {
    width: 10%;
}


/* --- 5. MODULE : PRIX --- */

.price-section {
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1em;
}

.plant-size {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 1.8em;
    text-align: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5em;
    margin-bottom: 0.5em;
    width: 90%;
    color: var(--color-text);
}

.plant-price {
    font-family: var(--font-primary);
    font-weight: 800;
    text-align: center;
    line-height: 1;
    font-size: 7em;
    margin-top: 0.1em;
    color: var(--color-text);
}

.non-vegetal-price-large { font-size: 11em; }

.price-per-unit, 
.product-info-condensed, 
.product-info-complementaire {
    font-family: var(--font-secondary);
    text-align: center;
    color: var(--color-text);
}

.price-per-unit {
    font-weight: 700;
    font-size: 2.2em;
    margin-top: 0.5em;
}

.product-info-condensed {
    font-weight: 600;
    font-size: 1.6em;
    margin: 0.5em auto;
}

.product-info-complementaire {
    font-size: 1.8em;
    opacity: 0.8;
}

/* Formatage Prix (Centimes) */
.prix-harmonise-int { font-size: 1em; }
.prix-harmonise-cents {
    font-size: 0.6em;
    vertical-align: top;
    margin-left: 2px;
}


/* --- 6. MODULE : PROMO --- */

.wrapper-promo-section {
    padding: 1em;
    width: 100%;
    display: flex;
    min-height: 25em;
    flex-grow: 1;
}

.promo-section {
    position: relative;
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    align-content: space-between;
    padding: 1em;
    text-align: center;
    background-color: var(--bg-promo);
    /* Border géré par JS via getBorderStyle('promo') */
}

.promo-title {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: 2.5em;
    text-transform: uppercase;
    padding: 0.1em 0.5em;
    border-radius: 5px;
    position: relative;
    margin: 0;
    background-color: var(--color-promo);
    color: var(--color-promo-title);
}

.promo-price-main, .promo-price-new {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: 6em;
    line-height: 1;
    margin: 0.1em 0;
    color: var(--color-promo);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.promo-price-old {
    font-family: var(--font-secondary);
    font-size: 3em;
    font-weight: 300;
    text-decoration: line-through !important;
    opacity: 0.8;
    color: var(--color-text);
}

.promo-remise-percent {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: 7em;
    line-height: 1;
    margin-top: 0.2em;
    color: var(--color-promo);
}

.promo-remise-details {
    display: flex;
    align-items: center;
    gap: 1em;
    justify-content: center;
    flex-wrap: wrap;
}

.promo-offert-main {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 4em;
    line-height: 1.1;
    color: var(--color-promo);
}
.promo-offert-main span { font-size: 1.2em; }

.promo-size, 
.promo-disclaimer, 
.promo-price-sub, 
.promo-lot-details {
    font-family: var(--font-secondary);
    color: var(--color-text);
}

.promo-size {
    font-weight: 700;
    font-size: 1.8em;
    margin-top: 0.5em;
}

.promo-lot-details {
    font-weight: 600;
    font-size: 3em;
    margin-top: 0;
}

.promo-price-sub {
    font-size: 1em;
    opacity: 0.9;
    margin-top: 0em;
}


/* --- 7. MODULE : TEXTES & HORAIRES --- */

.simpletexte {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 4em;
    text-align: center;
    line-height: 1.2;
    margin: auto;
    color: var(--color-text);
}

.advanced-text-content {
    width: 100%;
    height: 100%;
    font-family: var(--font-secondary);
    font-size: 1.5em;
    text-align: left;
    overflow: hidden;
    color: var(--color-text);
}
.advanced-text-content h1, 
.advanced-text-content h2 { 
    font-family: var(--font-primary); 
}

/* Horaires */
.horaires-container, 
.horaires-exceptionnel {
    font-family: var(--font-primary);
    width: 100%;
    text-align: center;
    margin: auto;
    color: var(--color-text);
}

.horaires-titre {
    font-size: 3.5em;
    font-weight: 900;
    border-bottom: 0.1em solid;
    display: inline-block;
    border-color: var(--color-text);
}

.horaires-ligne {
    font-size: 2.2em;
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5em;
    line-height: 2em;
}

.horaires-heures {
    font-weight: 800;
    color: var(--color-primary);
}

.horaires-ex-titre {
    font-size: 3em;
    font-weight: 600;
    border-bottom-color: var(--color-text);
}

.horaires-ex-jour {
    font-size: 5em;
    font-weight: 900;
    margin: 0.2em 0;
}

.horaires-ex-sub {
    font-size: 2em;
    font-family: var(--font-secondary);
}

/* --- FORMATS PERSONNALISÉS --- */

/* Le format custom écrase les dimensions fixes A4/A5 */
#affiche.format-custom {
    min-width: 0 !important; 
    min-height: 0 !important;
    width: auto; 
    height: auto;
    margin: 0 auto; /* Centré dans le wrapper */
}

/* Guide de sécurité (Zone sûre pour le texte) */
.safe-zone-guide {
    position: absolute;
    border: 1px dashed rgba(255, 0, 0, 0.4) !important;
    background: rgba(255, 0, 0, 0.02);
    pointer-events: none;
    z-index: 1000;
}

/* On cache le guide lors de l'export ou preview finale */
.exporting .safe-zone-guide,
.preview-mode .safe-zone-guide {
    display: none !important;
}

/* --- 8. UTILITAIRES & HELPERS --- */

/* Options Visuelles Globales */
.affiche.grayscale-icons .icon-item-img, 
.affiche.grayscale-icons .info-icon {
    filter: grayscale(100%);
    opacity: 0.7;
}

.affiche.hide-latin .latin-name { display: none !important; }

/* Correction Centimes Alignés */
.affiche.cents-aligned .plant-price .prix-harmonise-cents,
.affiche.cents-aligned .promo-price-new .prix-harmonise-cents,
.affiche.cents-aligned .tarif-item-price .prix-harmonise-cents {
    font-size: 1em !important; 
    vertical-align: baseline !important;
    margin-left: 0 !important;
}

/* Gestion Dynamique des Tailles (Override via JS) */
.plant-size { --base-size: 2.5em; }
.plant-price { --base-size: 7em; }
.common-name { --base-size: 2.8em; }
.product-info-condensed { --base-size: 1.6em; }
.product-info-complementaire { --base-size: 1.8em; }
.price-per-unit { --base-size: 2.2em; }
.promo-size { --base-size: 1.8em; }
.simpletexte { --base-size: 4em; }
.horaires-titre { --base-size: 3.5em; }
.horaires-jours { --base-size: 1.5em; }
.horaires-heures { --base-size: 2.2em; }
.non-vegetal-price-large { --base-size: 11em; }
.promo-price-main { --base-size: 6em; }
.promo-remise-percent { --base-size: 7em; }
.promo-price-new { --base-size: 6em; }
.promo-price-old { --base-size: 3em; }
.promo-lot-details { --base-size: 3em; }
.horaires-ex-titre { --base-size: 3em; }
.horaires-ex-jour { --base-size: 5em; }
.horaires-ex-sub { --base-size: 2em; }

/* Application des deltas (taille +- via UI) */
.plant-size, 
.plant-price, 
.common-name, 
.product-info-condensed, 
.product-info-complementaire, 
.price-per-unit,
.promo-size,
.simpletexte,
.horaires-titre,
.horaires-jours,
.horaires-heures,
.promo-price-main,
.promo-remise-percent,
.promo-price-new,
.promo-price-old,
.promo-lot-details,
.horaires-ex-titre,
.horaires-ex-jour,
.horaires-ex-sub {
    font-size: calc(var(--base-size) + var(--font-size-delta, 0pt)) !important;
}

/* Helpers Constructeur (Injections de style inline) */
[style*="--custom-scale"] { font-size: calc(var(--base-size, 1em) * var(--custom-scale, 1)) !important; }
[style*="--custom-pad-top"] { padding-top: var(--custom-pad-top) !important; }
[style*="--custom-pad-bot"] { padding-bottom: var(--custom-pad-bot) !important; }
[style*="--custom-weight"] { font-weight: var(--custom-weight) !important; }