/* ============================================
 * Audit Hôtellerie Pro - Formulaire terrain
 * Mobile-first
 * ============================================ */

.ahp-audit-app {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 12px 100px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #333;
}

.ahp-audit-app * { box-sizing: border-box; }

/* Header sticky */
.ahp-audit-header {
    position: sticky;
    top: 0;
    background: #1a3a5c;
    color: #fff;
    margin: 0 -12px 16px;
    padding: 16px 16px 12px;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.ahp-audit-header h1 {
    font-size: 20px;
    margin: 0 0 8px;
    color: #fff;
    line-height: 1.2;
}

.ahp-audit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.ahp-progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.ahp-progress-fill {
    height: 100%;
    background: #c9a961;
    transition: width 0.3s ease;
    width: 0%;
}

.ahp-progress-text {
    font-size: 12px;
    opacity: 0.85;
    text-align: right;
}

/* Navigation pôles (onglets scrollables horizontalement) */
.ahp-poles-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 0 -12px 16px;
    padding: 10px 12px 10px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: 0; /* ajusté en JS selon la hauteur de l'en-tête */
    z-index: 99;
    background: #ffffff;
    box-shadow: 0 3px 5px rgba(0,0,0,0.06);
}

.ahp-pole-tab {
    flex-shrink: 0;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ahp-pole-tab:hover { border-color: #c9a961; }

.ahp-pole-tab.active {
    background: #1a3a5c;
    color: #fff;
    border-color: #1a3a5c;
}

.ahp-pole-tab.complete:not(.active) {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

.ahp-pole-tab-count {
    background: rgba(0,0,0,0.1);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.ahp-pole-tab.active .ahp-pole-tab-count {
    background: rgba(255,255,255,0.25);
}

/* Sections de pôles */
.ahp-pole-section {
    display: none;
}

.ahp-pole-section.active {
    display: block;
}

.ahp-pole-section h2 {
    font-size: 22px;
    margin: 0 0 16px;
    color: #1a3a5c;
    padding-bottom: 8px;
    border-bottom: 2px solid #c9a961;
}

.ahp-empty {
    text-align: center;
    color: #999;
    padding: 30px 20px;
    background: #f9f9f9;
    border-radius: 6px;
}

/* Critères */
.ahp-critere {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.ahp-critere-theme {
    display: inline-block;
    background: #f0e8d6;
    color: #8a7332;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.ahp-critere-question {
    font-size: 16px;
    font-weight: 600;
    color: #1a3a5c;
    margin-bottom: 14px;
    line-height: 1.4;
}

.ahp-required {
    color: #d63638;
    margin-left: 4px;
}

/* Boutons Oui/Non/NA */
.ahp-oui-non {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.ahp-btn-reponse {
    flex: 1;
    padding: 14px 8px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 48px;
}

.ahp-btn-reponse:hover { border-color: #c9a961; }

.ahp-btn-reponse[data-value="oui"][data-active="1"] {
    background: #4caf50;
    border-color: #4caf50;
    color: #fff;
}

.ahp-btn-reponse[data-value="non"][data-active="1"] {
    background: #f44336;
    border-color: #f44336;
    color: #fff;
}

.ahp-btn-reponse[data-value="na"][data-active="1"] {
    background: #9e9e9e;
    border-color: #9e9e9e;
    color: #fff;
}

/* Échelles */
.ahp-echelle {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.ahp-echelle-10 {
    flex-wrap: wrap;
}

.ahp-btn-score {
    flex: 1;
    min-width: 38px;
    height: 44px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.ahp-echelle-10 .ahp-btn-score {
    flex: 1 1 calc(20% - 5px);
}

.ahp-btn-score:hover { border-color: #c9a961; }

.ahp-btn-score[data-active="1"] {
    background: #1a3a5c;
    border-color: #1a3a5c;
    color: #fff;
}

/* Échelles qualitatives (Excellent → Pas du tout satisfaisant) */
.ahp-echelle-qual {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.ahp-btn-qual {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    min-height: 46px;
    position: relative;
    --qual-color: #c9a961;
}

.ahp-btn-qual:hover {
    border-color: var(--qual-color);
}

.ahp-btn-qual[data-active="1"] {
    background: var(--qual-color);
    border-color: var(--qual-color);
    color: #fff;
}

.ahp-btn-qual.ahp-btn-na {
    --qual-color: #9e9e9e;
    color: #777;
    font-size: 13px;
}

.ahp-btn-qual.ahp-btn-na[data-active="1"] {
    background: #9e9e9e;
    border-color: #9e9e9e;
}

.ahp-btn-qual.ahp-btn-inexistant {
    --qual-color: #111;
    background: #fff;
    border: 2px solid #111;
    color: #111;
    font-size: 13px;
}
.ahp-btn-qual.ahp-btn-inexistant[data-active="1"] {
    background: #111;
    border-color: #111;
    color: #fff;
}

.ahp-input-date,
.ahp-input-heure {
    width: 100%;
    max-width: 260px;
    padding: 12px 14px;
    border: 1px solid #cbd6e2;
    border-radius: 8px;
    font-size: 16px;
    color: #1a3a5c;
    background: #fff;
}

/* Sur desktop, on peut mettre en grille pour gagner de la place */
@media (min-width: 600px) {
    .ahp-echelle-qual {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    .ahp-btn-qual.ahp-btn-na {
        grid-column: 1 / -1;
    }
}

/* Input texte */
.ahp-input-texte,
.ahp-input-note {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
}

.ahp-critere-note {
    margin-top: 10px;
    margin-bottom: 10px;
}

.ahp-critere-note label span {
    display: block;
    font-size: 12px;
    color: #777;
    margin-bottom: 4px;
    font-weight: 600;
}

/* Photos */
.ahp-critere-photos {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #ddd;
}

.ahp-photo-trigger {
    display: inline-block;
    padding: 10px 16px;
    background: #f5f5f5;
    border: 2px dashed #c9a961;
    border-radius: 8px;
    color: #1a3a5c;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ahp-photo-trigger:hover {
    background: #fff8e1;
}

.ahp-required-note {
    margin-left: 10px;
    font-size: 12px;
    color: #d63638;
    font-style: italic;
}

.ahp-photos-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.ahp-photo-thumb {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.ahp-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ahp-photo-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

/* Status saving */
.ahp-critere-status {
    min-height: 18px;
    font-size: 12px;
    margin-top: 8px;
    text-align: right;
}

.ahp-critere-status.saving { color: #1a3a5c; }
.ahp-critere-status.saved { color: #4caf50; }
.ahp-critere-status.error { color: #d63638; }

/* Boutons de navigation entre pôles */
.ahp-pole-nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.ahp-btn {
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.15s;
    min-height: 44px;
}

.ahp-btn-primary {
    background: #1a3a5c;
    color: #fff;
}

.ahp-btn-primary:hover {
    background: #142e48;
    color: #fff;
}

.ahp-btn-secondary {
    background: #fff;
    color: #1a3a5c;
    border: 2px solid #1a3a5c;
}

/* Footer (bouton soumettre) */
.ahp-audit-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 12px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    z-index: 50;
}

.ahp-btn-submit {
    width: 100%;
    background: #c9a961;
    color: #fff;
    font-size: 16px;
    padding: 14px;
    min-height: 52px;
}

.ahp-btn-submit:hover {
    background: #b59650;
    color: #fff;
}

.ahp-btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ahp-footer-hint {
    text-align: center;
    font-size: 11px;
    color: #888;
    margin: 6px 0 0;
}

/* Status banner */
.ahp-status-banner {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    margin: 20px 0;
}

.ahp-status-banner h2 {
    margin: 0 0 10px;
    color: #2e7d32;
    border: none;
}

.ahp-status-done .ahp-btn-primary {
    margin-top: 14px;
}

/* Modal */
.ahp-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ahp-modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    position: relative;
}

.ahp-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 26px;
    line-height: 36px;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
}
.ahp-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.ahp-modal-content h3 {
    margin-top: 0;
    color: #1a3a5c;
}

/* Erreur générique */
.ahp-error {
    background: #fef2f2;
    border: 2px solid #d63638;
    color: #721c24;
    padding: 20px;
    border-radius: 10px;
    margin: 30px auto;
    max-width: 500px;
    text-align: center;
}

/* Loader inline */
.ahp-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: #1a3a5c;
    border-radius: 50%;
    animation: ahp-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes ahp-spin {
    to { transform: rotate(360deg); }
}

/* Responsive desktop */
@media (min-width: 768px) {
    .ahp-audit-app {
        padding: 0 20px 100px;
    }

    .ahp-audit-header {
        margin: 0 -20px 20px;
        padding: 20px 24px;
    }

    .ahp-audit-header h1 {
        font-size: 24px;
    }

    .ahp-poles-nav {
        margin: 0 -20px 20px;
        padding: 10px 20px 10px;
    }

    .ahp-audit-footer {
        position: sticky;
        bottom: 16px;
        margin: 16px 0 0;
        border-radius: 10px;
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }

    .ahp-pole-section {
        max-width: 720px;
    }
}

/* ============================================
 * Boutons photo (caméra / bibliothèque)
 * ============================================ */
.ahp-photo-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    margin: 0 8px 8px 0;
    background: #f0f4f8;
    border: 1px solid #cbd6e2;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #1a3a5c;
}
.ahp-photo-trigger:active { background: #e2e9f1; }
.ahp-photo-library { background: #eef7ef; border-color: #bfe0c2; color: #1e7e34; }

/* ============================================
 * Navigation par volet (drawer)
 * ============================================ */
.ahp-drawer-trigger-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #1a3a5c;
    color: #fff;
}
.ahp-drawer-open {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.ahp-drawer-open:active { background: rgba(255,255,255,0.3); }
.ahp-drawer-current { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ahp-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.ahp-drawer-overlay.open { opacity: 1; }

.ahp-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 82%;
    max-width: 340px;
    background: #fff;
    z-index: 999;
    box-shadow: 2px 0 18px rgba(0,0,0,0.25);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}
.ahp-drawer.open { transform: translateX(0); }
.ahp-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #1a3a5c;
    color: #fff;
}
.ahp-drawer-head h2 { margin: 0; font-size: 17px; }
.ahp-drawer-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.ahp-drawer-list { list-style: none; margin: 0; padding: 8px 0; overflow-y: auto; flex: 1; }
.ahp-drawer-list li { margin: 0; }
.ahp-drawer-item {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 14px 18px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    color: #333;
}
.ahp-drawer-item.active { background: #eef4fb; color: #1a3a5c; font-weight: 600; border-left: 4px solid #c9a961; }
.ahp-drawer-item .ahp-pole-tab-count { font-size: 12px; color: #888; background: #f0f0f0; border-radius: 10px; padding: 2px 8px; }
body.ahp-drawer-lock { overflow: hidden; }

/* ============================================
 * Critère non répondu (contrôle avant soumission)
 * ============================================ */
.ahp-critere.ahp-critere-missing {
    border: 2px solid #d64545;
    background: #fdf4f4;
    border-radius: 8px;
    box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.12);
}
.ahp-critere.ahp-critere-missing::before {
    content: "⚠️ Critère à renseigner";
    display: block;
    color: #b02a2a;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
}

/* Bouton RAS (Rien À Signaler) pour champs texte */
.ahp-btn-ras {
    margin-top: 8px;
    padding: 7px 16px;
    background: #f0f4f8;
    border: 1px solid #cbd6e2;
    border-radius: 8px;
    color: #1a3a5c;
    font-size: 13px;
    cursor: pointer;
}
.ahp-btn-ras:active { background: #e2e9f1; }
.ahp-btn-ras.ahp-ras-active { background: #28a745; border-color: #28a745; color: #fff; }

/* Boutons « Non mesuré » / « Inexistant » communs (types non qualitatifs) */
.ahp-namx-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ahp-btn-namx {
    padding: 9px 16px;
    border: 1px solid #cbd6e2;
    border-radius: 8px;
    background: #f4f7fa;
    font-size: 13px;
    color: #555;
    cursor: pointer;
}
.ahp-btn-namx.ahp-btn-na[data-active="1"] {
    background: #9e9e9e;
    border-color: #9e9e9e;
    color: #fff;
}
.ahp-btn-namx.ahp-btn-inexistant {
    background: #fff;
    border: 2px solid #111;
    color: #111;
}
.ahp-btn-namx.ahp-btn-inexistant[data-active="1"] {
    background: #111;
    border-color: #111;
    color: #fff;
}
