:root {
    --primary-color: #012a4a; /* Bleu Nuit du logo */
    --accent-color: #0084ff; /* Bleu Azur du logo */
    --secondary-color: #e8f0fe;
    --danger-color: #dc3545;
    --success-color: #28a745; /* Conservé pour certains éléments si besoin */
    --neutral-color: #6c757d;
    --warning-color: #ff8c00;
    --export-color: #17a2b8;
    --light-gray: #f4f7f9;
    --dark-gray: #333;
    --border-color: #dee2e6;
    --border-radius: 5px;
}
body {
    font-family: -apple-system, BlinkMacSystemfont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--light-gray);
    color: var(--dark-gray);
    font-size: 14px;
}
.page-container {
    max-width: 900px;
    margin: 1rem auto;
    background: white;
    padding: 2rem;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}
.company-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.company-header .logo {
    width: 200px;
    height: auto;
}
.company-header .address {
    text-align: right;
    font-size: 0.9em;
}
.main-title {
    text-align: center;
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary-color);
    margin: 2rem 0;
}
.info-section {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    overflow: visible;
}
.section-title {
    background-color: var(--primary-color);
    color: white;
    padding: 0.6rem 1rem;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
}
.info-content {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}
.form-group label {
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: #555;
}
.form-group input, .form-group select, .form-group textarea {
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    font-size: 1em;
}
input#audit-id { background-color: #e9ecef; color: #555; cursor: not-allowed; }
#address-form-group { position: relative; z-index: 2; }
#address-suggestions {
    position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #ddd;
    border-top: none; border-radius: 0 0 5px 5px; max-height: 200px; overflow-y: auto; z-index: 1;
}
.suggestion-item { padding: 0.8rem; cursor: pointer; }
.suggestion-item:hover { background-color: var(--secondary-color); }

/* Nouveaux styles pour la fréquence */
#frequence-container {
    grid-column: 1 / -1;
}
.frequency-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.frequence-unit-options {
    display: flex;
    gap: 1rem;
}
#frequence-value-wrapper input, #frequence-value-wrapper select {
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    font-size: 1em;
    width: 80px;
}
/* Fin des nouveaux styles */

.audit-section .section-title { cursor: pointer; }
.section-content { display: none; padding: 1rem; }
.audit-item-row { display: grid; gap: 1.5rem; padding: 0.5rem 0; border-bottom: 1px solid #eee; align-items: center; }
.audit-item { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;}
.item-label { font-weight: 500; margin-right: auto; }
.item-controls { display: flex; gap: 0.5rem; flex-shrink: 0; align-items: center;}
.item-addon { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.item-addon select, .item-addon input { padding: 0.3rem; border-radius: 4px; border: 1px solid #ccc; }
.item-addon input[type="number"] { width: 60px; text-align: center; }
.dolphin-slider {
    position: relative;
    width: 70px;
    height: 28px;
    cursor: pointer;
    user-select: none;
}
.dolphin-track {
    width: 100%;
    height: 100%;
    background-color: #ccc;
    border-radius: 14px;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
}
.dolphin-thumb {
    position: absolute;
    top: 2px;
    width: 24px;
    height: 24px;
    font-size: 18px;
    line-height: 24px;
    text-align: center;
    transition: transform 0.3s ease, filter 0.3s ease;
}
.dolphin-slider[data-status="null"] .dolphin-track { background-color: #e0e0e0; }
.dolphin-slider[data-status="null"] .dolphin-thumb { transform: translateX(2px) scaleX(1); filter: grayscale(100%) opacity(0.6); }
.dolphin-slider[data-status="present"] .dolphin-track { background-color: var(--accent-color); }
.dolphin-slider[data-status="present"] .dolphin-thumb { transform: translateX(44px) scaleX(-1); filter: grayscale(0%) opacity(1); }
.dolphin-slider[data-status="absent"] .dolphin-track { background-color: var(--danger-color); }
.dolphin-slider[data-status="absent"] .dolphin-thumb {
    transform: translateX(2px) scaleX(1);
    filter: grayscale(0%) opacity(1);
}
.dolphin-slider[data-status="absent"] .dolphin-thumb::after {
    content: '❌';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.status-btn {
    border: 1px solid #ccc; background-color: #f0f0f0; padding: 0.5rem 0.8rem;
    border-radius: 5px; cursor: pointer; font-weight: bold;
}
.status-btn.active[data-status="comment"] { background-color: var(--neutral-color); color: white; border-color: var(--neutral-color); }
.item-details { width: 100%; margin-top: 0.8rem; }
.section-photos, .section-comment { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--border-color); }

.item-details textarea,
.section-comment textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 40px;
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    font-size: 1em;
    font-family: inherit;
    resize: none;
    overflow-y: hidden;
}

.photo-input-label {
    background-color: #f0f0f0; color: var(--primary-color); border: 1px solid var(--primary-color);
    padding: 0.5rem 1rem; border-radius: 5px; cursor: pointer; display: inline-block;
}
input[type="file"].section-photo-input { display: none; }
.add-button { background-color: var(--primary-color); color: white; border: none; padding: 0.8rem 1.2rem;
    border-radius: var(--border-radius); cursor: pointer; font-weight: bold; margin-top: 1rem;
    display: block; width: 100%; box-sizing: border-box; text-align: center;
}
.add-button:hover { opacity: 0.9; }
#restore-form-btn { background-color: var(--accent-color); }
#import-form-btn { background-color: var(--accent-color); }
.reset-button { background-color: var(--neutral-color); }
.add-item-button { background-color: #f0f0f0; color: var(--primary-color); border: 1px dashed var(--primary-color); }
.add-item-form { background-color: #f8f9fa; border: 1px solid var(--border-color); border-radius: var(--border-radius);
    padding: 1rem; margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
}
.add-item-form .form-group {
    flex-grow: 1;
    margin-bottom: 0;
}
.add-item-form .add-button {
    width: auto;
    margin-top: 0;
    flex-shrink: 0;
}
.button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.export-section { display: flex; flex-direction: column; gap: 1rem; }
.export-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 10; }
.modal-content { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; padding: 1.5rem; border-radius: var(--border-radius); box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 11; width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 0.8rem; margin-bottom: 1rem; flex-shrink: 0; }
.modal-title { margin: 0; font-size: 1.2em; color: var(--primary-color); }
.modal-close { background: none; border: none; font-size: 1.8em; cursor: pointer; color: #888; }
.modal-controls { display: flex; gap: 1rem; margin-bottom: 1rem; flex-shrink: 0; }
.modal-controls input, .modal-controls select { padding: 0.6rem; border: 1px solid #ccc; border-radius: var(--border-radius); font-size: 1em; }
.modal-controls input { flex-grow: 1; }
.modal-body { overflow-y: auto; }
.modal-body ul { list-style: none; padding: 0; margin: 0; }
.modal-body li { padding: 0.8rem; border-bottom: 1px solid #f0f0f0; cursor: pointer; word-break: break-all; }
.modal-body li:hover { background-color: var(--secondary-color); }
.modal-body li:last-child { border-bottom: none; }
.modal-body .item-details { font-size: 0.8em; color: #555; }

#contract-type-options, .frequence-unit-options { 
    display: flex; 
    gap: 1rem; 
    flex-wrap: wrap; 
    align-items: center; 
}
#contract-type-options label, .frequence-unit-options label { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    margin-bottom: 0; 
    font-weight: normal; 
}
.replacement-date-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 1rem; align-items: center; margin-bottom: 0.8rem; }
.delete-replacement-btn { background-color: var(--danger-color); color: white; border: none; border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-weight: bold; }
#add-replacement-btn { width: auto; display: inline-block; padding: 0.5rem 1rem; font-size: 0.9em; margin-top: 0.5rem; background-color: var(--accent-color); }

/* Weekly Planner Styles */
.weekly-planner { border-top: 1px dashed var(--border-color); margin-top: 1rem; padding-top: 1rem; }
.week-days { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.day-btn { padding: 0.5rem 0.8rem; border: 1px solid var(--border-color); background-color: #f8f9fa; border-radius: var(--border-radius); cursor: pointer; font-weight: 500; }
.day-btn.active { background-color: var(--primary-color); color: white; border-color: var(--primary-color); }
.day-schedule { border-left: 3px solid var(--secondary-color); padding-left: 1rem; margin-bottom: 1rem; }
.day-schedule-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.day-schedule-header .day-label { font-weight: bold; color: var(--primary-color); margin-right: auto; }

.time-slots-container {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.time-slot {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.time-slot-title {
    font-weight: bold;
    font-size: 0.9em;
    color: var(--primary-color);
}
.time-slot-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.time-slot input[type="time"] { padding: 0.4rem; }
.time-slot .delete-slot-btn { background: none; border: none; color: var(--danger-color); font-weight: bold; font-size: 1.2em; cursor: pointer; }


@media screen and (max-width: 768px) {
    .page-container { padding: 1rem; }
    .audit-item-row { grid-template-columns: 1fr !important; }
    .button-grid, .export-grid { grid-template-columns: 1fr; }
    .replacement-date-row { grid-template-columns: 1fr; }
    .modal-controls { flex-direction: column; }
    .frequency-controls { flex-direction: column; align-items: flex-start; }
}

@media print {
    body {
        font-size: 10pt;
        background-color: #fff;
        color: #000;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .page-container {
        box-shadow: none;
        margin: 0;
        padding: 0;
        max-width: 100%;
    }

    /* --- ÉLÉMENTS À MASQUER --- */
    .button-grid, .export-section, #add-zone-container, .add-item-button, 
    .photo-input-label, .delete-photo-btn, .add-item-form-container, 
    #export-separator, #add-replacement-btn, .delete-replacement-btn, 
    .item-controls .status-btn[data-status="comment"], .week-days,
    textarea { 
        display: none !important;
    }
    
    /* --- GESTION DES SAUTS DE PAGE --- */
    .info-section, .audit-section, .audit-item-row, .audit-item {
        page-break-inside: avoid; 
    }

    /* --- AFFICHAGE DES CONTENUS ET COMMENTAIRES --- */
    .section-content, .weekly-planner, .item-details {
        display: block !important;
    }

    /* Style pour le bloc de texte qui remplace le textarea */
    .print-comment {
        display: block !important;
        white-space: pre-wrap;      
        word-break: break-word;     
        margin-top: 5px;
        padding: 5px;
        border: 1px solid #ddd;
        background-color: #f9f9f9;
        font-family: inherit;
        font-size: inherit;
        color: #000;
    }
    
    /* --- FILTRAGE DES ÉLÉMENTS NON PERTINENTS --- */
    .audit-item:has(.dolphin-slider[data-status="absent"]),
    .audit-item:has(.dolphin-slider[data-status="null"]) {
        display: none !important;
    }
    
    .company-header {
        border-bottom: 2px solid #000;
    }

    .company-header .logo {
        width: 150px;
    }
    
    a {
        text-decoration: none;
        color: #000;
    }
    
    .photo-preview-container img {
        border: 1px solid #ccc;
    }
}

/* Style pour les pastilles Test/Prod dans la modale */
.env-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.75em;
    font-weight: bold;
    border-radius: 8px;
    color: white;
    margin-left: 8px;
    vertical-align: middle;
}

.test-badge {
    background-color: #ffc107; /* Jaune/Orange */
    color: #333;
}

.prod-badge {
    background-color: #28a745; /* Vert */
}

/* --- Styles pour la section Pièces Jointes --- */
#attachment-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

#attachment-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.attachment-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    word-break: break-all; /* Pour les noms de fichiers longs */
}

.attachment-link:hover {
    text-decoration: underline;
}

.delete-attachment-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 1.4em;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
}

.delete-attachment-btn:hover {
    opacity: 0.7;
}


/* Règle pour cacher temporairement le lien vers le portail */
.portal-link {
    display: none !important;
}

/* --- Styles pour la liste des contacts --- */
#contact-list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.contact-item {
    display: flex;
    justify-content: space-between;
    align-items: center; 
    padding: 1rem;
    background-color: var(--bg-color-dark);
    border-radius: 8px;
    border: 1px solid var(--border-color-light);
    font-family: inherit; /* <-- CORRECTION : Force l'utilisation de la police de la page */
}

.contact-item-details {
    display: flex;
    flex-direction: column; 
    gap: 0.5rem; 
}

.contact-item-details .contact-name {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-color);
}

.contact-item-metadata {
    display: flex;
    flex-direction: row; 
    flex-wrap: wrap;      
    gap: 1.5rem;          
    color: var(--text-color-light);
    font-size: 0.9em;
}

.contact-item-metadata .contact-detail strong {
    color: var(--text-color-medium);
}

.delete-contact-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.delete-contact-btn:hover {
    opacity: 1;
}

/* --- Styles pour le formulaire d'ajout --- */
#add-contact-form-container {
    padding-top: 1rem;
}
/* --- Version Display --- */
#app-version-display {
    font-family: inherit;
    font-size: 0.75rem; /* Très petit */
    color: var(--text-color-light); /* Gris clair */
    text-align: center;
    padding: 0.5rem;
    margin-top: 0.5rem;
    opacity: 0.7; /* Légèrement transparent */
    letter-spacing: 0.5px;
}
