/* --- Global Reset & Variables --- */
:root {
    --primary: #007bff; /* Bleu */
    --danger: #dc3545;  /* Rouge */
    --text-color: #333;
    --muted-color: #6c757d;
    --border-color: #ccc;
    --bg-light: #f4f7fa;
    --card-bg: #ffffff;
    --header-bg: #ffffff;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --page-gutter: clamp(8px, 2vw, 24px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-light);
}

/* --- App Shell & Layout --- */
.app {
    min-height: 100vh;
}

.container {
    width: auto;              /* prend toute la largeur disponible… */
    max-width: none;          /* …sans limite fixe */
    margin-inline: var(--page-gutter);   /* petit espace à gauche/droite */
    padding-inline: clamp(2px, 1.5vw, var(--spacing-md)); /* garde un peu d’air dedans */
  }
/* --- Header --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--header-bg);
    margin-bottom: var(--spacing-md);
}

.app-header.container {
    /* 1. Remove the margin that pulls the element away from the page edges */
    margin-inline: 0;
    /* 2. OPTIONAL: Set padding-inline to 0 if you want the content itself right against the edge.
       If you want content spaced, you might skip this line or add a separate inner container. */
    padding-inline: var(--spacing-md);
}

.app-title {
    font-size: 1.5rem;
    font-weight: 500;
}

.header-controls {
    display: flex;
    gap: var(--spacing-md);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Ajouter ceci au CSS global */
.split {
    display: flex;
    flex-direction: column; /* CHANGE : Empile les éléments verticalement */
    gap: var(--spacing-md); /* Ajoute un espace entre les deux champs */
}

/* --- Utilities (Spacing, Text) --- */
.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: var(--spacing-sm); }
.pl-md { padding-left: var(--spacing-md); }

.muted {
    color: var(--muted-color);
    font-size: 0.9rem;
}

.text-sm { font-size: 0.85rem; }
.text-lg { font-size: 1.25rem; }
.mono { font-family: monospace; }
.row-start {
    display: flex;
    align-items: center;
}
.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.row-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
.gap-md { gap: var(--spacing-md); }
.gap-sm { gap: var(--spacing-sm); }
.flex-0 { flex: 0.8; min-width: 0; }
.flex-1 { flex: 1; min-width: 0; }
.flex-2 { flex: 2; min-width: 0; }
.flex-3 { flex: 3; min-width: 0; }
.hidden { display: none; }

.legend {
    font-size: 0.75rem;
    margin-left: var(--spacing-sm);
}
.legend.red { color: var(--danger); }
.tip {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.8rem;
    color: var(--muted-color);
}
.badge.warn {
    display: inline-block;
    background-color: #ffc107; /* Jaune */
    color: #333;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8rem;
}
.badge.tips {
    display: inline-block;
    background-color: rgba(13,110,253,.08);; /* Jaune */
    color:#084298;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8rem;
    margin-top: var(--spacing-xs);
    margin-left: auto;
}
/* --- Grids (Flexbox/Grid pour les agencements) --- */
.grid {
    display: grid;
}
.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}
.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
.wrap {
    gap: var(--spacing-md);
}
/* Pour les petits écrans */
@media (max-width: 900px) {
    .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}
/* Grille spécifique à la modale Izicod */
.form-grid {
    display: grid;
    grid-template-columns: max-content 1fr; /* Label à gauche, Input à droite */
    gap: var(--spacing-sm) var(--spacing-md);
    align-items: center;
}
.form-grid > .textarea {
    grid-column: 2;
}


/* --- Forms & Inputs --- */
.form-field {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.field-label {
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}
.field-label-italic {
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    font-style: italic;
}

.field-label-inline {
    font-weight: 500;
    font-size: 0.9rem;
}

.input, .textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
}

.input-wide { width: 100%; }
.input-md { width: 300px; } /* Exemple de largeur moyenne */

.textarea {
    resize: vertical;
}
.textarea.tall {
    min-height: 80px;
}
.textarea.h-52vh {
    min-height: 52vh;
}
.bg-muted {
    background-color: var(--bg-light);
}

/* Style de base pour Dash Core Components */
.dd .Select-control, .dd .Select-menu-outer {
    border-color: var(--border-color) !important;
    border-radius: 4px !important;
}

.dd.compact .Select-control {
    min-height: 30px;
}
.dd.compact .Select-value {
    padding-top: 0;
    padding-bottom: 0;
}

/* Dropdown “langue cible” plus étroit */
.dd.lang-target {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 140px !important;
}

/* S'il est dans une barre en flex (ex: .toolbar), empêche l’étirement */
.dd.lang-target {
    flex: 0 0 140px !important;
    }

/* Optionnel : sur mobile, laisser reprendre toute la largeur */
@media (max-width: 600px) {
    .dd.lang-target {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
    }
}


/* --- Dropdown compact : hauteur alignée sur les boutons (~36px) --- */
.dd.compact .Select-control{ min-height:36px; height:36px; }

/* Aligner verticalement le texte et l’input */
.dd.compact .Select-placeholder,
.dd.compact .Select--single > .Select-control .Select-value{
  line-height:34px; padding:0 8px;
}
.dd.compact .Select-input{ height:34px; }
.dd.compact .Select-input > input{ height:34px; padding:0; }

/* Zone flèche / clear à la même hauteur */
.dd.compact .Select-arrow-zone,
.dd.compact .Select-clear-zone{
  height:34px; padding-top:0; padding-bottom:0;
}

/* --- Empêcher le shrink dans la toolbar + donner une largeur mini --- */
.toolbar .dd{ flex:0 0 auto; }           /* ne pas rétrécir dans le flex row */
.toolbar .dd.compact{ min-width:120px; } /* 4 chiffres + chevron sans ellipses */


/* Style pour les RadioItems (PCS Builder) */
#pcs-bp label, #pcs-ap label, #pcs-dev label, #pcs-qual label {
    font-size: 0.9rem;
    padding: 0.25rem 0;
}

/* --- Buttons --- */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: #0056b3;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: #bd2130;
}

.btn-danger-outline {
    background-color: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-danger-outline:hover {
    background-color: var(--danger);
    color: white;
}

.btn-secondary {
    background-color: var(--muted-color);
    color: white;
}
.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-ghost {
    background-color: transparent;
    color: var(--primary);
    padding: 0.25rem 0.5rem;
}
.btn-ghost:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

.btn-block {
    width: 100%;
    margin-top: var(--spacing-md);
}
.btn-xs {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
}

/* Clipboard button */
.btn-clip {
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 1.2rem;
    padding: 0 0.5rem;
}
.btn-clip:hover {
    opacity: 0.8;
}

/* --- Cards --- */
.card {
    background-color: var(--card-bg);
    padding: var(--spacing-md);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.card-title {
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--bg-light);
}

/* --- Tabs --- */
.custom-tabs {
    border-bottom: 1px solid var(--border-color);
    margin-top: var(--spacing-sm);
}

.custom-tab, .custom-tab--selected {
    font-weight: 500;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-bottom: none;
    cursor: pointer;
    transition: background-color 0.2s;
    background-color: var(--bg-light);
}

.custom-tab--selected {
    border-color: var(--border-color);
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    border-bottom: 2px solid var(--card-bg); /* cache la ligne de séparation */
    background-color: var(--card-bg);
    color: var(--primary);
}

/* --- Login Overlay --- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95); /* Fond très clair */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Assure qu'il est au-dessus de tout */
}

/* Style for dcc.Loading around login card */
#login-loading {
    display: inline-block;
    width: auto;
}

.login-card {
    background-color: white;
    padding: var(--spacing-lg);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 350px;
    text-align: center;
    position: relative;
    overflow: hidden; /* Pour le bandeau */
}

.flag-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    /* Exemple de drapeau (Luxembourg : Rouge, Blanc, Bleu) */
    background: linear-gradient(to right, #da291c 0%, #da291c 33%, #ffffff 33%, #ffffff 66%, #00a1e3 66%, #00a1e3 100%);
}

.login-title {
    margin-top: var(--spacing-sm);
    font-size: 1.8rem;
}

.login-card .field-label {
    text-align: left;
    display: block;
    margin-top: var(--spacing-md);
}

.login-error {
    color: var(--danger);
    margin-top: var(--spacing-sm);
    font-weight: 500;
}

/* --- Modals (overlays) --- */
.modal-overlay {
    /* Couvre toute la fenêtre d'affichage */
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* Centrage horizontal et vertical du contenu (le .modal-card) */
    display: flex;
    justify-content: center; /* Centre horizontalement */
    align-items: center;    /* Centre verticalement */
    
    /* Autres styles */
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
}

.modal-card {
    /* Le style que vous avez fourni */
    background-color: var(--card-bg);
    padding: var(--spacing-lg);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    /* Aucun besoin de margin ou positionnement supplémentaire ici, 
       car le parent (.modal-overlay) gère le centrage Flexbox */
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--bg-light);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: 4px;
    color: var(--danger);;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem;
}

.modal-close:hover {
    background-color: var(--danger);
    color: white;
}

/* --- PDF Frame --- */
.pdf-frame {
    width: 100%;
    min-height: 80vh;
    border: 1px solid var(--border-color);
    margin-top: var(--spacing-md);
}

/* --- Pre & Markdown Output --- */
.pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
    background-color: #f8f9fa;
    padding: var(--spacing-sm);
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: var(--spacing-sm);
    font-size: 0.9rem;
}

/* --- DataTable Styling (minimal) --- */
/* Le style spécifique de Dash DataTable doit souvent être géré via les props `style_table`, `style_cell`, `css` */
#faq-results, #izicod-results {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

/* Style de coloration pour Izicod (latéralité) - doit être géré en JS/callback, mais voici les classes de base */
.izi-lat-left { background-color: rgba(0, 123, 255, 0.1); }    /* Bleu clair */
.izi-lat-right { background-color: rgba(255, 99, 71, 0.1); }   /* Rouge/Saumon clair */
.izi-lat-bilateral { background-color: rgba(255, 193, 7, 0.1); } /* Jaune clair */

/* Style pour l'élément de statut de copie (pcs-copy-status) */
.text-success {
    color: #28a745; /* Vert */
    font-weight: 500;
}


/* Container du bloc */
.form-stack {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-md);
    background: transparent;  /* pas de fond */
    box-shadow: none;         /* pas d'ombre */
    border: 0;                /* pas de border autour des dropdowns */
  }
  
  /* Tous les champs prennent la largeur dispo */
  .w-100 { width: 100%; }
  
  /* Empilement vertical avec rythme constant */
  .stack > * + * { margin-top: var(--spacing-sm); }
  
  /* Barre "ajouter à ma checklist" alignée et responsive */
  .inline-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
  }
  .inline-bar .btn { flex: 0 0 auto; }
  .inline-bar .dd  { flex: 1 1 auto; }
  
  /* Centrage du bouton "Vider" */
  .center-actions {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-md);
  }
  
  /* Nettoyage du look des dropdowns (optionnel) */
  .dd .Select-control {
    border-color: var(--border-color) !important;  /* déjà dans ton CSS global, on garde fin */
    box-shadow: none !important;                   /* supprime l'ombre forcée inline */
  }
  
  /* Un form-field compact ne s'étire pas */
.form-field.flex-0 {
    flex: 0 0 auto !important;
    width: auto !important;      /* ← crucial : annule width:100% de .form-field */
    max-width: none !important;
  }

  /* Permet aux form-field de partager l'espace horizontal au lieu de prendre 100% */
.form-field.inline-item {
    width: auto;             /* Ne force plus la largeur à 100% */
    flex-grow: 0;            /* Ne grandit pas par défaut */
}

/* Modificateur pour donner une largeur minimum dans un contexte inline */
.form-field.inline-item.w-min-lg {
    min-width: 200px; /* Exemple de largeur minimum pour les champs (ajuster au besoin) */
}

/* DeepTranslate en 2 colonnes */
.split{
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr); /* 2 colonnes égales */
  gap: var(--spacing-md);
  align-items: start;
}

/* même hauteur pour les 2 zones */
.h-52vh{ min-height:52vh; }

/* que les textareas prennent toute la largeur */
.textarea{ width:100%; }

/* Responsive : repasse en lignes sur petit écran */
@media (max-width:1100px){
  .split{ grid-template-columns: 1fr; }
}
