/* ═══════════════════════════════════════════════════════════════════
   MARQUEUR CHAMPS OBLIGATOIRES — astérisque rouge sur les labels
   Django admin ajoute la classe .required sur les <label> des champs
   required=True. On l'exploite pour marquer visuellement le champ.
   Règle très large avec haute spécificité pour couvrir tous les
   templates admin (change_form, tabular_inline, stacked_inline...).
   ═══════════════════════════════════════════════════════════════════ */
body #content label.required::after,
body #content .form-row label.required::after,
body #content .form-row .required label::after,
body #content .aligned label.required::after,
body #content .required > label::after,
body #content th.required::after,
body #content label[class*="required"]::after {
    content: " *" !important;
    color: #d9534f !important;
    font-weight: 800 !important;
    font-size: 15px !important;
    margin-left: 2px !important;
}

/* Hint discret dans le header du formulaire */
body.change-form #content-main > h1::after,
body.add-form #content-main > h1::after,
.change-form .content-title::after,
.add-form .content-title::after {
    content: " (les champs marqués d'une * sont obligatoires)";
    font-size: 12px;
    font-weight: normal;
    color: #999;
    margin-left: 10px;
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════
   FIX : page tronquée à droite (retour cliente Agathe #1)
   Le body Django admin déborde à droite sur certains écrans (100% zoom)
   parce que le contenu principal a une largeur fixée. On force le
   contenu à respecter la largeur de l'écran et à ne jamais dépasser.
   ═══════════════════════════════════════════════════════════════════ */
html, body { overflow-x: hidden !important; }
#container { max-width: 100% !important; }
#content-main, #content, .main {
    max-width: 100% !important;
    overflow-x: auto !important;
}
/* Tables larges → scroll horizontal LOCAL au tableau, pas à la page */
#content table {
    max-width: 100% !important;
}
#result_list, .results {
    max-width: 100% !important;
    overflow-x: auto !important;
}

/* Wrapper global centré */
.pepi-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 10px 40px;
}

/* Tablette paysage (≤1400px) : pleine largeur pour matcher le breakpoint
   global de base_site.html. Évite le vide à droite sur iPad Pro paysage. */
@media (max-width: 1400px) {
    .pepi-wrapper,
    .pepi-page-title {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Carte blanche autour du contenu */
.pepi-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.04);
    border: 1px solid #e3e3e3;
    padding: 24px 26px 30px;
}

/* Titre principal */
.pepi-page-title {
    margin: 15px auto 5px;
    max-width: 1100px;
    font-size: 24px;
    font-weight: 600;
    color: #1f2d27;
}

/* Alléger les fieldsets */
.pepi-card fieldset.module {
    border-radius: 10px;
    border-color: #e1e1e1;
    margin-bottom: 18px;
}

/* Bouton Enregistrer en vert */
.pepi-card .submit-row input.default {
    background: #3f6e57;
    border-color: #3f6e57;
}

.pepi-card .submit-row input.default:hover {
    background: #335745;
    border-color: #335745;
}

/* Fond général gris clair sur la page PepiniereInfo */
body.change-form.app-core.model-pepiniereinfo {
    background-color: #f5f6f7;
}

/* Style uniforme pour tous les titres de section */
.pepi-card h2,
fieldset.module h2 {
    font-family: "Inter", "Segoe UI", Roboto, sans-serif !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    color: #2d5442 !important;
    padding: 10px 14px !important;
    background: #e7f0ec !important;
    border-left: 4px solid #3f6e57 !important;
    border-radius: 6px !important;
    margin-top: 20px !important;
}

/* Uniformisation des titres (tous) */
fieldset.module h2,
.module h2,
.inline-group h2,
.pepi-card h2,
.collapse h2 {
    font-family: "Inter", "Segoe UI", Roboto, sans-serif !important;

    font-size: 20px !important;
    font-weight: 600 !important;

    color: #2d5442 !important;

    background: #e7f0ec !important;
    border-left: 4px solid #3f6e57 !important;
    border-radius: 6px !important;
    padding: 10px 14px !important;

    text-transform: none !important;

    margin-top: 22px !important;
    margin-bottom: 10px !important;
}

/* =================================================================== */
/* LISTE DES PLANTES                                                   */
/* =================================================================== */

body.change-list.app-gestion.model-plante #content {
    background: #f3f4f6;
}

body.change-list.app-gestion.model-plante .plantes-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

body.change-list.app-gestion.model-plante .plantes-banner {
    background: #3f6e57;
    color: #ffffff;
    padding: 14px 26px;
    text-align: left;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

body.change-list.app-gestion.model-plante .plantes-banner-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

body.change-list.app-gestion.model-plante .plantes-banner-icon {
    font-size: 26px;
    line-height: 1;
}

body.change-list.app-gestion.model-plante .plantes-banner-text-main {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.06em;
    margin: 0;
    text-transform: uppercase;
}

body.change-list.app-gestion.model-plante .plantes-banner-text-sub {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

body.change-list.app-gestion.model-plante .plantes-banner-right {
    font-size: 12px;
    opacity: 0.95;
    text-align: right;
}

body.change-list.app-gestion.model-plante .plantes-actions-bar {
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
}

body.change-list.app-gestion.model-plante #content-main .object-tools {
    position: relative;
    float: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-start;
    max-width: none;
    width: auto;
    flex-wrap: wrap;
}

body.change-list.app-gestion.model-plante #content-main .object-tools li {
    list-style: none;
    margin: 0;
    padding: 0;
}

body.change-list.app-gestion.model-plante #content-main .object-tools form {
    margin: 0;
}

body.change-list.app-gestion.model-plante #content-main .object-tools .addlink,
body.change-list.app-gestion.model-plante #content-main .object-tools .importlink,
body.change-list.app-gestion.model-plante #content-main .object-tools .exportlink {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

/* style commun pour les trois boutons */
body.change-list.app-gestion.model-plante .plantes-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 999px;
    background: #3f6e57;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border: none;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.12);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

body.change-list.app-gestion.model-plante .plantes-btn span.icon {
    font-size: 15px;
    line-height: 1;
}

body.change-list.app-gestion.model-plante .plantes-btn:hover {
    background: #2f5543;
    box-shadow: 0 6px 16px rgba(34, 66, 51, 0.26);
    transform: translateY(-1px);
}

body.change-list.app-gestion.model-plante .plantes-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

body.change-list.app-gestion.model-plante #changelist {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    padding: 6px 6px 12px 6px;
}

body.change-list.app-gestion.model-plante #changelist .results {
    border-radius: 8px;
    overflow: hidden;
}

body.change-list.app-gestion.model-plante #changelist-filter {
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

@media (max-width: 768px) {
    body.change-list.app-gestion.model-plante .plantes-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    body.change-list.app-gestion.model-plante .plantes-banner-right {
        text-align: left;
    }
}

/* =================================================================== */
/* Cartes pour le formulaire Client                                    */
/* =================================================================== */

.client-section {
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 60%);
    border: 1.5px solid #d1e7dd;
    border-radius: 16px;
    padding: 1.4em 1.6em;
    margin-bottom: 1.6em;
    box-shadow: 0 3px 12px rgba(20, 20, 20, 0.05);
}

.client-section h2 {
    font-size: 1.05em !important;
    font-weight: 700 !important;
    color: #256029 !important;
    background: transparent !important;
    border-left: none !important;
    border-radius: 0 !important;
    padding: 0 0 0.6em 0 !important;
    margin: 0 0 0.6em 0 !important;
    display: flex;
    align-items: center;
    gap: 0.45em;
}

.client-section input,
.client-section select,
.client-section textarea {
    border-radius: 8px !important;
}

/* Bloc livraison grisé quand "même adresse" est coché */
.client-livraison.client-disabled {
    opacity: 0.45;
    filter: grayscale(.6);
}


/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE GLOBAL — retour Gaëtan 28/07/2026
   Sur écrans étroits (fenêtre réduite, laptop 13", tablette paysage),
   les tableaux admin débordaient à droite SANS scrollbar → user ne
   pouvait pas voir les colonnes de droite.
   Cette section rend TOUT l'admin utilisable jusqu'à ~700px de large :
     - Scroll horizontal LOCAL sur chaque tableau qui déborde
     - Sidebar plus compacte sous 1200px
     - Paddings réduits sous 900px
   ═══════════════════════════════════════════════════════════════════ */

/* 1) Tableaux : scroll horizontal AUTOMATIQUE quand ça déborde.
   On enveloppe le tableau visible dans un container scrollable pour
   que l'utilisateur voie une petite barre en bas des tableaux larges. */
#content .results,
#content #result_list_wrapper,
#content .module .results,
#content-main .results {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;  /* smooth scroll sur iPad */
    max-width: 100% !important;
}

/* Le tableau lui-même garde sa largeur naturelle (pas forcé à 100%)
   sinon les colonnes se compressent en illisible.
   `min-width: max-content` force le tableau à rester lisible ET
   à déclencher le scroll parent. */
#content .results table,
#content #result_list,
#content-main table.results,
.change-list #result_list {
    min-width: max-content !important;
    width: auto !important;
}

/* Colonnes : évite qu'un email long casse le layout */
#content .results td,
#content .results th {
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cellule email/URL : autorise le retour à la ligne */
#content .results td.field-email,
#content .results td.field-url {
    white-space: normal;
}


/* 2) DASHBOARD : force les cartes à passer en 1 colonne dès 1200px
   (avant c'était 900px mais avec la sidebar de 260px, un ecran
   de 1300px n'a que 1040px utiles pour le dashboard). */
@media (max-width: 1200px) {
    .gaia-wrap {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 4px 2px 12px !important;
    }
    .gaia-wrap .one-col,
    .gaia-wrap .two-col {
        grid-column: 1 / -1 !important;
    }
    .gaia-title {
        font-size: 20px !important;
        padding: 10px 12px !important;
    }
    .gaia-body { padding: 12px !important; }
    .grid-kpis {
        grid-template-columns: 1fr !important;
    }
}

/* Force TOUT le contenu à ne jamais déborder son container.
   Filet de sécurité brutal contre les min-width fixes de Django admin. */
html, body { max-width: 100vw !important; overflow-x: hidden !important; }
#container, #main, #content, #content-main {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

/* Cartes météo qui débordent : scroll horizontal local */
.gaia-wrap .weather-scroll,
#weather-block .wx-hours,
#weather-block > div[style*="grid"] {
    overflow-x: auto !important;
    max-width: 100% !important;
    -webkit-overflow-scrolling: touch;
}


/* 3) CONTENU 100% LARGEUR SUR ECRAN ETROIT
   La sidebar Gmail-style est gérée par base_site.html (bouton toggle `‹›`
   et hamburger `☰`). Ici on se contente d'AIDER le contenu à se reflow
   correctement quand la fenetre est etroite (~ demi-écran) :
   - Padding réduit
   - Titres compactés
   - Boutons "Ajouter" en pleine largeur sur tout petit ecran
*/

@media (max-width: 1100px) {
    /* Force le contenu à prendre TOUTE la largeur (sans marge résiduelle). */
    #content, #content-main, #container, .main {
        margin-left: 0 !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

/* Mobile pur : boutons pleine largeur */
@media (max-width: 700px) {
    #header, .pepi-header {
        padding: 8px 10px !important;
        font-size: 13px !important;
    }
    .gaia-title {
        font-size: 16px !important;
    }
    .object-tools a,
    .object-tools li {
        display: block !important;
        margin: 4px 0 !important;
        width: 100% !important;
        text-align: center !important;
    }
}


/* 4) FORMULAIRES change_form : réduit paddings sur mobile */
@media (max-width: 900px) {
    #content .form-row {
        padding: 8px 6px !important;
    }
    #content .aligned label {
        width: 100% !important;
        float: none !important;
        text-align: left !important;
        padding-bottom: 4px !important;
    }
    #content .aligned .form-row > div,
    #content .aligned .form-row .field-box {
        margin-left: 0 !important;
    }
    /* Inputs pleine largeur sur mobile */
    #content input[type="text"],
    #content input[type="email"],
    #content input[type="url"],
    #content input[type="number"],
    #content textarea,
    #content select {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    #content input[type="time"],
    #content input[type="date"] {
        max-width: 200px !important;
    }
}


/* 5) TABLES INLINE (StackedInline, TabularInline) : scroll horizontal aussi */
#content .inline-group,
#content .inline-related {
    overflow-x: auto !important;
    max-width: 100% !important;
}
#content .inline-group table {
    min-width: max-content !important;
}


/* 6) FIELDSETS : évite qu'un champ trop large casse le layout */
#content fieldset.module {
    max-width: 100% !important;
    overflow-x: auto;
}
#content fieldset.module .form-row {
    max-width: 100% !important;
}


/* 7) HEADER (barre du haut avec logo pépi, "Bienvenue", année, boutons)
   Empile vertical sous 900px pour ne pas déborder. */
@media (max-width: 900px) {
    #header, .pepi-header, .gaia-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    #header #branding,
    #header #user-tools {
        width: 100% !important;
    }
}
