@import url('planning.css');

/* Réinitialisation de base et styles globaux */
:root {
    /* Variables existantes conservées */
    --primary-color: #007bff; /* Bleu MDDigi */
    --secondary-color: #6c757d; /* Gris neutre */
    --success-color: #28a745; /* Vert succès */
    --danger-color: #dc3545;  /* Rouge danger */
    --warning-color: #ffc107; /* Jaune avertissement */
    --info-color: #17a2b8;    /* Cyan info */
    --light-color: #f8f9fa;   /* Fond clair global */
    --dark-color: #343a40;    /* Fond sombre (utilisé pour l'ancienne nav, peut être réutilisé) */
    --text-color: #212529; /* Texte principal */
    --light-text-color: #ffffff;
    --border-color: #dee2e6;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --border-radius: 4px;
    --border-radius-small: 2px;

    /* NOUVELLE VARIABLE pour la hauteur de la barre de menu supérieure */
    --top-bar-height: 60px;

    /* Variables de la proposition de design (peuvent être fusionnées/ajustées avec les tiennes) */
    --primary-hover-color: #0056b3; /* Version plus foncée du bleu MDDigi pour hover */
    --card-background: #ffffff; /* Fond pour les cartes et la modale */
    --modal-header-bg: #f0f0f0; /* Fond pour l'en-tête de la modale */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    touch-action: pan-x pan-y pinch-zoom;
}

body {
    font-family: var(--font-family);
    background-color: var(--light-color); /* Fond général de la page */
    color: var(--text-color);
    line-height: 1.6;
    margin: 0; /* Assurer qu'il n'y a pas de marge par défaut */
}

/* ---- Styles Page de Connexion (Conservés) ---- */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f2f5;
}
.login-container {
    background-color: var(--card-background); /* Utilisation variable */
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-container h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 24px;
}
.login-container p {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}
.login-form input[type="text"],
.login-form input[type="password"] {
    width: calc(100% - 20px);
    padding: 12px 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    font-size: 16px;
}
.login-form button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}
.login-form button:hover {
    background-color: var(--primary-hover-color); /* Utilisation variable */
}

/* Styles pour feedback messages (Conservés et légèrement ajustés si besoin) */
.feedback, .error-message, .success-message {
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
    font-size: 0.9em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.feedback.success, .success-message {
    background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb;
}
.feedback.error, .error-message {
    background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb;
}
.feedback.warning { /* Ajouté pour cohérence si besoin */
    background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba;
}
.close-feedback {
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    background: none;
    border: none;
    color: inherit;
    margin-left: 15px;
}


/* ---- NOUVELLE Structure principale du CRM (Remplace l'ancienne grille) ---- */
.crm-container {
    display: flex;
    flex-direction: column; /* La barre du haut puis le contenu principal */
    min-height: 100vh;
}

/* Nouvelle barre de navigation supérieure */
.crm-top-bar {
    background-color: var(--card-background); /* Fond blanc pour la barre */
    color: var(--text-color);
    padding: 0 20px;
    height: var(--top-bar-height);
    display: flex;
    align-items: center;
    justify-content: space-between; /* Espacer logo, nav, zone utilisateur */
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    position: fixed; /* Fixe la barre en haut */
    top: 0;
    left: 0;
    right: 0;
    z-index: 1060; /* MODIFIÉ : Doit être supérieur à la modale (1050) et à son overlay */
}

.top-bar-logo {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    flex-shrink: 0; /* Empêche le logo de rétrécir */
}
/* #crm-title est dans le HTML, il hérite de .top-bar-logo */

.crm-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-background);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    flex: 0 0 auto;
}

.crm-menu-toggle span {
    width: 22px;
    height: 2px;
    background: var(--text-color);
    border-radius: 999px;
    transition: transform .2s ease, opacity .2s ease;
}

.crm-menu-toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.crm-menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
}

.crm-menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-top-devis {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    background: var(--primary-color);
    color: var(--light-text-color);
    font-weight: 600;
    font-size: 0.95em;
    cursor: pointer;
    flex: 0 0 auto;
    white-space: nowrap;
}

.mobile-top-devis:hover,
.mobile-top-devis:focus {
    opacity: 0.9;
    outline: none;
}

.crm-top-navigation {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}
.crm-top-navigation ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
}
.crm-top-navigation li {
    margin: 0 2px; /* Petit espacement entre les boutons */
    display: flex;
    min-width: 0;
}
.crm-top-navigation .nav-button {
    background-color: transparent;
    color: #555;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9em;
    border-radius: var(--border-radius);
    white-space: nowrap;
    display: flex;
    align-items: center;
    transition: background-color 0.3s, color 0.3s;
}
.crm-top-navigation .nav-button-text {
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-top-navigation .nav-button i {
    margin-right: 8px;
}
.crm-top-navigation .nav-button:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
}
.crm-top-navigation .nav-button.active {
    background-color: var(--primary-color);
    color: var(--light-text-color);
    font-weight: 500;
}
.crm-top-navigation .nav-action-button {
    background-color: var(--primary-color);
    color: var(--light-text-color);
    font-weight: 500;
}
.crm-top-navigation .nav-action-button:hover {
    background-color: #0056b3;
    color: var(--light-text-color);
}

.top-bar-user-area {
    display: flex;
    align-items: center;
    font-size: 0.9em;
    flex-shrink: 0; /* Empêche la zone utilisateur de rétrécir */
}
.top-bar-user-area span {
    margin-right: 15px;
}
.top-bar-user-area .logout-button {
    background-color: transparent; /* Ou une couleur discrète */
    color: var(--primary-color);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.3s ease, color 0.3s ease;
    border: 1px solid transparent; /* Pour la cohérence de taille */
}
.top-bar-user-area .logout-button:hover {
    background-color: #e9ecef;
    border-color: #ddd; /* Optionnel */
}
.top-bar-user-area .logout-button i { /* Si icône dans le bouton déconnexion */
    margin-right: 5px;
}

/* Contenu principal (sous la barre du haut) */
.crm-main-content {
    margin-top: var(--top-bar-height); /* Dégager l'espace pour la barre du haut fixe */
    padding: 20px; /* Espace autour du contenu du dashboard */
    flex-grow: 1;
    overflow-y: auto; /* Si le dashboard est grand */
    background-color: var(--light-color); /* Fond pour la zone principale si différent du body */
}
.main-content-placeholder { /* Message si aucun module n'est chargé */
    text-align: center;
    color: #777;
    padding-top: 100px;
}
.main-content-placeholder i {
    margin-bottom: 20px;
    color: #ccc;
}
.main-content-placeholder a {
    color: var(--primary-color);
}


/* ---- NOUVEAUX Styles pour la Fenêtre Modale (Remplacent complètement les anciens) ---- */
#modal-container {
    position: fixed;
    top: var(--top-bar-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--top-bar-height));
    /* background-color: rgba(0, 0, 0, 0.5); L'overlay s'en charge si besoin, ou wrapper direct */
    display: flex;
    z-index: 1050;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0.2s ease; /* Transition plus rapide */
}

#modal-container.modal-hidden {
    opacity: 0;
    visibility: hidden;
}

#modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4); /* Overlay léger pour le focus */
    z-index: 1; /* Sous le contenu de la modale mais couvre le main-content */
}

#modal-content-wrapper {
    background-color: var(--card-background);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative; /* Pour que l'overlay soit bien positionné par rapport à lui */
    z-index: 2; /* Au-dessus de l'overlay */
}

#modal-header {
    background-color: var(--modal-header-bg);
    padding: 12px 20px; /* Un peu moins haut */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
#modal-title {
    font-size: 1.3em; /* Un peu plus petit */
    margin: 0;
    color: var(--text-color); /* Titre plus sobre */
    font-weight: 500;
}
#modal-close-button {
    background: none; border: none; font-size: 1.7em; cursor: pointer;
    color: #888; padding: 0 5px; line-height: 1;
}
#modal-close-button:hover { color: var(--danger-color); }

#modal-body {
    overflow-y: auto;
    flex-grow: 1;
    background-color: #f0f2f5; /* Fond gris clair pour faire ressortir les cartes */
    padding: 20px; /* On s'assure que le padding est ici */
}

/* Pleine largeur pour le module Planning dans la modale SPA */
#modal-container.planning-modal #modal-content-wrapper { width: 100%; max-width: 100%; }
#modal-container.planning-modal #modal-body { padding: 0; }
#modal-container.planning-modal .planning-pro-container { max-width: none !important; width: 100% !important; margin: 0 !important; }

/* On retire le padding des modules internes car il est maintenant sur modal-body */
.client-module, .devis-module {
    padding: 0;
}


/* ---- Styles spécifiques au Module Client / Contacts (Conservés et vérifiés) ---- */
/* Ces styles s'appliqueront au contenu chargé dans #modal-body */
.client-module {
    padding: 20px;
    font-size: 0.95em;
    height: 100%; /* Permet au module de remplir le modal-body */
    display: flex;
    flex-direction: column;
}

.client-module .module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}
.client-module .module-header h1 {
    margin: 0;
    font-size: 1.6em; /* Un peu réduit pour s'intégrer à l'en-tête de modale */
    color: var(--primary-color);
}
.client-module .header-actions {
    display: flex;
    gap: 10px;
}
/* Styles généraux pour les boutons DANS le module client */
.client-module .nav-button,
.client-module .action-btn,
.client-form .form-actions button, /* Inclure les boutons de formulaire */
.details-actions-bar button, .details-actions-bar .action-btn /* Inclure boutons de la barre d'actions vue détaillée */
 {
    background-color: var(--primary-color); color: var(--light-text-color);
    padding: 8px 15px; border-radius: var(--border-radius); text-decoration: none;
    font-size: 0.9em; transition: background-color 0.2s ease, opacity 0.2s ease;
    border: none; cursor: pointer; display: inline-flex; align-items: center;
}
.client-module .nav-button:hover,
.client-module .action-btn:hover,
.client-form .form-actions button:hover,
.details-actions-bar button:hover, .details-actions-bar .action-btn:hover {
    opacity: 0.85; /* ou une couleur de survol via variable */
}

/* Spécificités des boutons si nécessaire (les couleurs de base sont bien) */
.client-module .nav-button.primary-action, .client-module .action-btn.primary-action {
    background-color: var(--success-color);
}
.client-module .nav-button.edit-action, .client-module .action-btn.edit-btn {
    background-color: var(--warning-color);
    color: var(--dark-color); /* Assurer lisibilité sur jaune */
}
.client-module .nav-button.secondary-action, .client-module .action-btn.secondary-action {
    background-color: var(--secondary-color);
}
.client-module .delete-btn, .client-module .action-btn.delete-action { /* Cohérence */
    background-color: var(--danger-color);
}

/* Assurer que les boutons dans les cartes héritent des bonnes couleurs */
.client-module .contact-card .action-btn.view-btn {
    background-color: var(--info-color) !important;
    color: var(--light-text-color) !important;
}

.client-module .contact-card .action-btn.edit-btn {
    background-color: var(--warning-color) !important;
    color: var(--dark-color) !important; /* Assurer lisibilité sur jaune */
}

.client-module .contact-card .action-btn.delete-btn {
    background-color: var(--danger-color) !important;
    color: var(--light-text-color) !important;
}

/* On ajoute cette règle spécifique pour les boutons avec du texte */
.client-module .nav-button span + i,
.client-module .action-btn span + i,
.client-form .form-actions button span + i,
.details-actions-bar button span + i,
.client-module .nav-button > i:not(:last-child),
.client-module .action-btn > i:not(:last-child) {
    margin-right: 8px;
}

/* On s'assure que les icônes seules dans les cartes n'ont aucune marge */
.contact-card .card-actions-footer .action-btn i {
    margin-right: 0;
}


.client-module h2 {
    font-size: 1.4em;
    color: var(--secondary-color);
    margin-top: 0; /* Le padding du module-header ou client-module gère l'espace */
    margin-bottom: 15px;
}

/* Panneau de recherche (MODIFIÉ POUR ÊTRE PLUS COMPACT) */
.search-panel {
    background-color: #f8f9fa;
    padding: 12px 15px; /* Padding réduit */
    border-radius: var(--border-radius);
    margin-bottom: 20px; /* Marge réduite */
    border: 1px solid var(--border-color);
}
.search-panel form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end; /* Aligne les boutons en bas, à côté des champs de texte */
    gap: 20px; /* Espace entre la zone de filtre et les boutons d'action */
}

.search-panel form .search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px; /* Espacement réduit */
    align-items: center; /* Alignement vertical centré */
    margin-bottom: 10px;
}
.search-panel .filter-group {
    display: flex;
    flex-direction: row; /* Labels et inputs sur la même ligne */
    align-items: center; /* Alignement vertical */
    flex: 1 1 220px;
}
.search-panel .filter-group label {
    font-size: 0.9em;
    margin-bottom: 0; /* Plus de marge en bas */
    margin-right: 8px; /* Espace entre le label et l'input */
    color: #495057;
    font-weight: 600;
    white-space: nowrap;
}
.search-panel .filter-group label i {
    margin-right: 6px;
    color: var(--primary-color);
}
.search-panel .filter-group input[type="text"],
.search-panel .filter-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    font-size: 0.95em;
    background-color: var(--card-background);
}
.search-panel .filter-group-checkbox {
    display: flex;
    align-items: center;
    padding-top: 0; /* Padding supprimé */
    flex-basis: auto;
}
.search-panel .filter-group-checkbox input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}
.search-panel .filter-group-checkbox label {
     font-size: 0.95em;
     margin-bottom: 0;
     font-weight: normal;
}
.search-panel .search-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 0; /* Le 'gap' du formulaire parent gère l'espacement */
    flex-shrink: 0; /* NOUVEAU : Empêche ce bloc de boutons de se faire écraser */
}

/* NOUVEAU BLOC : On s'assure que le texte des boutons ne se coupe pas */
.search-panel .search-actions .action-btn,
.search-panel .search-actions .nav-button {
    white-space: nowrap; /* Empêche le texte comme "Filtrer" de passer à la ligne */
}


/* Liste des cartes de contact (FORTEMENT RÉDUITE) */
.contact-card-list {
    display: grid;
    /* Largeur min fortement réduite pour maximiser le nombre de cartes */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
    gap: 10px; /* Espacement encore réduit */
    padding-top: 10px;
    flex-grow: 1; 
    overflow-y: auto;
    padding-bottom: 10px;
}

.contact-card {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-left-width: 4px;
    border-radius: var(--border-radius);
    padding: 8px 12px; /* Padding interne fortement réduit */
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    height: 210px; /* Hauteur légèrement augmentée pour tenir compte des nouveaux espacements */
    min-height: 210px;
    max-height: 210px;
    overflow: hidden; /* Éviter le débordement */
}
.contact-card:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transform: translateY(-3px);
}
.contact-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px; /* Marge encore réduite */
    min-height: 40px; /* Hauteur minimale pour le header */
    max-height: 50px; /* Hauteur maximale pour éviter que le header prenne trop de place */
    overflow: hidden; /* Éviter le débordement du header */
}
.contact-card .card-title {
    margin: 0 0 4px 0;
    font-size: 1em; /* Police du titre encore réduite */
    font-weight: 600;
    /* CORRECTION : Limiter le titre à 2 lignes maximum */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.2;
    max-height: 2.4em; /* 2 lignes * 1.2 line-height */
}
.contact-card .card-title a {
    text-decoration: none;
    color: var(--primary-color);
}
.contact-card .card-title a:hover {
    text-decoration: underline;
}
.card-status {
    font-size: 0.8em;
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--light-text-color);
    white-space: nowrap;
    font-weight: 500;
    text-transform: capitalize;
}

/* Couleurs spécifiques pour les pastilles de statut (plus foncées pour la lisibilité) */
.card-status.status-contact { background-color: var(--info-color) !important; }
.card-status.status-prospect { background-color: var(--warning-color) !important; color: var(--dark-color) !important; }
.card-status.status-client { background-color: var(--success-color) !important; }
.card-status.status-ancien_client { background-color: var(--secondary-color) !important; }
.card-status.status-archive { background-color: var(--dark-color) !important; }

/* Règle complète et renforcée pour le badge de prix du produit */
.card-price-badge {
    font-size: 0.8em;
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--light-text-color);
    white-space: nowrap;
    font-weight: 500;
    background-color: var(--success-color) !important; /* Ajout de !important pour forcer l'application */
}
.status-contact, .status-border-contact { 
    border-left-color: var(--info-color); 
    background-color: #e0f7fa; /* Fond cyan très clair */
}
.status-prospect, .status-border-prospect { 
    border-left-color: var(--warning-color); 
    background-color: #fffbf0; /* Fond jaune très clair */
}
.status-client, .status-border-client { 
    border-left-color: var(--success-color); 
    background-color: #e8f5e8; /* Fond vert très clair */
}
.status-ancien_client, .status-border-ancien_client { 
    border-left-color: var(--secondary-color); 
    background-color: #f5f5f5; /* Fond gris très clair */
}
.status-archive, .status-border-archive { 
    border-left-color: var(--dark-color); 
    background-color: #f0f0f0; /* Fond gris neutre très clair */
}

/* --- NOUVEAUX STYLES POUR LES CATÉGORIES DE PRODUITS --- */
/* Pour les produits sans catégorie assignée */
.contact-card.status-border-non-classe { 
    border-left-color: #95a5a6; /* Gris neutre */
    background-color: #f8f9fa; /* Fond gris très clair */
}

/* Jeu de 5 couleurs pour les catégories dynamiques */
.contact-card.category-color-1 { 
    border-left-color: #3498db; /* Bleu */
    background-color: #e3f2fd; /* Fond bleu très clair */
}
.contact-card.category-color-2 { 
    border-left-color: #2ecc71; /* Vert */
    background-color: #e8f5e8; /* Fond vert très clair */
}
.contact-card.category-color-3 { 
    border-left-color: #f1c40f; /* Jaune */
    background-color: #fffbf0; /* Fond jaune très clair */
}
.contact-card.category-color-4 { 
    border-left-color: #e67e22; /* Orange */
    background-color: #fff3e0; /* Fond orange très clair */
}
.contact-card.category-color-5 { 
    border-left-color: #9b59b6; /* Violet */
    background-color: #f3e5f5; /* Fond violet très clair */
}

.contact-card .card-client-number {
    font-size: 0.8em; /* Police encore réduite */
    color: #777;
    margin-bottom: 4px; /* Marge réduite pour optimiser l'espace */
    font-weight: 500;
    /* CORRECTION : Tronquer le texte long pour éviter le débordement */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* ==== CORRECTION BOUTONS COUPÉS DANS LES CARTES PRODUITS ==== */
.contact-card .card-details {
    font-size: 0.8em; /* Police des détails encore réduite */
    color: #555;
    flex-grow: 1; /* Prend l'espace disponible */
    margin-bottom: 8px; /* Marge encore réduite */
    overflow: hidden; /* Éviter le débordement */
    display: flex;
    flex-direction: column;
    max-height: 80px; /* Réduction de la hauteur pour laisser plus de place au footer */
    min-height: 60px; /* Hauteur minimale pour éviter que le footer remonte trop */
}
.contact-card .card-details p {
    margin: 2px 0; /* Marge encore réduite */
    display: flex;
    align-items: center;
    white-space: nowrap; /* Empêche le passage à la ligne pour les détails longs */
    overflow: hidden; /* Cache le texte qui dépasse */
    text-overflow: ellipsis; /* Ajoute des "..." pour le texte tronqué */
}
.contact-card .card-details p i {
    margin-right: 6px; /* Marge encore réduite */
    color: var(--secondary-color);
    width: 12px;
    text-align: center;
}
.contact-card .card-details a {
    color: var(--primary-color);
    text-decoration: none;
}
.contact-card .card-details a:hover {
    text-decoration: underline;
}
.contact-card .card-actions-footer {
    margin-top: auto;
    padding-top: 8px; /* Augmentation légère pour plus d'espace */
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 5px; /* Espace entre boutons encore réduit */
    flex-wrap: nowrap; /* Empêche le passage à la ligne des boutons */
    justify-content: flex-end;
    flex-shrink: 0; /* Empêche le footer de se rétrécir */
    min-height: 50px; /* Hauteur minimale garantie pour le footer - augmentée */
    position: relative; /* S'assurer que le footer reste à sa place */
}

/* Style pour les boutons d'icônes, plus compacts */
.contact-card .card-actions-footer .action-btn {
    padding: 8px; /* Padding uniforme pour un format carré */
    font-size: 0.9em; /* Taille de l'icône */
    line-height: 1;
    width: 32px !important; /* Largeur forcée pour surcharger les styles généraux */
    height: 32px !important; /* Hauteur forcée pour surcharger les styles généraux */
    flex-grow: 0; /* On ne veut plus que les boutons s'étirent */
    flex-shrink: 0; /* Empêche les boutons de se rétrécir */
    text-align: center;
    justify-content: center;
    border-radius: 4px !important; /* Bords légèrement arrondis, pas ronds */
    display: flex; /* Pour centrer parfaitement l'icône */
    align-items: center;
    /* CORRECTION FORCÉE : Assurer la visibilité sur toutes les cartes */
    background-color: var(--primary-color) !important;
    color: var(--light-text-color) !important;
    border: none !important;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}


/* Formulaires d'ajout/édition (Généralisé) */
.crm-module-form .form-section {
    background-color: var(--card-background); /* Fond blanc */
    padding: 25px;
    border: none; /* On retire la bordure */
    border-radius: 8px; /* Un radius plus doux et moderne */
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* L'ombre qui crée l'effet de carte */
    transition: box-shadow 0.3s ease;
}

.crm-module-form .form-section:focus-within {
     box-shadow: 0 5px 15px rgba(0, 123, 255, 0.12); /* Effet de "focus" sur la carte */
}
.crm-module-form .form-section h3 {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--text-color);
    margin: -25px -25px 25px -25px; /* Astuce pour coller le titre en haut de la carte */
    padding: 18px 25px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fa; /* Fond très léger pour l'en-tête de carte */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.crm-module-form .form-row {
    display: flex;
    gap: 25px;
    margin-bottom: 0;
}
.client-form .form-row .form-group {
    flex: 1;
    min-width: 0;
}
.client-form .form-group {
    margin-bottom: 18px;
}
.client-form .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.95em;
    color: #495057;
}
.client-form .form-group input[type="text"],
.client-form .form-group input[type="email"],
.client-form .form-group input[type="date"],
.client-form .form-group select,
.client-form .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    box-sizing: border-box;
    font-size:1em;
    background-color: var(--card-background);
}
.client-form .form-group input:focus,
.client-form .form-group select:focus,
.client-form .form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
    outline: none;
}
.client-form .form-group textarea {
    min-height: 100px;
    resize: vertical;
}
.client-form .form-group small {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 4px;
    display: block;
}
.crm-module-form .form-actions {
    margin-top: 10px;
    padding: 20px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background-color: var(--card-background);
    border-top: 1px solid var(--border-color);
    /* Astuce pour coller la barre en bas de la modale */
    position: sticky;
    bottom: 0;
    z-index: 10;
}
.client-form.form-archived-disabled .form-section {
    opacity: 0.7;
}
.client-form.form-archived-disabled input:not([name="statut_fiche"]),
.client-form.form-archived-disabled select:not([name="statut_fiche"]),
.client-form.form-archived-disabled textarea {
    background-color: #e9ecef !important;
    cursor: not-allowed;
}


/* Vue détaillée de la fiche (Conservé) */
.view-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}
.view-header h2 {
    margin: 0;
    font-size: 1.7em;
    color: var(--primary-color);
    font-weight: 600;
}

.details-actions-bar {
    margin-bottom: 25px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.client-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
}
.client-view-section { /* Renommé pour éviter conflit avec .form-section si jamais */
    background-color: var(--card-background);
    padding: 20px 25px;
    border-radius: var(--border-radius);
    border: 1px solid #e7e7e7;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.client-view-section h3 { /* Titre de section dans la vue */
    font-size: 1.25em;
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}
.client-view-section h3 i {
    margin-right: 10px;
    color: var(--primary-color);
}
.client-view-section p {
    margin: 0 0 10px 0;
    font-size: 0.95em;
    line-height: 1.6;
}
.client-view-section p strong {
    color: #343a40;
    font-weight: 600;
}
.client-view-section p a {
    color: var(--primary-color);
    text-decoration: none;
}
.client-view-section p a:hover {
    text-decoration: underline;
}
.client-view-section.notes-section p {
    white-space: pre-wrap;
    background-color: #fdfdfd;
    padding: 12px;
    border-radius: var(--border-radius-small);
    border: 1px solid #f0f0f0;
    font-family: monospace;
    font-size: 0.9em;
}
.related-items-section h3 {
    color: var(--primary-color) !important;
}
.related-items-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.related-item-box {
    flex: 1;
    min-width: 240px;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: var(--border-radius);
    border: 1px solid #e9ecef;
}
.related-item-box h4 {
    font-size: 1.1em;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
}
.related-item-box h4 i {
    margin-right: 8px;
}
.related-item-box p {
    font-size: 0.9em;
    margin-bottom: 12px;
}


/* Responsive Design Adjustments */
/* L'ancien .crm-footer n'est plus dans la grille, donc pas besoin de règles spécifiques ici */

@media (max-width: 1600px) {
    .crm-top-navigation .nav-button {
        padding: 5px 6px; 
        font-size: 0.85em;
    }
    .crm-top-navigation .nav-button i {
        margin-right: 4px;
    }
    .top-bar-user-area span { display: none; } /* Cacher Bienvenue pour gagner de la place */
}

@media (max-width: 1400px) {
    .crm-top-navigation .nav-button-text { /* Cacher le texte des boutons, garder icônes */
        display: none;
    }
    .crm-top-navigation .nav-button i {
        margin-right: 0; /* Plus de texte, donc plus de marge */
    }
     .crm-top-navigation .nav-button {
        padding: 10px 12px; /* Padding uniforme pour icônes seules */
    }
    .top-bar-logo { font-size: 1.3em; }

    /* Ajustements pour les formulaires et cartes dans le contenu du module */
    .crm-module-form .form-row {
        flex-direction: column;
        gap: 0;
    }
     .search-panel form .search-filters {
        gap: 15px;
    }
    .search-panel .filter-group {
        flex-basis: calc(50% - 10px);
    }
}

@media (max-width: 768px) {
    .top-bar-logo { display: none; } /* Cacher le logo pour plus de place pour nav/user */
    .crm-top-bar {
        padding: 0 8px;
        gap: 8px;
        overflow: visible;
        justify-content: flex-start;
    }
    .crm-menu-toggle {
        display: inline-flex;
        margin-left: auto;
    }
        .mobile-top-devis { display: inline-flex; margin-right: 25px; z-index: 1075; position: relative; }
    .crm-top-navigation {
        display: none;
        position: fixed;
        top: var(--top-bar-height);
        left: 8px;
        right: 8px;
        max-height: calc(100vh - var(--top-bar-height) - 16px);
        overflow-y: auto;
        background: var(--card-background);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        box-shadow: 0 18px 45px rgba(0,0,0,.18);
        padding: 8px;
        z-index: 1070;
    }
    .crm-top-navigation.is-open {
        display: block;
    }
    .crm-top-navigation ul {
        display: flex;
        flex-direction: column;
        min-width: 0;
        width: 100%;
        gap: 4px;
    }
    .crm-top-navigation li {
        width: 100%;
        margin: 0;
    }
    .crm-top-navigation .nav-item-devis {
        display: none;
    }
    .crm-top-navigation .nav-button,
    .crm-top-navigation .nav-button.icon-only {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 14px;
    }
    .crm-top-navigation .nav-button-text,
    .crm-top-navigation .nav-button.icon-only .nav-button-text {
        display: inline-block;
        position: static;
        transform: none;
    }
    .crm-top-navigation .nav-button i,
    .crm-top-navigation .nav-icon {
        margin-right: 10px;
    }
    .nav-item-dropdown .dropdown-content,
    .crm-top-navigation .dropdown-content {
        position: static;
        display: block;
        box-shadow: none;
        border: 0;
        padding: 4px 0 4px 28px;
        background: transparent;
    }
    .top-bar-user-area {
        margin-left: 0;
        flex: 0 0 auto;
    }

    /* CORRECTIF IMPORTANT : Forcer la modale à prendre toute la largeur sur mobile */
    #modal-container {
        width: 100% !important;
        height: calc(100vh - var(--top-bar-height)) !important;
    }
    
    #modal-content-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #modal-body {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        overflow-x: auto !important;
    }

    /* Le contenu de la modale est déjà à 100% de largeur/hauteur sous la barre du haut */
    /* Les ajustements ci-dessous concernent le contenu DANS la modale */
    .client-module { 
        padding: 10px !important; 
        font-size: 0.9em; 
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .devis-module,
    .devis-form,
    .devis-list-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 10px !important;
    }
    
    .client-module .module-header { flex-direction: column; align-items: flex-start; gap:10px;}
    .client-module .header-actions { width: 100%;} /* Prendre toute la largeur */
    .client-module .header-actions .nav-button { flex-grow:1; text-align:center; justify-content: center;}

    /* OPTIMISATION MOBILE : Réduire la hauteur du bloc de recherche */
    .search-panel { 
        padding: 10px; 
        margin-bottom: 10px;
        background: #f8f9fa;
        border-radius: 8px;
    }
    
    /* Rendre le bloc de recherche collapsible sur mobile */
    .search-panel-mobile-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        margin-bottom: 10px;
        cursor: pointer;
        background: #4f46e5;
        color: white;
        padding: 10px 15px;
        border-radius: 6px;
        font-weight: 500;
    }
    
    .search-panel-mobile-toggle i {
        transition: transform 0.3s ease;
    }
    
    .search-panel-mobile-toggle.collapsed i {
        transform: rotate(-90deg);
    }
    
    .search-panel-content {
        transition: max-height 0.3s ease;
        overflow: hidden;
    }
    
    .search-panel-content.collapsed {
        max-height: 0;
        margin: 0;
        padding: 0;
    }

    .search-panel form .search-filters,
    .search-panel .search-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .search-panel .filter-group,
    .search-panel .filter-group-checkbox {
        width: 100%;
        padding-top: 0;
        flex-basis: auto;
        margin-bottom: 8px;
    }
    
    /* Réduire la taille des labels et inputs sur mobile */
    .search-panel .filter-group label {
        font-size: 0.85em;
        margin-bottom: 4px;
    }
    
    .search-panel .filter-group input,
    .search-panel .filter-group select {
        padding: 8px 10px;
        font-size: 0.9em;
    }
    
    .search-panel .search-actions .action-btn,
    .search-panel .search-actions .nav-button {
        padding: 10px 15px;
        font-size: 0.9em;
        margin: 2px 0;
    }
    
     .search-panel .filter-group-checkbox { margin-top: 8px; }


    .contact-card-list { grid-template-columns: 1fr; gap: 15px; } /* Une carte par ligne */
    .client-view-grid { grid-template-columns: 1fr; gap: 15px; }
    .client-form .form-section { padding: 15px; }

    .crm-module-form .form-actions { flex-direction: column; }
    .client-form .form-actions button, .client-form .form-actions .nav-button { /* cibler plus spécifiquement */
        width: 100%;
        margin-bottom: 10px;
    }
    .client-form .form-actions button:last-child, .client-form .form-actions .nav-button:last-child {
        margin-bottom: 0;
    }

    .details-actions-bar { flex-direction: column; }
    .details-actions-bar form, .details-actions-bar .action-btn { width: 100%; margin-bottom: 5px;}
    .details-actions-bar button { width: 100%;}
}

/* --- NOUVEAU: STYLES POUR LA SOUS-MODALE (CATALOGUE) --- */
#sub-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    z-index: 1100; /* Supérieur à la modale principale (1050) */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
#sub-modal-container.modal-hidden {
    opacity: 0;
    visibility: hidden;
}
#sub-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 1;
}
#sub-modal-content-wrapper {
    background-color: var(--card-background);
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 2;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}
#sub-modal-header {
    background-color: var(--modal-header-bg);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
#sub-modal-title {
    font-size: 1.3em;
    margin: 0;
    color: var(--text-color);
    font-weight: 500;
}
#sub-modal-close-button {
    background: none;
    border: none;
    font-size: 1.7em;
    cursor: pointer;
    color: #888;
    padding: 0 5px;
    line-height: 1;
}
#sub-modal-close-button:hover {
    color: var(--danger-color);
}
#sub-modal-body {
    overflow-y: auto;
    flex-grow: 1;
    padding: 20px;
    background-color: #f8f9fa;
}
/* --- AMÉLIORATION LAYOUT FORMULAIRE DEVIS --- */
.devis-grid-container {
    display: grid;
    grid-template-columns: 1fr 380px; /* Colonne principale flexible, colonne latérale à largeur fixe */
    gap: 25px; /* Espace entre les colonnes */
    align-items: flex-start; /* Aligner les éléments en haut */
    margin-bottom: 25px; /* Espace avant la section suivante */
}

/* On retire la marge du bas des sections qui sont dans la grille pour éviter un double espacement */
.devis-grid-main .form-section,
.devis-grid-side .form-section {
    margin-bottom: 0;
}

/* La section latérale a déjà un h4, on peut retirer le conteneur et la marge des totaux */
.devis-grid-side .tva-recap-container {
    margin-bottom: 20px;
}
.devis-grid-side .totals-container {
    max-width: 100%;
    border: none;
    padding: 0;
    background-color: transparent;
}
.devis-grid-side .form-section > h4 {
    font-size: 1.2em;
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}


/* Responsive: sur les écrans plus petits, on repasse sur une seule colonne */
@media (max-width: 1200px) {
    .devis-grid-container {
        grid-template-columns: 1fr;
    }
    .devis-grid-main .form-section {
       margin-bottom: 25px; /* On remet la marge en mode une colonne */
    }
}
/* --- REFRESH VISUEL : TABLEAU DEVIS --- */

/* On retire la bordure de la section qui contient la grille pour mieux l'intégrer */
.devis-grid-main .form-section,
.devis-grid-side .form-section {
    border: none;
    background-color: transparent;
    padding: 0;
}

/* Style général du tableau des lignes */
#lignes-devis-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); /* Ajoute une ombre discrète */
    border-radius: var(--border-radius);
    overflow: hidden; /* Pour que le radius s'applique aux coins */
}

/* En-tête du tableau */
#lignes-devis-table thead th {
    background-color: #495057; /* Un gris sombre élégant */
    color: var(--light-text-color);
    font-weight: 600;
    text-align: left;
    padding: 12px 10px;
    border-bottom: none;
}

/* Lignes du corps du tableau */
#lignes-devis-table tbody tr:nth-child(even) {
    background-color: var(--card-background);
}
#lignes-devis-table tbody tr:nth-child(odd) {
    background-color: #f8f9fa; /* Couleur zébrée légère */
}
#lignes-devis-table tbody tr:hover {
    background-color: #e9ecef; /* Surbrillance au survol */
}

/* Cellules du tableau */
#lignes-devis-table tbody td {
    padding: 2px; /* Padding très réduit car les inputs l'auront */
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

/* Inputs à l'intérieur du tableau pour un look intégré */
#lignes-devis-table .form-control {
    background-color: transparent;
    border: 1px solid transparent; /* Bordure invisible par défaut */
    border-radius: var(--border-radius-small);
    padding: 8px 6px;
    width: 100%;
    height: 100%;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}
#lignes-devis-table .form-control:focus {
    outline: none;
    box-shadow: none;
    background-color: var(--card-background); /* Fond blanc au focus */
    border-color: var(--primary-color); /* Bordure de couleur au focus */
}

/* Style du total de ligne en lecture seule */
#lignes-devis-table .line-total-display {
    font-weight: bold;
    text-align: right;
    padding-right: 10px !important;
}

/* Cellule des actions (poubelle) */
#lignes-devis-table .actions-cell {
    text-align: center;
}
#lignes-devis-table .delete-line-btn {
    opacity: 0.5;
    transition: opacity 0.2s;
}
#lignes-devis-table .delete-line-btn:hover {
    opacity: 1;
}
/* ==========================================================================
   NOUVEAU SYSTÈME DE DESIGN "MDDIGI-BOOTSTRAP" ET STYLES DEVIS
   ========================================================================== */

/* --- 1. Variables & Typographie de base --- */
:root {
    --bs-blue: #0d6efd;
    --bs-green: #198754;
    --bs-gray-100: #f8f9fa;
    --bs-gray-200: #e9ecef;
    --bs-gray-500: #adb5bd;
    --bs-gray-600: #6c757d; /* text-muted */
    --bs-white: #ffffff;
    --bs-font-sans-serif: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-bg: #f0f2f5;
}
body {
    font-family: var(--bs-body-font-family);
}
#modal-body {
    background-color: var(--bs-body-bg);
}
.fw-semibold { font-weight: 600 !important; }
.text-muted { color: var(--bs-gray-600) !important; }
.text-white { color: var(--bs-white) !important; }
.bg-secondary { background-color: var(--bs-gray-600) !important; }
.align-middle { vertical-align: middle !important; }
.cursor-pointer { cursor: pointer !important; }

/* --- 2. Système de Grille (Row/Col) --- */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-top: calc(-1 * var(--bs-gutter-y, 0));
    margin-right: calc(-.5 * var(--bs-gutter-x, 1rem));
    margin-left: calc(-.5 * var(--bs-gutter-x, 1rem));
}
.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: calc(var(--bs-gutter-x, 1rem) * .5);
    padding-left: calc(var(--bs-gutter-x, 1rem) * .5);
    margin-top: var(--bs-gutter-y, 1rem);
}
.g-3 { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }
@media (min-width: 992px) {
    .row-cols-lg-2 > * {
        flex: 0 0 auto;
        width: 50%;
    }
}

/* --- 3. Composant Card --- */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: var(--bs-white);
    background-clip: border-box;
    border: 1px solid var(--border-color);
    border-radius: .375rem;
    margin-bottom: 1.5rem;
}
.card-header {
    padding: .75rem 1.25rem;
    margin-bottom: 0;
    background-color: var(--bs-gray-100);
    border-bottom: 1px solid var(--border-color);
}
.card-header:first-child {
    border-radius: calc(.375rem - 1px) calc(.375rem - 1px) 0 0;
}
.card-body {
    flex: 1 1 auto;
    padding: 1.25rem;
}
.card-title {
    margin-bottom: .5rem;
    font-size: 1.25rem;
    font-weight: 500;
}
.shadow-sm { box-shadow: 0 .125rem .25rem rgba(0,0,0,.075) !important; }

/* --- 4. Formulaires --- */
.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--bs-gray-600);
    margin-bottom: .25rem;
    display: inline-block;
}
.form-control {
    display: block;
    width: 100%;
    padding: .375rem .75rem;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--bs-white);
    background-clip: padding-box;
    border: 1px solid #ced4da;
    appearance: none;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
/* ---- Supprimez ce bloc ---- */


/* --- Variables et base Bootstrap-like --- */
.devis-module {
    --bs-primary: #007bff;
    --bs-secondary: #6c757d;
    --bs-success: #28a745;
    --bs-danger: #dc3545;
    --bs-warning: #ffc107;
    --bs-info: #17a2b8;
    --bs-light: #f8f9fa;
    --bs-white: #ffffff;
    --bs-gray-100: #f8f9fa;
    --bs-gray-200: #e9ecef;
    --bs-gray-300: #dee2e6;
    --bs-gray-600: #6c757d;
    --bs-border-radius: 0.375rem;
    --bs-border-color: #dee2e6;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --- Container principal du devis --- */
.devis-container {
    max-width: 1600px; /* On définit une largeur maximale généreuse */
    margin: 0 auto;    /* On centre ce conteneur dans l'espace disponible */
    padding: 0 15px;   /* On ajoute un peu de marge intérieure pour que le contenu ne colle pas aux bords */
}

.devis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--bs-gray-200);
}

.devis-header h2 {
    margin: 0;
    color: var(--bs-primary);
    font-size: 1.75rem;
    font-weight: 600;
}

.devis-status-badge {
    padding: 0.5rem 1rem;
    border-radius: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-brouillon {
    background-color: var(--bs-gray-200);
    color: var(--bs-gray-600);
}

.status-envoye {
    background-color: var(--bs-info);
    color: white;
}

.status-accepte {
    background-color: var(--bs-success);
    color: white;
}

.status-refuse {
    background-color: var(--bs-danger);
    color: white;
}

/* --- Système de grille et cartes --- */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.row > * {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

.col-md-1 { flex: 0 0 auto; width: 8.333333%; }
.col-md-2 { flex: 0 0 auto; width: 16.666667%; }
.col-md-3 { flex: 0 0 auto; width: 25%; }
.col-md-4 { flex: 0 0 auto; width: 33.333333%; }
.col-md-6 { flex: 0 0 auto; width: 50%; }
.col-md-8 { flex: 0 0 auto; width: 66.666667%; }
.col-md-12, .col-12 { flex: 0 0 auto; width: 100%; }

@media (max-width: 768px) {
    .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-6, .col-md-8 {
        width: 100%;
    }
}

.g-3 > * {
    margin-top: 1rem;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: var(--bs-white);
    background-clip: border-box;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.25rem;
    margin-bottom: 0;
    background-color: var(--bs-gray-100);
    border-bottom: 1px solid var(--bs-border-color);
    border-top-left-radius: calc(var(--bs-border-radius) - 1px);
    border-top-right-radius: calc(var(--bs-border-radius) - 1px);
}

.card-body {
    flex: 1 1 auto;
    padding: 1.25rem;
}

.card-title {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 500;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* --- Formulaires --- */
.form-label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--bs-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: var(--bs-white);
    background-clip: padding-box;
    border: 1px solid var(--bs-border-color);
    appearance: none;
    border-radius: var(--bs-border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: #212529;
    background-color: var(--bs-white);
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-control:disabled {
    background-color: var(--bs-gray-200);
    opacity: 1;
}

/* --- Sélecteurs de produits --- */
.product-selectors {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1.5rem;
    border-radius: var(--bs-border-radius);
    border: 2px dashed var(--bs-border-color);
    transition: all 0.3s ease;
}

.product-selectors:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 0.5rem 1rem rgba(0, 123, 255, 0.15);
}

/* --- Actions et boutons --- */
.devis-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: var(--bs-border-radius);
    transition: all 0.15s ease-in-out;
}

.btn i {
    margin-right: 0.5rem;
}

.btn:only-child i {
    margin-right: 0;
}

.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.btn-secondary {
    background-color: var(--bs-secondary);
    border-color: var(--bs-secondary);
    color: white;
}

.btn-outline-primary {
    color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.btn-outline-primary:hover {
    background-color: var(--bs-primary);
    color: white;
}

.btn-outline-info {
    color: var(--bs-info);
    border-color: var(--bs-info);
}

.btn-outline-info:hover {
    background-color: var(--bs-info);
    color: white;
}

.btn-outline-secondary {
    color: var(--bs-secondary);
    border-color: var(--bs-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--bs-secondary);
    color: white;
}

.btn-outline-danger {
    color: var(--bs-danger);
    border-color: var(--bs-danger);
}

.btn-outline-danger:hover {
    background-color: var(--bs-danger);
    color: white;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-group-vertical {
    display: flex;
    flex-direction: column;
}

.btn-group-vertical .btn {
    border-radius: 0;
    margin-bottom: -1px;
}

.btn-group-vertical .btn:first-child {
    border-top-left-radius: var(--bs-border-radius);
    border-top-right-radius: var(--bs-border-radius);
}

.btn-group-vertical .btn:last-child {
    border-bottom-left-radius: var(--bs-border-radius);
    border-bottom-right-radius: var(--bs-border-radius);
    margin-bottom: 0;
}

/* --- Tableau des lignes de devis --- */
.table-responsive {
    overflow-x: auto;
}

.table-devis {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.table-devis thead th {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    color: white;
    font-weight: 600;
    text-align: center;
    padding: 0.75rem 0.5rem;
    border-bottom: 2px solid #343a40;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-devis tbody tr {
    transition: background-color 0.15s ease;
}

.table-devis tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.table-devis tbody tr:hover {
    background-color: #e3f2fd;
    transform: scale(1.001);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 123, 255, 0.15);
}

.table-devis tbody td {
    padding: 0.25rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--bs-border-color);
}

.table-devis .form-control {
    border: 1px solid transparent;
    background-color: transparent;
    font-size: 0.875rem;
    padding: 0.375rem 0.5rem;
    transition: all 0.15s ease;
}

.table-devis .form-control:focus {
    background-color: white;
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.line-total-display {
    font-weight: 600 !important;
    text-align: right !important;
    background-color: #e8f5e8 !important;
    color: var(--bs-success) !important;
}

.actions-cell {
    width: 80px;
    text-align: center;
    padding: 0.5rem !important;
}

/* --- Section totaux et récapitulatif --- */
.totals-summary {
    font-size: 1rem;
}

.totals-summary .fw-bold {
    font-weight: 700 !important;
}

.text-primary {
    color: var(--bs-primary) !important;
}

.fs-5 {
    font-size: 1.25rem !important;
}

#tva-recap-container .table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

#tva-recap-container .table th {
    background-color: var(--bs-gray-100);
    font-weight: 600;
    padding: 0.5rem;
    border-top: none;
}

#tva-recap-container .table td {
    padding: 0.5rem;
    text-align: right;
}

/* --- Actions du formulaire --- */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
    padding: 1.5rem 0;
    border-top: 2px solid var(--bs-gray-200);
    margin-top: 2rem;
}

/* --- Utilitaires --- */
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-4 { margin-top: 1.5rem !important; }

.me-2 { margin-right: 0.5rem !important; }

.d-flex { display: flex !important; }
.d-none { display: none !important; }

.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }

.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }

.text-muted { color: var(--bs-gray-600) !important; }
.text-white { color: white !important; }

.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

.small { font-size: 0.875rem !important; }

.w-100 { width: 100% !important; }

/* --- Responsive Design --- */
@media (max-width: 992px) {
    .devis-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .product-selectors .row {
        flex-direction: column;
    }
    
    .devis-actions {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .devis-container {
        padding: 0 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-devis {
        font-size: 0.8rem;
    }
    
    .table-devis .form-control {
        font-size: 0.8rem;
        padding: 0.25rem 0.375rem;
    }
    
    .actions-cell .btn-group-vertical .btn {
        padding: 0.125rem 0.25rem;
        font-size: 0.7rem;
    }
    
    .btn-group-vertical {
        gap: 1px;
    }
}

/* --- Animations et transitions --- */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table-devis tbody tr {
    animation: slideInUp 0.3s ease;
}

.card {
    animation: slideInUp 0.4s ease;
}

/* --- États de validation --- */
.form-control.is-invalid {
    border-color: var(--bs-danger);
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control.is-valid {
    border-color: var(--bs-success);
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* --- Focus et accessibilité --- */
.btn:focus,
.form-control:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* --- Amélioration du contraste --- */
.table-devis thead th {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.devis-status-badge {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* --- Styles pour les écrans haute résolution --- */
@media (min-resolution: 2dppx) {
    .table-devis {
        border-width: 0.5px;
    }
}

/* ==========================================================================
   INTEGRATION AVEC LE STYLE EXISTANT
   ========================================================================== */

/* --- Amélioration de l'harmonie avec le design existant --- */
.devis-module .card {
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

.devis-module .card:hover {
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.15);
}

.devis-module .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
}

.devis-module .btn {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0.025em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.devis-module .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.devis-module .btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* --- Cohérence avec les modules existants --- */
.devis-module .module-header {
    border-bottom: 2px solid var(--primary-color);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.devis-module h2,
.devis-module .card-title {
    color: var(--primary-color);
    font-weight: 600;
}

/* --- Responsive pour mobile --- */
@media (max-width: 576px) {
    .devis-module {
        padding: 0.5rem;
    }
    
    .devis-header h2 {
        font-size: 1.5rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .product-selectors {
        padding: 1rem;
    }
    
    .table-devis .form-control {
        padding: 0.125rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .actions-cell {
        width: 60px;
    }
    
    .btn-group-vertical .btn {
        padding: 0.125rem;
        font-size: 0.65rem;
    }
}

/* Styles supplémentaires pour l'intégration du planning */
.modal.planning-modal {
    max-width: 95vw;
    width: 95vw;
}

.modal.planning-modal .modal-content {
    height: 90vh;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.planning-modal .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.modal.planning-modal .planning-container {
    height: 100%;
    max-height: 100%;
    overflow: auto;
    padding: 10px;
}

/* --- STYLES SPÉCIFIQUES MODULE DEVIS --- */
/* ========================================================== */
/* ==   CORRECTIF LARGEUR ZONE UTILE - Module Devis & Autres == */
/* ========================================================== */
.devis-module,
.client-module /* On applique la même règle au module client pour l'harmonie */
{
    max-width: 1600px !important; /* Largeur maximale généreuse */
    width: 95% !important;        /* Prend 95% de l'espace, évite de coller aux bords */
    margin: 0 auto !important;    /* Force le centrage horizontal */
}

/* Exception: le Planning Pro doit utiliser toute la largeur disponible dans la modale */
#modal-container.planning-modal .client-module.planning-pro-container {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
}

/* Poignée pour glisser-déposer */
.drag-handle {
    cursor: grab;
    text-align: center;
    color: #b0b0b0;
    transition: color 0.2s;
    vertical-align: middle;
}
.drag-handle:hover {
    color: var(--primary-color);
}
.ligne-item.dragging {
    opacity: 0.5;
    background: #eaf2ff;
}
.ligne-item.dragging .drag-handle {
    cursor: grabbing;
}


/* Badge de statut du devis */
.badge-status {
    padding: 0.4em 0.8em;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    color: var(--light-text-color);
}
.status-brouillon { background-color: var(--secondary-color); }
.status-envoyé { background-color: var(--primary-color); }
.status-accepté { background-color: var(--success-color); }
.status-refusé { background-color: var(--danger-color); }

/* Grille principale pour Client / Détails */
.devis-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Tableau des lignes de devis */
#lignes-devis-table {
    margin-bottom: 0;
}

#lignes-devis-table th {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--secondary-color);
    background-color: var(--light-color);
    padding: 12px 8px;
}

#lignes-devis-body tr.line-item:hover {
    background-color: #f5f9ff;
}

#lignes-devis-body td {
    vertical-align: middle;
    padding: 4px;
}

/* Poignée pour glisser-déposer */
.drag-handle {
    cursor: grab;
    text-align: center;
    color: #b0b0b0;
    transition: color 0.2s;
}
.drag-handle:hover {
    color: var(--primary-color);
}
.dragging {
    opacity: 0.5;
    background: #e0e7ff;
}

/* Ligne de type "Titre" */
.line-type-titre td {
    padding-top: 15px;
    padding-bottom: 5px;
}
.form-control-title {
    border: none;
    background-color: transparent;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
    padding-left: 0;
}
.form-control-title:focus {
    box-shadow: none;
    background-color: #eef2ff;
}

/* Lignes de type "Produit" */
#lignes-devis-table .form-control {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-small);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#lignes-devis-table .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}
#lignes-devis-table textarea.form-control {
    resize: vertical;
    min-height: 38px;
    line-height: 1.4;
}
.line-total-display {
    font-weight: 500;
    padding-right: 12px !important;
}

.btn-delete-line {
    opacity: 0;
    transition: opacity 0.2s;
}
#lignes-devis-body tr:hover .btn-delete-line {
    opacity: 1;
}

/* Bloc des totaux */
.totals-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    background-color: #f8f9fa;
}
.totals-container .total-line {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1rem;
}
.totals-container .total-line .label {
    font-weight: 500;
    color: var(--secondary-color);
}
.totals-container .total-line .value {
    font-weight: bold;
}
.totals-container .grand-total {
    border-top: 2px solid var(--border-color);
    margin-top: 8px;
    padding-top: 8px;
    font-size: 1.3rem;
    color: var(--primary-color);
}
#tva-recap-container .total-line {
    font-size: 0.9rem;
    padding: 4px 0;
}

/* Sélecteur de produits */
#product-adder-container {
    position: relative;
    display: none; /* Caché par défaut */
}
#product-search-results-wrapper {
    position: relative;
    display: inline-block;
}
#product-search-results {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    width: 350px; /* Largeur de la liste de résultats */
    right: 0;
}
#product-search-results .product-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}
#product-search-results .product-item:hover {
    background-color: #f0f0f0;
}
#product-search-results .product-item:last-child {
    border-bottom: none;
}
#product-search-results .product-ref {
    font-size: 0.8em;
    color: #666;
    display: block;
}


/* Responsive */
@media (max-width: 992px) {
    .devis-grid-container {
        grid-template-columns: 1fr;
    }
}

/* Toolbar pour les lignes de texte */
.text-format-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
    background-color: #f8f9fa;
    padding: 5px;
    border-radius: 4px;
}
.text-format-toolbar .btn-format,
.text-format-toolbar .select-format-size {
    border: 1px solid #ccc;
    background-color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
}
.text-format-toolbar .btn-format.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-hover-color);
}
#lignes-devis-table textarea.ligne-designation-source {
    width: 100%;
    border: 1px solid #ddd;
    padding: 8px;
    min-height: 40px;
    resize: vertical;
    font-size: 11px; /* Taille par défaut */
}
/* --- STYLES POUR LA ZONE DE TEXTE MULTILIGNE DANS LES DEVIS --- */
#lignes-devis-table textarea.ligne-designation-produit {
    width: 100%;
    box-sizing: border-box; /* S'assure que le padding et la bordure sont inclus dans la largeur */
    border: 1px solid #ccc;
    padding: 6px;
    border-radius: 4px;
    vertical-align: top; /* Aligne le texte en haut de la cellule */
    resize: vertical; /* Permet à l'utilisateur de redimensionner la zone verticalement */
    min-height: 34px; /* Hauteur minimale équivalente à un input */
    overflow-y: auto; /* Ajoute une barre de scroll si le contenu dépasse */
    line-height: 1.4; /* Améliore la lisibilité */
}

/* S'assure que toutes les cellules de la ligne sont alignées en haut */
#lignes-devis-table tbody td {
    vertical-align: top;
    padding-top: 8px; /* Ajoute un peu d'espace en haut des cellules */
}
/* --- AMELIORATION TEXTAREA DEVIS --- */
#lignes-devis-table textarea.auto-resize {
    overflow-y: hidden; /* Empêche la barre de défilement de clignoter pendant le redimensionnement */
}
/* --- AJUSTEMENT LARGEUR COLONNES DEVIS --- */
#lignes-devis-table {
    table-layout: fixed; /* Force le tableau à respecter les largeurs que nous définissons */
    width: 100%;
}

/* On cible les en-têtes (th) pour définir la largeur de chaque colonne */
#lignes-devis-table th:nth-child(1) { width: 4%; }  /* Colonne pour la poignée de déplacement */
#lignes-devis-table th:nth-child(2) { width: 12%; } /* Colonne Type */
#lignes-devis-table th:nth-child(3) { width: 35%; } /* Colonne Désignation - LA PLUS LARGE */

/* On ajuste les autres pour qu'elles prennent moins de place */
#lignes-devis-table th:nth-child(4) { width: 8%; }  /* Réf. */
#lignes-devis-table th:nth-child(5) { width: 6%; }  /* Qté */
#lignes-devis-table th:nth-child(6) { width: 7%; }  /* Unité */
#lignes-devis-table th:nth-child(7),
#lignes-devis-table th:nth-child(8),
#lignes-devis-table th:nth-child(9),
#lignes-devis-table th:nth-child(10),
#lignes-devis-table th:nth-child(11) {
    width: auto; /* Laisse les colonnes de prix se répartir l'espace restant */
}

/* On s'assure que la zone de texte remplit bien sa cellule maintenant élargie */
#lignes-devis-table .ligne-designation-produit,
#lignes-devis-table .ligne-designation-source {
    width: 100%;
    box-sizing: border-box; /* S'assure que le padding est inclus dans la largeur */
}
/* ============================================ */
/* STYLE POUR LA MODALE D'IMPORT                */
/* ============================================ */

.modal-overlay {
    position: fixed;
    z-index: 1050; /* Doit être supérieur à tout le reste */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5); /* Fond noir semi-transparent */
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px; /* Largeur maximale */
    border-radius: 5px;
    position: relative;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 1rem;
}

.modal-title {
    margin: 0;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
}

.modal-body {
    padding: 20px 0;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
}

#quoteSearchResults .result-item {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#quoteSearchResults .result-item:hover {
    background-color: #f1f1f1;
}
/* NOUVEAU STYLE POUR LES BOUTONS D'INFORMATION */
.btn-info {
    background-color: var(--info-color); /* Utilise la variable de couleur 'info' (#17a2b8) */
    color: var(--light-text-color) !important; /* Force le texte en blanc pour une lisibilité maximale */
}

.btn-info:hover {
    background-color: #138496; /* Une version un peu plus foncée de la couleur info pour le survol */
    opacity: 0.9;
}

/* /public_html/crm/style.css */

/* ... tout votre style existant ... */

/* Style pour les notifications globales (toast) */
.global-feedback {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -150%); /* Position initiale hors de l'écran */
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    color: white;
    font-weight: 600;
    transition: transform 0.5s ease-in-out;
    max-width: 90%;
    text-align: center;
}

.global-feedback.show {
    transform: translate(-50%, 0); /* Position finale à l'écran */
}

.global-feedback.success {
    background-color: #28a745;
    border-left: 5px solid #218838;
}

.global-feedback.error {
    background-color: #dc3545;
    border-left: 5px solid #c82333;
}

.global-feedback p {
    margin: 0;
    padding: 0;
}
/* AJOUTEZ CES STYLES À VOTRE style.css */

/* Notifications globales (toast) */
.global-feedback {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -150%);
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    color: white;
    font-weight: 500;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90%;
    min-width: 300px;
    backdrop-filter: blur(10px);
}

.global-feedback.show {
    transform: translate(-50%, 0);
}

.global-feedback.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.global-feedback.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.global-feedback.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.feedback-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    position: relative;
}

.feedback-content i:first-child {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.feedback-content span {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
}

.feedback-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.feedback-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive pour mobile */
@media (max-width: 768px) {
    .global-feedback {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: translateY(-150%);
        min-width: auto;
        max-width: none;
    }
    
    .global-feedback.show {
        transform: translateY(0);
    }
}

/* ========================================================== */
/* == NOUVEAU DESIGN - GESTION D'ENTREPRISE (STYLE MODERNE) = */
/* ========================================================== */

.entreprise-form-container {
    padding: 10px;
}

.card.modern-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 25px;
    background-color: #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    overflow: hidden; /* Pour que le radius s'applique au header */
}

.modern-card .card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
}

.modern-card .card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

.modern-card .card-header h3 i {
    margin-right: 12px;
    font-size: 1rem;
}

.modern-card .card-body {
    padding: 20px;
}

.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 25px; /* Espace vertical / horizontal */
}

.form-group-vertical {
    display: flex;
    flex-direction: column;
}

.form-group-vertical label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 6px;
}

.form-group-vertical input[type="text"],
.form-group-vertical input[type="email"],
.form-group-vertical textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.form-group-vertical input:focus,
.form-group-vertical textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
    outline: none;
}
.form-group-vertical textarea {
    resize: vertical;
    min-height: 50px;
}

/* Spécifique à la carte Logo */
.logo-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.logo-preview-img {
    max-height: 120px;
    max-width: 100%;
    object-fit: contain;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px;
    background-color: #f8f9fa;
}

/* Boutons */
.form-actions-centered {
    text-align: center;
    padding: 20px 0;
}

.btn.btn-lg {
    padding: 12px 30px;
    font-size: 1.1rem;
}

/* Utilitaires */
.d-none {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .form-grid-2col {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .module-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) { .dashboard-card.kpi-card { flex-basis: 100%; } }

/* ========================================================== */
/* == NOUVEAU DESIGN MODERNE DASHBOARD (PRIORITÉ 1) ======== */
/* ========================================================== */

.dashboard-modern {
    padding: 20px;
    background: linear-gradient(135deg, #f0f2f5 0%, #e9ecef 100%);
    min-height: calc(100vh - var(--top-bar-height, 60px));
    font-family: var(--bs-font-sans-serif);
}

.dashboard-header {
    background: white;
    color: var(--text-color);
    padding: 1.5rem 2rem;
    margin: -20px -20px 2rem -20px;
    text-align: left;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-bottom: 1px solid var(--border-color);
}


.dashboard-header-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-summary {
    text-align: right;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.dashboard-summary .summary-item {
    margin-bottom: 0.5rem;
}

.dashboard-summary .summary-value {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.dashboard-header h1 {
    margin: 0 0 0.25rem 0;
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.dashboard-header p {
    margin: 0;
    font-size: 1rem;
    color: var(--secondary-color);
}

/* === CARTES AVEC BANDES COLORÉES === */
.section-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--section-color);
    transition: all 0.3s ease;
}

.section-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.section-card.ca-section { --section-color: #28a745; }
.section-card.funnel-section { --section-color: #007bff; }
.section-card.clients-section { --section-color: #fd7e14; }
.section-card.activity-section { --section-color: #6f42c1; }
.section-card.pending-section { --section-color: #ffc107; }
.section-card.payments-section { --section-color: #17a2b8; }
.section-card.urgent-section { --section-color: #dc3545; }

.section-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.section-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--section-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.section-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #2c3e50;
}

.section-body {
    padding: 1.5rem;
}

/* === NOUVELLE GRILLE PRINCIPALE === */
.dashboard-main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    padding-top: 1rem;
}

.dashboard-chart-section {
    grid-column: 1 / -1;
}
/* === GRILLE DES KPIs === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    border: 1px solid var(--border-color);
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}


.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: var(--kpi-color);
}

.kpi-card.primary { --kpi-color: #007bff; }
.kpi-card.success { --kpi-color: #28a745; }
.kpi-card.info { --kpi-color: #17a2b8; }
.kpi-card.warning { --kpi-color: #ffc107; }
.kpi-card.secondary { --kpi-color: #6c757d; }
.kpi-card.accent { --kpi-color: #6f42c1; }


.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--kpi-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 0.25rem 0;
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
    margin: 0 0 0.25rem 0;
}

.kpi-sublabel {
    font-size: 0.8rem;
    color: #868e96;
    margin: 0;
}

.text-danger { color: #dc3545 !important; }

/* === GRILLE PRINCIPALE === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2.5rem;
    padding: 0 2rem;
    margin-bottom: 3rem;
}

.dashboard-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    overflow: hidden;
    border: none;
    border-left: 5px solid #007bff;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
}

.dashboard-card:hover {
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.dashboard-card.urgent {
    border-left: 4px solid #dc3545;
}

.dashboard-card.chart-card {
    grid-column: span 2;
}


/* === ENTONNOIR DE VENTE === */
.funnel-item {
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
    position: relative;
}
.funnel-item:last-child {
    margin-bottom: 0;
}

.funnel-label {
    flex: 1;
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.funnel-value {
    font-weight: 700;
    color: #2c3e50;
    margin-left: 1rem;
    min-width: 50px;
    text-align: right;
}

.conversion-rate {
    font-size: 0.8rem;
    color: #28a745;
    font-weight: 500;
}

.funnel-bar-bg {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    margin-top: 4px;
    overflow: hidden;
}

.funnel-bar {
    height: 100%;
    background: var(--section-color);
    border-radius: 4px;
    transition: width 1s ease-in-out;
}


/* === LISTES === */
.client-list, .activity-timeline, .pending-list, .payment-list, .overdue-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}


.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.timeline-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.timeline-item:first-child{
    padding-top: 0;
}

.timeline-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.timeline-icon.devis {
    background: #007bff;
}

.timeline-icon.facture {
    background: #28a745;
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

.timeline-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.timeline-subtitle {
    color: #6c757d;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.timeline-date {
    font-size: 0.8rem;
    color: #868e96;
}

/* === ÉTATS VIDES === */
.empty-state {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 2rem;
    background-color: #f8f9fa;
    border-radius: 6px;
}

/* === GRAPHIQUES === */
#monthlyChart {
    height: 280px !important;
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .dashboard-chart-section {
        grid-column: span 1;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        padding: 1.5rem 1rem;
        margin: -20px -20px 1.5rem -20px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dashboard-header h1 {
        font-size: 1.8rem;
    }
    
    .kpi-grid, .dashboard-main-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0;
    }
    
    .kpi-card {
        padding: 1rem;
        gap: 1rem;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .section-body {
        padding: 1rem;
    }
}


/* === ANIMATIONS === */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card, .section-card {
    animation: slideInUp 0.5s ease-out forwards;
    opacity: 0;
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }
.kpi-card:nth-child(5) { animation-delay: 0.25s; }
.kpi-card:nth-child(6) { animation-delay: 0.3s; }

.section-card:nth-child(1) { animation-delay: 0.1s; }
.section-card:nth-child(2) { animation-delay: 0.2s; }
.section-card:nth-child(3) { animation-delay: 0.3s; }


/* === BADGES COLORÉS === */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.status-badge.accepte { background-color: #d4edda; color: #155724; }
.status-badge.envoye { background-color: #cce5ff; color: #004085; }
.status-badge.attente { background-color: #fff3cd; color: #856404; }
.status-badge.brouillon { background-color: #e2e3e5; color: #383d41; }
.status-badge.refuse { background-color: #f8d7da; color: #721c24; }

/* === AMÉLIORATIONS LISTES === */
.enhanced-list-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}
.enhanced-list-item:last-child{
    margin-bottom: 0;
}
.enhanced-list-item:hover {
    background-color: #e9ecef;
    transform: translateX(3px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--item-color, #dee2e6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-right: 1rem;
    flex-shrink: 0;
}

.item-content {
    flex: 1;
    min-width: 0;
}

.item-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
}

.item-subtitle {
    font-size: 0.85rem;
    color: #6c757d;
}

.item-value {
    text-align: right;
    flex-shrink: 0;
    padding-left: 1rem;
}

.item-amount {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
}

/* === AMÉLIORATION LIENS DANS LES LISTES DU DASHBOARD === */
.enhanced-list-item .item-title a {
    text-decoration: none;
    color: inherit; /* Utilise la couleur du parent .item-title */
    transition: color 0.2s ease;
}

.enhanced-list-item .item-title a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}
/* ================================================== */
/* == CORRECTIF AFFICHAGE STATUTS LISTE DEVIS == */
/* ================================================== */

/* Style de base pour tous les badges de statut */
.badge-status {
    padding: 0.3em 0.8em;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    border: 1px solid transparent;
}

/* Statut : Accepté */
.badge-status.status-accepte {
    background-color: #d1fae5; /* Fond vert très clair */
    color: #065f46;            /* Texte vert foncé */
    border-color: #a7f3d0;
}

/* Statut : Envoyé */
.badge-status.status-envoye {
    background-color: #dbeafe; /* Fond bleu très clair */
    color: #1e40af;            /* Texte bleu foncé */
    border-color: #bfdbfe;
}

/* Statut : Refusé */
.badge-status.status-refuse {
    background-color: #fee2e2; /* Fond rouge très clair */
    color: #991b1b;            /* Texte rouge foncé */
    border-color: #fecaca;
}

/* Statut : Annulé */
.badge-status.status-annule {
    background-color: #f3f4f6; /* Fond gris clair */
    color: #4b5563;            /* Texte gris foncé */
    border-color: #e5e7eb;
}

/* Statut : Brouillon */
.badge-status.status-brouillon {
    background-color: #e5e7eb; /* Fond gris */
    color: #374151;            /* Texte gris foncé */
    border-color: #d1d5db;
}

/* Statut : Facturé */
.badge-status.status-facture {
    background-color: #e0e7ff; /* Fond indigo clair */
    color: #3730a3;            /* Texte indigo foncé */
    border-color: #c7d2fe;
}
/* /public_html/crm/style.css */

/* === BOUTONS DE SÉLECTION DE PÉRIODE POUR GRAPHIQUE === */
.chart-period-selector {
    margin-left: auto; /* Pousse les boutons à droite */
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: #e9ecef;
    border-radius: 20px;
    padding: 4px;
}

.period-btn {
    background-color: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.period-btn:hover {
    background-color: #dce1e6;
    color: var(--primary-color);
}

.period-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
}

/* Ajustement pour mobile */
@media (max-width: 768px) {
    .section-header {
        flex-wrap: wrap; /* Permet aux éléments de passer à la ligne */
    }
    .chart-period-selector {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }
}
/* --- STYLES POUR LE GLISSER-DÉPOSER (SORTABLE) DES LIGNES DE DEVIS --- */

/* Style de la poignée de déplacement pour indiquer qu'elle est active */
.drag-handle {
    cursor: grab;
    color: #a0aec0;
    transition: color 0.2s ease;
}

.drag-handle:hover {
    color: #2d3748;
}

/* Style de l'indicateur de position (où la ligne sera déposée) */
.sortable-placeholder {
    height: 60px; /* Hauteur approximative d'une ligne */
    background-color: #ebf8ff;
    border: 2px dashed #90cdf4;
    visibility: visible !important;
}

.sortable-placeholder td {
    border-style: none !important; /* Pour que le style pointillé ressorte */
}

/* Style de la ligne en cours de déplacement (le "helper") */
.ui-sortable-helper {
    display: table; /* Force l'élément à se comporter comme une ligne de tableau */
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    background: white;
}

.ui-sortable-helper td {
    border-color: #cbd5e0;
}
/* ---- DEBUT : Style pour les lignes de désignation dans les devis ---- */
#devis-lignes-body textarea.line-designation {
    min-height: 38px; /* Hauteur minimale pour correspondre à un champ de texte standard */
    height: auto;     /* La hauteur sera gérée par le JavaScript */
    overflow-y: hidden; /* Cache la barre de défilement inutile */
    resize: none;     /* Désactive la poignée de redimensionnement manuelle */
    line-height: 1.4; /* Améliore la lisibilité */
    padding-top: 8px; /* Ajuste l'alignement vertical du texte */
    padding-bottom: 8px;
    box-sizing: border-box; /* Assure que le padding est inclus dans la hauteur */
    width: 100%; /* S'assurer qu'il prend toute la largeur de la cellule */
}
/* ---- FIN : Style pour les lignes de désignation ---- */
/*
==========================================================================
== NOUVEAU CORRECTIF DÉFINITIF : HAUTEUR CELLULES DEVIS (26/06/2025) ==
        overflow-x: auto !important;
    }
*/

/* 1. On cible la CELLULE (td) contenant la désignation pour la rendre compacte. */
.table-devis td.col-designation {
    /* Annule les paddings verticaux qui pourraient ajouter de l'espace */
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    /* Force la hauteur de ligne au minimum pour la cellule elle-même */
    line-height: 1.2 !important; 
}

/* 2. On s'assure que la boîte Trumbowyg n'ajoute AUCUN espace superflu. */
.table-devis .trumbowyg-box {
    /* Annule toute marge externe */
    margin: 0 !important;
    
    /* Force sa hauteur à n'être déterminée QUE par son contenu */
    min-height: 0 !important;
    height: auto !important;

    /* On garde une bordure propre pour l'ensemble */
    border: 1px solid #D1D5DB; 
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    
    /* On utilise flexbox pour un meilleur contrôle interne */
    display: flex;
    flex-direction: column;
}

/* 3. On s'assure que la zone d'écriture peut grandir à l'intérieur de la boîte */
.table-devis .trumbowyg-editor {
    flex-grow: 1; /* Permet à l'éditeur de prendre l'espace vertical disponible */
    border: none; /* Pas de double bordure */
    padding: 8px 10px !important; /* On garde un padding interne confortable */
    min-height: 24px !important; /* Hauteur minimale de la zone de texte elle-même */
}

/* 4. On s'assure que la barre d'outils est compacte */
.table-devis .trumbowyg-button-pane {
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}
/* ============================================ */
/* == STYLES GLOBAUX POUR LA MODALE D'IMPORT == */
/* ============================================ */

/* Styles pour la modale d'importation de lignes de devis.
   Placés ici pour être globaux et éviter les "flashs" au chargement. */
.import-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10000;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    background: rgba(0,0,0,0.6);

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Classe ajoutée par JavaScript pour rendre la modale visible */
.import-modal.is-visible {
    opacity: 1;
    visibility: visible;
}
/* ================================================== */
/* == STYLES POUR LE CONTENU DE LA MODALE D'IMPORT == */
/* ================================================== */

/* Définit la structure flexible pour le contenu de la modale */
.import-modal-content {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    overflow: hidden; /* Empêche le contenu de déborder */
}

/* En-tête de la modale */
.import-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0; /* Empêche l'en-tête de rétrécir */
}

.import-modal-header h4 {
    margin: 0;
    font-size: 1.2rem;
}

/* Corps de la modale */
.import-modal-body {
    flex-grow: 1; /* Fait en sorte que le corps prenne toute la place disponible */
    overflow-y: auto; /* Ajoute une barre de défilement si nécessaire */
    padding: 20px;
    display: flex;
    flex-direction: column; /* Assure que le contenu du corps est bien vertical */
}

/* Pied de page de la modale */
.import-modal-footer {
    padding: 15px 20px;
    text-align: right;
    border-top: 1px solid #e5e5e5;
    background: #f8f9fa;
    flex-shrink: 0; /* Empêche le pied de page de rétrécir */
}

/* Conteneur pour la liste des lignes à importer (corrige le bug principal) */
.lines-to-import-container {
    flex-grow: 1; /* Prend l'espace vertical restant dans le corps */
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow-y: auto; /* Barre de défilement si beaucoup de lignes */
    margin-bottom: 1rem; /* Espace avant les boutons du pied de page */
}

/* En-tête de la liste (avec "Tout sélectionner") */
.line-selection-header {
    padding: 10px 15px;
    background: #f8f9fa;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    position: sticky; /* Garde l'en-tête visible en haut lors du scroll */
    top: 0;
}
.line-selection-header input[type="checkbox"] {
    margin-right: 10px;
}

/* Chaque ligne dans la liste d'import */
.line-to-import-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}
.line-to-import-item label {
    flex-grow: 1;
    cursor: pointer;
    margin: 0;
}

/* Styles pour la première étape (recherche de devis) pour la cohérence */
.search-results-container {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}
.result-item:hover {
    background-color: #f0f8ff;
}
.result-item small {
    display: block;
    color: #666;
    margin-top: 4px;
}
/* Fichier à modifier : style.css */

.clickable-kpi {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.clickable-kpi:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
/* Rendre les boutons désactivés visuellement évidents sur tout le site */
button:disabled,
input[type="submit"]:disabled {
    opacity: 0.5; /* Réduit l'opacité pour le griser */
    cursor: not-allowed !important; /* Affiche une icône d'interdiction au survol */
    pointer-events: none; /* Empêche toute interaction (clic, survol, etc.) */
}
/* --- NOUVEAU : STYLE POUR MENU DÉROULANT --- */
.crm-top-navigation .dropdown-li {
    position: relative;
}

.crm-top-navigation .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #ffffff;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1051; /* Augmenté pour passer au-dessus de la modale (qui est à 1050) */
    list-style: none;
    padding: 5px 0;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.crm-top-navigation .dropdown-li:hover .dropdown-menu {
    display: block;
}

.crm-top-navigation .dropdown-menu li {
    margin: 0;
}

.crm-top-navigation .dropdown-item {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    font-size: 0.9em;
    white-space: nowrap;
}

.crm-top-navigation .dropdown-item:hover {
    background-color: #f2f2f2;
    color: var(--primary-color);
}

.crm-top-navigation .dropdown-toggle::after {
    content: ' ▼';
    font-size: 0.6em;
    margin-left: 5px;
    display: inline-block;
}
/* Style final pour surligner UNIQUEMENT la boîte de l'éditeur active */
.trumbowyg-box.highlight-editor {
    background-color: #f0f8ff !important;
    border-color: #007bff !important; 
    box-shadow: 0 0 6px rgba(0, 123, 255, 0.3) !important;
    /* Animation pour le changement de style */
    transition: all 0.4s ease-in-out;
}

/* Style pour afficher correctement le placeholder dans l'éditeur */
.trumbowyg-editor.trumbowyg-placeholder::before {
    content: attr(placeholder);
    position: absolute;
    color: #888; /* Couleur du texte du placeholder */
    font-style: italic;
    cursor: text;
}
/* Style pour afficher correctement le placeholder dans l'éditeur Trumbowyg */
.trumbowyg-editor.trumbowyg-placeholder::before {
    content: attr(placeholder);
    position: absolute;
    color: #999; /* Couleur grise, standard pour les placeholders */
    font-style: italic;
    cursor: text;
    pointer-events: none; /* Permet de cliquer "à travers" le placeholder */
}
/* ========================================================================
   PLACEHOLDER TRUMBOWYG AMÉLIORÉ - MODIFIÉ POUR PLUS DE VISIBILITÉ
   ======================================================================== */

/* Style de base pour l'éditeur avec placeholder */
.trumbowyg-editor.trumbowyg-placeholder {
    position: relative;
}

/* Le placeholder lui-même - VERSION AMÉLIORÉE */
.trumbowyg-editor.trumbowyg-placeholder::before {
    content: attr(placeholder);
    position: absolute;
    top: 8px;
    left: 12px;
    color: #6c757d !important;
}

/* Placeholder plus discret au focus mais toujours visible */
.trumbowyg-editor.trumbowyg-placeholder:focus::before {
    opacity: 0.5 !important;
    color: #999 !important;
}

/* Placeholder spécifique dans les tableaux de devis */
.table-devis .trumbowyg-editor.trumbowyg-placeholder::before,
#devis-lignes-body .trumbowyg-editor.trumbowyg-placeholder::before {
    top: 8px !important;
    left: 10px !important;
    font-size: 13px !important;
    color: #6c757d !important;
}

/* S'assurer que le placeholder disparaît quand il y a du contenu */
.trumbowyg-editor:not(.trumbowyg-placeholder)::before {
    display: none !important;
}

/* Responsive pour mobile */
@media (max-width: 768px) {
    .trumbowyg-editor.trumbowyg-placeholder::before {
        font-size: 12px !important;
        top: 6px !important;
        left: 8px !important;
    }
}
.search-actions {
    display: flex;
    align-items: flex-end; /* Aligne les éléments sur le bas */
    gap: 15px; /* Espace entre les éléments */
    flex-wrap: wrap;
}
/* ================================================== */
/* == STYLES POUR LES CELLULES D'ACTION (DEVIS/FACTURES) == */
/* ================================================== */

/* Règle pour la cellule (<td>) elle-même */
.actions-cell {
    vertical-align: middle; /* Centre le contenu verticalement */
    text-align: center;     /* Centre le conteneur des boutons */
    min-width: 100px;       /* Donne un peu d'espace aux boutons */
}

/* Conteneur interne qui aligne les boutons côte à côte */
.action-buttons-wrapper {
    display: inline-flex;
    gap: 8px; /* Espace entre les boutons */
}

/* Style pour le bouton PDF (utilisé dans les devis et factures) */
.client-module .action-btn.pdf-btn {
    background-color: var(--danger-color);
}
/* Style pour les boutons d'action rapide (émettre facture, envoyer devis) */
.client-module .action-btn.issue-btn {
    background-color: #2a9d8f; /* Couleur Sarcelle (Teal) */
}
/* ================================================== */
/* == STYLE POUR LIGNES DE TABLEAU CLIQUABLES      == */
/* ================================================== */

.clickable-row {
    cursor: pointer; /* Curseur par défaut pour la ligne */
    transition: background-color 0.2s ease;
}

/* RÈGLE CORRIGÉE : Force le curseur main sur les cellules de la ligne */
.clickable-row td {
    cursor: pointer;
}

.clickable-row:hover {
    background-color: #f5f9ff !important; /* Couleur de surbrillance bleu très clair */
}
/* --- Simulation de page A4 pour les éditeurs (V6 - Superposition Fiable) --- */
:root {
    /* RÉGLAGE CENTRALISÉ : Hauteur VISUELLE d'une page dans l'éditeur. */
    --a4-visual-page-height: 275mm;
    --a4-page-margin: 15mm;
}

.trumbowyg-a4-wrapper {
    background-color: #f0f2f5;
    padding: 30px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    overflow: auto;
}

/* La boîte Trumbowyg devient la page et une ancre de positionnement */
.trumbowyg-a4-wrapper .trumbowyg-box {
    width: 210mm;
    margin: 0 auto;
    border: 1px solid #ccc;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background-color: #ffffff;
    position: relative; /* Indispensable pour le pseudo-élément */
}

/* L'éditeur redevient un simple champ de texte blanc */
.trumbowyg-a4-wrapper .trumbowyg-editor {
    min-height: calc(var(--a4-visual-page-height) * 2); /* Hauteur pour voir au moins 2 pages */
    padding: var(--a4-page-margin);
    box-sizing: border-box;
    background-color: white; /* Fond blanc solide, on ne se bat plus avec */
    background-image: none; /* On s'assure qu'il n'y a plus de fond d'image */
    border: none;
    box-shadow: none;
}

/* LA SOLUTION : On superpose un calque avec les lignes par-dessus l'éditeur */
.trumbowyg-a4-wrapper .trumbowyg-box::before {
    content: '';
    position: absolute;
    /* On positionne le calque exactement sur la zone d'écriture, en tenant compte des marges */
    top: var(--a4-page-margin);
    left: var(--a4-page-margin);
    right: var(--a4-page-margin);
    bottom: 0; /* On le laisse s'étendre vers le bas */
    
    /* On dessine les lignes sur ce calque */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--a4-visual-page-height) - 1px),
        #d1d1d1 calc(var(--a4-visual-page-height) - 1px),
        #d1d1d1 var(--a4-visual-page-height)
    );
    
    /* LA LIGNE LA PLUS IMPORTANTE : rend le calque invisible pour la souris */
    pointer-events: none;
    z-index: 2; /* S'assure qu'il est au-dessus de l'éditeur mais sous le curseur de texte */
}
/* --- Styles pour la page de sélection de modèles de document --- */
.template-selection-container {
    padding: 24px;
    background-color: #f9fafb;
}

.template-selection-header {
    text-align: center;
    margin-bottom: 32px;
}

.template-selection-header h2 {
    font-size: 1.6rem;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.template-selection-header p {
    color: #6b7280;
    max-width: 550px;
    margin: 0 auto;
    font-size: 1rem;
}

.template-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background-color: #ffffff;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s ease-in-out;
    text-align: center;
    min-height: 160px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.07);
    border-color: #4f46e5;
    color: #4f46e5;
}

.template-card .icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: #4f46e5;
    line-height: 1;
}

.template-card .title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.4;
}

.template-card.primary {
    background-color: #4f46e5;
    color: white;
    border-color: #4f46e5;
}
.template-card.primary .icon {
    color: white;
}
.template-card.primary:hover {
    background-color: #4338ca;
    color: white;
}

.template-selection-footer {
    text-align: center;
    margin-top: 20px;
}
/* --- Variations de couleur pour les cartes de modèle --- */
.template-card.variant-green:hover { border-color: #34d399; color: #059669; }
.template-card.variant-green .icon { color: #34d399; }

.template-card.variant-blue:hover { border-color: #60a5fa; color: #2563eb; }
.template-card.variant-blue .icon { color: #60a5fa; }

.template-card.variant-orange:hover { border-color: #fb923c; color: #ea580c; }
.template-card.variant-orange .icon { color: #fb923c; }

.template-card.variant-teal:hover { border-color: #2dd4bf; color: #0d9488; }
.template-card.variant-teal .icon { color: #2dd4bf; }

/* Ajout d'un sous-titre pour l'incitation à l'action */
.template-card .action-text {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 8px;
    color: #9ca3af;
    transition: color 0.2s ease-in-out;
}

.template-card:hover .action-text {
    color: inherit; /* Le texte prend la couleur de la carte au survol */
}
/* ============================================= */
/* == NOUVEAU DESIGN MODULE TÂCHES (TODO V2)  == */
/* ============================================= */

.todo-module-v2 .module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.todo-module-v2 .module-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #374151;
}

.todo-module-v2 .header-icon {
    color: #4f46e5;
}

.todo-list-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.todo-item {
    display: flex;
    align-items: center;
    background-color: #fff;
    border-radius: 8px;
    padding: 15px 20px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.todo-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.todo-status {
    flex-shrink: 0;
    margin-right: 20px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.status-a_faire {
    background-color: #ef4444; /* Rouge */
}

.status-badge.status-fait {
    background-color: #22c55e; /* Vert */
}

.todo-content {
    flex-grow: 1;
}

.todo-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 5px 0;
}

.todo-description {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0 0 10px 0;
}

.todo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.8rem;
    color: #4b5563;
}

.todo-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.todo-meta .fas {
    color: #9ca3af;
}

.todo-actions {
    display: flex;
    gap: 8px;
    margin-left: 20px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.action-btn:hover {
    opacity: 0.8;
}

.action-btn.success { background-color: #22c55e; }
.action-btn.warning { background-color: #f59e0b; }
.action-btn.primary { background-color: #3b82f6; }
.action-btn.danger  { background-color: #ef4444; }


/* ----- Améliorations visuelles pour les boutons dans la vue détail d'un contrat ----- */
/* Cible uniquement les boutons présents dans la zone d'actions des échéances de contrat */
.contrat-edit-layout .actions-container .action-btn,
.contrat-edit-layout .actions-container a.action-btn {
    width: auto;
    height: auto;
    min-width: 110px;
    padding: 8px 12px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    justify-content: center;
}

/* Donner un style neutre (fond léger + bordure) uniquement si le bouton n'a pas
   déjà une classe de couleur comme success-action / warning-action / delete-action */
.contrat-edit-layout .actions-container .action-btn:not(.success-action):not(.warning-action):not(.primary-action):not(.delete-action):not(.edit-btn):not(.view-action) {
    background: #f3f4f6;
    color: #111;
    border: 1px solid #d1d5db;
}

.contrat-edit-layout .actions-container .action-btn i { margin-right: 6px; }

/* S'assurer que les boutons avec classes colorées gardent leurs couleurs mais profitent
   aussi du padding/arrondi appliqué ci-dessus */
.contrat-edit-layout .actions-container .action-btn.success-action { background-color: #28a745; color: #fff; border: none; }
.contrat-edit-layout .actions-container .action-btn.warning-action { background-color: #ffc107; color: #000; border: none; }
.contrat-edit-layout .actions-container .action-btn.primary-action { background-color: #007bff; color: #fff; border: none; }

/* Style pour la vue vide */
.empty-state {
    text-align: center;
    padding: 60px 40px;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 2px dashed #e5e7eb;
}

.empty-state-icon {
    font-size: 3rem;
    color: #22c55e;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: #374151;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 1rem;
    color: #6b7280;
}
/* Style pour les tâches urgentes */
.todo-item.urgent {
    border-left: 5px solid #ef4444; /* Bordure rouge épaisse à gauche */
    position: relative;
}

.urgent-indicator {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* ============================================= */
/* == STYLE MENU DEROULANT CONFIGURATION      == */
/* ============================================= */

/* Conteneur principal de l'élément de menu */
.nav-item-dropdown {
    position: relative; /* Nécessaire pour positionner le menu déroulant par rapport à cet élément */
    display: flex;
    min-width: 0;
}

/* Le menu déroulant lui-même (caché par défaut) */
.nav-item-dropdown .dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #ffffff;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 100;
    border-radius: 4px;
    padding: 5px 0;
    border: 1px solid #ddd;
}

/* Affichage du menu au survol de l'élément principal */
.nav-item-dropdown:hover .dropdown-content {
    display: block;
}

/* Style des liens dans le menu déroulant */
.nav-item-dropdown .dropdown-content a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    font-size: 0.9rem;
}

/* Style des liens au survol */
.nav-item-dropdown .dropdown-content a:hover {
    background-color: #f2f2f2;
}

@media (min-width: 769px) {
    .crm-top-bar {
        flex-wrap: nowrap !important;
        flex-direction: row !important;
        justify-content: flex-start;
        align-items: center;
        gap: 12px;
        overflow: visible;
    }

    .top-bar-logo {
        flex: 0 0 auto;
    }

    .mobile-top-devis,
    .crm-menu-toggle {
        display: none !important;
    }

    .crm-top-navigation {
        display: flex !important;
        justify-content: flex-start !important;
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
        overflow-y: visible;
    }

    .crm-top-navigation ul {
        min-width: 0 !important;
        max-width: 100%;
        flex-wrap: nowrap;
        align-items: center;
        white-space: nowrap;
    }

    .crm-top-navigation li {
        flex: 0 0 auto;
    }

    .crm-top-navigation .nav-button {
        padding: 9px 9px;
        font-size: 0.86em;
        white-space: nowrap;
    }

    .crm-top-navigation .nav-button.icon-only .nav-button-text {
        display: none;
    }

    .crm-top-navigation .nav-button.icon-only i,
    .crm-top-navigation .nav-button.icon-only .nav-icon {
        margin-right: 0;
    }

    .nav-item-dropdown .dropdown-content,
    .crm-top-navigation .dropdown-content {
        display: none !important;
        position: absolute !important;
        right: 0;
        top: 100%;
        min-width: 240px;
        z-index: 1080;
    }

    .nav-item-dropdown:hover .dropdown-content,
    .nav-item-dropdown:focus-within .dropdown-content {
        display: block !important;
    }

    .top-bar-user-area {
        margin-left: 12px;
        flex: 0 0 auto;
        white-space: nowrap;
    }
}
/* ================================================== */
/* == CORRECTION BOUTONS FILTRER/EFFACER ========== */
/* ================================================== */

/* Amélioration du conteneur des actions de recherche */
.search-panel .search-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px; /* Un peu d'espace au-dessus */
    flex-shrink: 0; /* Empêche la compression du bloc */
    flex-wrap: wrap; /* NOUVEAU : Permet aux boutons de passer à la ligne si nécessaire */
    min-width: 0; /* NOUVEAU : Permet la flexibilité */
}

/* Style uniforme pour tous les boutons dans les actions de recherche */
.search-panel .search-actions .action-btn,
.search-panel .search-actions .nav-button {
    /* Assure que le texte ne se coupe jamais */
    white-space: nowrap;
    
    /* Taille uniforme pour tous les boutons */
    min-width: 100px; /* NOUVEAU : Largeur minimale garantie */
    padding: 8px 16px; /* NOUVEAU : Padding plus généreux et uniforme */
    
    /* Style visuel uniforme */
    font-size: 0.9em;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center; /* NOUVEAU : Centre le contenu */
    
    /* Transition douce */
    transition: all 0.2s ease;
    
    /* Évite que les boutons rétrécissent */
    flex-shrink: 0;
}

/* Style spécifique pour le bouton Filtrer */
.search-panel .search-actions .action-btn {
    background-color: var(--primary-color);
    color: var(--light-text-color);
}

.search-panel .search-actions .action-btn:hover {
    background-color: var(--primary-hover-color, #0056b3);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Style spécifique pour le bouton Effacer */
.search-panel .search-actions .nav-button.secondary-action {
    background-color: var(--secondary-color);
    color: var(--light-text-color);
}

.search-panel .search-actions .nav-button.secondary-action:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Icônes dans les boutons */
.search-panel .search-actions .action-btn i,
.search-panel .search-actions .nav-button i {
    margin-right: 6px;
    font-size: 0.9em;
}

/* Responsive : sur petits écrans, boutons en pleine largeur */
@media (max-width: 768px) {
    .search-panel .search-actions {
        flex-direction: column; /* Boutons empilés verticalement */
        align-items: stretch; /* Boutons en pleine largeur */
        gap: 8px;
    }
    
    .search-panel .search-actions .action-btn,
    .search-panel .search-actions .nav-button {
        width: 100%; /* Pleine largeur sur mobile */
        min-width: auto; /* Retire la largeur minimale sur mobile */
        justify-content: center; /* Centre le contenu */
    }
}

/* ================================================== */
/* == AMÉLIORATION GÉNÉRALE DU PANNEAU DE RECHERCHE == */
/* ================================================== */

/* Amélioration du formulaire de recherche pour éviter les débordements */
.search-panel form {
    display: flex;
    flex-direction: column; /* NOUVEAU : Organisation verticale */
    gap: 15px;
}

.search-panel form .search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end; /* Aligne les champs en bas */
}

/* Sur écrans moyens et grands, remettre en ligne */
@media (min-width: 769px) {
    .search-panel form {
        flex-direction: row; /* Remet en ligne horizontale */
        align-items: flex-end;
        justify-content: space-between;
    }
    
    .search-panel form .search-filters {
        flex: 1; /* Prend l'espace disponible */
        margin-right: 20px; /* Espace avant les boutons */
    }
    
    .search-panel .search-actions {
        flex-shrink: 0; /* Les boutons gardent leur taille */
        margin-top: 0; /* Pas de marge en mode ligne */
    }
}
/* ========================================================== */
/* == CORRECTIF COULEURS BOUTONS MODULE PHOTOVOLTAÏQUE     == */
/* ========================================================== */

/* On cible spécifiquement les boutons dans l'en-tête du module photovoltaïque */

/* Bouton "Sauvegarder" (Vert) */
.photovoltaique-module .header-actions .btn-success {
    background-color: #28a745 !important; /* Vert Succès */
    color: #ffffff !important;
    border: 1px solid #28a745 !important;
}
.photovoltaique-module .header-actions .btn-success:hover {
    background-color: #218838 !important; /* Vert plus foncé au survol */
    border-color: #1e7e34 !important;
}

/* Bouton "Générer PDF" (Rouge) */
.photovoltaique-module .header-actions .btn-danger {
    background-color: #dc3545 !important; /* Rouge Danger */
    color: #ffffff !important;
    border: 1px solid #dc3545 !important;
}
.photovoltaique-module .header-actions .btn-danger:hover {
    background-color: #c82333 !important; /* Rouge plus foncé au survol */
    border-color: #bd2130 !important;
}
/* ========================================================== */
/* == CORRECTIF COULEUR BOUTON SIMULATEUR PHOTOVOLTAÏQUE   == */
/* ========================================================== */

/* On force la couleur de fond par défaut du bouton "Lancer la simulation" */
.photovoltaique-module #calculate-btn {
    background-color: var(--primary-color) !important; /* Force le bleu primaire */
    border-color: var(--primary-color) !important;
    color: white !important;
}

/* On s'assure que l'effet de survol reste correct */
.photovoltaique-module #calculate-btn:hover {
    background-color: var(--primary-hover-color) !important; /* Bleu plus foncé */
    border-color: var(--primary-hover-color) !important;
}
/* ========================================================== */
/* == CORRECTIF AFFICHAGE LIGNES DEVIS/FACTURES            == */
/* ========================================================== */

/* * Cette règle force un fond blanc et un texte noir sur tous les champs 
 * de formulaire (`.form-control`) qui se trouvent dans le corps
 * du tableau des lignes de devis (`#devis-lignes-body`).
 * L'utilisation de !important garantit que ce style prioritaire
 * ne sera pas écrasé par un autre style de navigateur ou de librairie.
*/
#devis-lignes-body .form-control {
    background-color: #ffffff !important;
    color: #212529 !important;
}
/* ========================================================================
   CORRECTIF DÉFINITIF - VISIBILITÉ ÉDITEUR TRUMBOWYG DANS MODALES
   Ajoutez ce code à la fin de votre style.css
   ======================================================================== */

/* 1. FORCER le fond blanc et texte noir sur TOUS les éditeurs Trumbowyg */
.trumbowyg-editor {
    background-color: #f8f9fa !important;
    border: 2px solid #007bff !important;
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-family: inherit !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    /* Empêche l'héritage de styles indésirables */
    background-image: none !important;
    text-shadow: none !important;
}

/* 2. S'assurer que la boîte Trumbowyg est visible */
.trumbowyg-box {
    background-color: #ffffff !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    /* Z-index élevé pour les modales */
    position: relative !important;
    z-index: 1 !important;
}

/* 3. Spécifiquement dans les tableaux de devis */
#devis-lignes-body .trumbowyg-box,
#lignes-devis-table .trumbowyg-box {
    margin: 0 !important;
    width: 100% !important;
}

#devis-lignes-body .trumbowyg-editor,
#lignes-devis-table .trumbowyg-editor {
    background-color: #ffffff !important;
    color: #212529 !important;
    border: none !important;
    padding: 6px 8px !important;
    min-height: 34px !important;
    font-size: 13px !important;
}

/* 4. Barre d'outils visible */
.trumbowyg-button-pane {
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
    min-height: 35px !important;
}

.trumbowyg-button-pane .trumbowyg-button-group button {
    background-color: #ffffff !important;
    color: #495057 !important;
    border: 1px solid #ced4da !important;
    margin: 2px !important;
}

/* 5. Focus et survol pour bien voir l'interaction */
.trumbowyg-editor:focus {
    background-color: #ffffff !important;
    color: #212529 !important;
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15) !important;
    outline: none !important;
}

.trumbowyg-box:hover {
    border-color: #007bff !important;
}

/* 6. Placeholder visible */
.trumbowyg-editor.trumbowyg-placeholder::before {
    color: #6c757d !important;
    font-style: italic !important;
    opacity: 0.8 !important;
}

/* 7. Pour les mode sombres forcés par le navigateur */
@media (prefers-color-scheme: dark) {
    .trumbowyg-editor {
    background-color: #f8f9fa !important;
    color: #212529 !important;
        /* On force le mode clair même en mode sombre système */
    }
}

/* 8. Correctif spécifique pour les modales */
#modal-body .trumbowyg-editor,
.modal .trumbowyg-editor {
    background-color: #ffffff !important;
    color: #212529 !important;
    position: relative !important;
    z-index: 10 !important;
}

/* 9. Empêcher les styles système Windows/navigateur */
.trumbowyg-editor,
.trumbowyg-box {
    -webkit-appearance: none !important;
    appearance: none !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* 10. Curseur visible */
.trumbowyg-editor {
    cursor: text !important;
    caret-color: #212529 !important;
}
/* Indicateurs visuels pour les champs obligatoires */
.form-group label[for="entreprise_id"]:after,
.form-group label[for="search_client_input"]:after,
.form-group label[for="date_creation_devis"]:after,
.form-group label[for="date_validite_devis"]:after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

/* Style pour les champs en erreur */
.form-control.error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Message d'erreur sous les champs */
.field-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* ==== CORRECTIFS MOBILES POUR MODALES - AJOUT SPECIFIQUE ==== */
@media (max-width: 768px) {
    /* CORRECTIF IMPORTANT : Forcer la modale à prendre toute la largeur sur mobile */
    #modal-container {
        width: 100% !important;
        height: calc(100vh - var(--top-bar-height)) !important;
    }
    
    #modal-content-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #modal-body {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        overflow-x: auto !important;
    }

    /* Correctifs pour les modules dans les modales */
    .client-module,
    .devis-module,
    .devis-form,
    .devis-list-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 10px !important;
    }
    
    /* Correctifs pour les sections de formulaire */
    .form-section {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 15px 0 !important;
        padding: 15px !important;
    }
    
    /* Empêcher le débordement horizontal */
    body, html {
        overflow-x: auto !important;
    }
}

/* Correctif smartphone : ne pas couper les boutons/options qui depassent. */
@media (max-width: 768px) {
    #modal-body,
    .modal-body,
    .crm-main-content,
    .table-responsive,
    .data-table-container,
    .devis-list-container,
    .devis-form,
    .form-actions-header,
    .actions-group,
    .search-actions,
    .header-actions {
        overflow-x: auto !important;
    }

    .form-actions-header,
    .actions-group,
    .search-actions,
    .header-actions,
    .gestion-actions,
    .btn-add-section {
        flex-wrap: wrap !important;
        justify-content: stretch !important;
        gap: 8px !important;
    }

    .form-actions-header .btn,
    .actions-group .btn,
    .search-actions .nav-button,
    .search-actions .action-btn,
    .header-actions .nav-button,
    .header-actions .btn-modern,
    .gestion-actions .btn-modern,
    .btn-add-section .btn-modern,
    .btn-add-section button {
        flex: 1 1 150px !important;
        white-space: nowrap;
        justify-content: center !important;
        max-width: 100%;
    }

    table,
    .data-table,
    #lignes-devis-table {
        min-width: max-content;
    }
}

/* ============================================================ */
/* == OVERRIDE FINAL : BARRE DU HAUT DESKTOP (priorité max) == */
/* ============================================================ */
@media (min-width: 769px) {
    body .crm-container > .crm-top-bar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 12px !important;
        height: var(--top-bar-height) !important;
        padding: 0 16px !important;
        overflow: visible !important;
    }

    body .crm-top-bar .top-bar-logo {
        flex: 0 0 auto !important;
        display: block !important;
    }

    body .crm-top-bar .mobile-top-devis,
    body .crm-top-bar .crm-menu-toggle {
        display: none !important;
    }

    body .crm-top-bar .crm-top-navigation {
        position: static !important;
        display: flex !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        overflow: visible !important;
        justify-content: flex-start !important;
    }

    body .crm-top-bar .crm-top-navigation > ul {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 2px !important;
        margin: 0 !important;
        padding: 0 !important;
        list-style: none !important;
        min-width: 0 !important;
        white-space: nowrap !important;
    }

    body .crm-top-bar .crm-top-navigation li {
        flex: 0 0 auto !important;
        margin: 0 !important;
        width: auto !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-button {
        white-space: nowrap !important;
        padding: 9px 10px !important;
        font-size: 0.86em !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-button.icon-only .nav-button-text {
        display: none !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-item-dropdown {
        position: relative !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-item-dropdown .dropdown-content {
        display: none !important;
        position: absolute !important;
        top: 100% !important;
        right: 0 !important;
        left: auto !important;
        min-width: 240px !important;
        background: #ffffff !important;
        border: 1px solid #ddd !important;
        border-radius: 4px !important;
        box-shadow: 0 8px 16px rgba(0,0,0,0.18) !important;
        padding: 5px 0 !important;
        z-index: 1080 !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-item-dropdown:hover > .dropdown-content,
    body .crm-top-bar .crm-top-navigation .nav-item-dropdown:focus-within > .dropdown-content {
        display: block !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-item-dropdown .dropdown-content a {
        display: block !important;
        padding: 10px 14px !important;
        color: #333 !important;
        text-decoration: none !important;
        white-space: nowrap !important;
    }

    body .crm-top-bar .top-bar-user-area {
        margin-left: auto !important;
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
    }
}

/* ============================================================ */
/* == CORRECTION FINALE : ANTI-CHEVAUCHEMENT BARRE DU HAUT == */
/* ============================================================ */
@media (min-width: 769px) {
    body .crm-container > .crm-top-bar {
        overflow: visible !important;
    }

    body .crm-top-bar .crm-top-navigation {
        overflow: visible !important;
    }

    body .crm-top-bar .crm-top-navigation > ul {
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }

    body .crm-top-bar .crm-top-navigation li {
        flex: 0 1 auto !important;
        min-width: 0 !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-button {
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-button-text {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    body .crm-top-bar .top-bar-user-area > span {
        display: none !important;
    }
}

@media (max-width: 1700px) and (min-width: 769px) {
    body .crm-top-bar .crm-top-navigation .nav-button {
        padding: 8px 7px !important;
        font-size: 0.84em !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-button i,
    body .crm-top-bar .crm-top-navigation .nav-icon {
        margin-right: 5px !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-item-dropdown .nav-button-text,
    body .crm-top-bar .crm-top-navigation .nav-button.icon-only .nav-button-text {
        display: none !important;
    }
}

@media (max-width: 1500px) and (min-width: 769px) {
    body .crm-top-bar .crm-top-navigation .nav-button-text {
        display: none !important;
    }

    body .crm-top-bar .crm-top-navigation .nav-button i,
    body .crm-top-bar .crm-top-navigation .nav-icon {
        margin-right: 0 !important;
    }
}


