/* z:\outils-la\css\ola_rapport_visite.css */

/* Variables spécifiques à la page (complément de styleCommun.css) */
:root {
    --accent-color: #0B6BA7;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
}

/* Structure de la page */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.main-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.side-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.action-sticky {
    position: sticky;
    top: 24px;
}

/* Titles */
.card header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card header h2 i {
    color: var(--accent-color);
}

/* Map Styling */
#map-container {
    height: 500px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Photo Gallery */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.photo-item {
    background: #fcfcfc;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.photo-item:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.photo-preview-container {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #eee;
}

.photo-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fix mobile stretching for photo buttons */
.btn-photo-remove, .btn-photo-annotate {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 10;
    transition: transform 0.2s ease;
}

.btn-photo-remove:hover, .btn-photo-annotate:hover {
    transform: scale(1.15) !important;
}

.photo-metadata {
    font-size: 13px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    padding: 2px 0;
}

.meta-label {
    color: var(--text-muted);
}

.meta-value {
    color: #111;
    font-weight: 600;
}

/* Annotation Modal Styles */
.anno-toolbar {
    display: flex;
    align-items: center;
    background: #111;
    padding: 10px 15px;
    border-radius: 12px;
    gap: 15px;
    color: white;
}

.anno-tool-group {
    display: flex;
    gap: 8px;
}

.btn-anno-tool {
    background: #333;
    border: 2px solid #444;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.btn-anno-tool:hover {
    background: #444;
}

.btn-anno-tool.active {
    background: var(--bleu);
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.btn-anno-tool i {
    pointer-events: none;
}

@media (max-width: 600px) {
    .anno-toolbar {
        padding: 5px 8px;
        gap: 8px;
        width: 100%;
        border-radius: 0;
    }
    .anno-tool-group {
        gap: 4px;
    }
    .btn-anno-tool {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    .hide-mobile {
        display: none !important;
    }
    .divider-v {
        margin: 0 2px;
    }
    #anno_modal.modal-overlay {
        justify-content: flex-start;
        padding: 0;
    }
    .anno_canvas_container {
        border-radius: 0;
        margin-top: 5px;
    }
}

/* Weather UI */
.weather-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: #eef7ff;
    color: #0369a1;
    font-size: 12px;
    font-weight: 600;
    gap: 6px;
    border: 1px solid #bae6fd;
}

.weather-tag.warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fef3c7;
}

.weather-tag.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fee2e2;
}

/* Upload Dropzone */
.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.dropzone:hover {
    border-color: var(--accent-color);
    background: #f0f9ff;
}

.dropzone i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: #64748b;
}

.dropzone p {
    margin: 5px 0;
    color: #334155;
}

/* Mobile Optimizations */
@media (max-width: 1100px) {
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    .side-column {
        order: -1; /* Actions en haut sur tablette/mobile */
    }
}

@media (max-width: 600px) {
    main {
        padding: 12px;
    }

    #map-container {
        height: 350px;
    }

    .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    #btn_search_site, #btn_locate_me {
        width: 48px !important;
        margin-bottom: 0;
    }

    .photo-grid {
        grid-template-columns: 1fr;
    }
}

/* Photo Number Badge on Map */
.marker-label-wrapper {
    position: relative;
    width: 25px !important;
    height: 41px !important;
}

.marker-number-badge {
    position: absolute;
    top: -10px;
    right: -15px;
    background: var(--accent-color);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 1000;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 800px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.modal-content-sm {
    max-width: 400px !important;
}

.modal-content header {
    padding: 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-content header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #1e293b;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
}

.btn-close-modal:hover {
    color: #64748b;
}

.modal-body {
    padding: 24px;
}

/* Label Manquante cliquable */
.geo-link {
    cursor: pointer;
    text-decoration: underline dotted;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.geo-link:hover {
    color: var(--accent-color) !important;
    text-decoration: underline;
}

/* --- CSP MIGRATION STYLES --- */

/* Evaluation Buttons (Migrated from PHP) */
.eval-btn-group {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}
.eval-btn {
    flex: 1;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    background: #f9fafb;
    transition: all 0.2s;
    text-align: center;
}
.eval-btn:hover { border-color: #999; background: #f3f4f6; }
.eval-btn.active.sat { background: #dcfce7 !important; color: #166534 !important; border-color: #22c55e !important; box-shadow: 0 0 0 2px #22c55e; }
.eval-btn.active.imp { background: #fef3c7 !important; color: #92400e !important; border-color: #f59e0b !important; box-shadow: 0 0 0 2px #f59e0b; }
.eval-btn.active.unsat { background: #fee2e2 !important; color: #991b1b !important; border-color: #ef4444 !important; box-shadow: 0 0 0 2px #ef4444; }

/* Synthesis Table (Migrated from PHP) */
.synthesis-table th {
    text-align: center;
    padding: 12px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
}
.sat-header { color: #166534; background: #f0fdf4; border-bottom: 3px solid #22c55e; }
.imp-header { color: #92400e; background: #fffbeb; border-bottom: 3px solid #f59e0b; }
.unsat-header { color: #991b1b; background: #fef2f2; border-bottom: 3px solid #ef4444; }

/* Toggle Switch (Migrated from PHP) */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1; transition: .3s; border-radius: 24px;
}
.toggle-slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white; transition: .3s; border-radius: 50%;
}
input:checked+.toggle-slider { background-color: #22c55e !important; }
input:checked+.toggle-slider:before { transform: translateX(20px); }

/* Utility Classes for CSP Compliance */
.d-flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-between { justify-content: space-between !important; }
.flex-center { align-items: center !important; }
.flex-content-center { justify-content: center !important; }
.gap-4 { gap: 4px !important; }
.gap-5 { gap: 5px !important; }
.gap-8 { gap: 8px !important; }
.gap-10 { gap: 10px !important; }
.gap-15 { gap: 15px !important; }
.gap-20 { gap: 20px !important; }

.p-8 { padding: 8px !important; }
.p-10 { padding: 10px !important; }
.p-16 { padding: 16px !important; }
.p-24 { padding: 24px !important; }
.p-8-15 { padding: 8px 15px !important; }
.p-10-15 { padding: 10px 15px !important; }
.p-4-12 { padding: 4px 12px !important; }
.pt-12 { padding-top: 12px !important; }
.mb-4 { margin-bottom: 4px !important; }
.mb-8 { margin-bottom: 8px !important; }
.d-block { display: block !important; }

.grid { display: grid !important; }
.col-2 { grid-template-columns: repeat(2, 1fr) !important; }
.gap-8 { gap: 8px !important; }
.gap-12 { gap: 12px !important; }

.mt-10 { margin-top: 10px !important; }
.mt-15 { margin-top: 15px !important; }
.mt-24 { margin-top: 24px !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-15 { margin-bottom: 15px !important; }
.m-0 { margin: 0 !important; }

.w-full { width: 100% !important; }
.w-400 { width: 400px !important; }
.h-400 { height: 400px !important; }
.w-180 { width: 180px !important; }
.w-120 { width: 120px !important; }
.w-40 { width: 40px !important; }
.w-100 { width: 100% !important; }

.bg-f1 { background: #f1f1f1 !important; }
.bg-f8 { background: #f8fafc !important; }
.bg-222 { background: #222 !important; }
.bg-red { background: #dc2626 !important; }
.bg-gray-lightest { background: #f8fafc !important; }

.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.fs-11 { font-size: 11px !important; }
.fs-12 { font-size: 12px !important; }
.fs-13 { font-size: 13px !important; }
.fs-14 { font-size: 14px !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.uppercase { text-transform: uppercase !important; }
.color-gray-muted { color: #6b7280 !important; }
.color-dark { color: #1e293b !important; }
.color-text-muted { color: var(--text-muted) !important; }

.border-ddd { border: 1px solid #ddd !important; }
.border-eee { border-top: 1px solid #eee !important; }
.border-none { border: 0 !important; }
.border-radius-6 { border-radius: 6px !important; }
.border-radius-8 { border-radius: 8px !important; }
.border-radius-12 { border-radius: 12px !important; }
.border-gray-light { border: 1px solid #e5e7eb !important; }
.border-top-2 { border-top: 2px solid #f3f4f6 !important; }
.border-left-divider { border-left: 1px solid #ddd !important; padding-left: 15px !important; margin-left: 5px !important; }

.p-5 { padding: 5px !important; }
.p-8 { padding: 8px !important; }
.p-10-15 { padding: 10px 15px !important; }
.p-6-12 { padding: 6px 12px !important; }
.p-8-15 { padding: 8px 15px !important; }
.p-4-12 { padding: 4px 12px !important; }

.input-flat {
    border: 1px solid #d1d5db !important;
    background: #ffffff !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    color: #374151 !important;
    width: 100%;
}
.input-flat:focus {
    border-color: var(--accent-color) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1) !important;
}

.btn-icon-danger {
    background: none !important;
    border: none !important;
    color: #dc2626 !important;
    cursor: pointer !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: opacity 0.2s;
}
.btn-icon-danger:hover { opacity: 0.7; }

.divider-v {
    width: 1px;
    height: 24px;
    background: #dddddd;
    margin: 0 5px;
    align-self: center;
}

.bg-222 .divider-v { background: #444; }

.collapse { border-collapse: collapse !important; }
.grid-sidebar { grid-template-columns: 1fr 350px; }
.grid-responsive { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.sticky-action { position: sticky; top: 20px; }
.z-modal { z-index: 3000; }
.hidden { display: none !important; }

/* Photo Card Rendering Classes */
.photo-item-content { display: flex; flex-direction: column; gap: 0; }
.photo-left-col { width: 100%; border-bottom: 1px solid #e5e7eb; display: flex; flex-direction: column; }
.photo-right-col { width: 100%; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: white; }

.photo-preview-container { position: relative; width: 100%; }
.photo-preview-img { width: 100%; height: auto; min-height: 250px; max-height: 450px; object-fit: contain; background: #f3f4f6; display: block; }
.photo-badge-index { position: absolute; top: 8px; left: 8px; background: var(--accent-color); color: white; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 700; }

.btn-photo-remove { position: absolute; top: 8px; right: 8px; padding: 4px 8px; background: #dc2626 !important; }
.btn-photo-annotate { position: absolute; top: 45px; right: 8px; padding: 4px 8px; background: var(--bleu) !important; }

.photo-metadata { padding: 12px; background: #f9fafb; flex-grow: 1; font-size: 0.85rem; }
.geo-link { cursor: pointer; color: var(--bleu); }
.geo-missing { color: #dc2626; }

.weather-row { display: flex; flex-wrap: wrap; gap: 8px; }
.weather-tag { background: #e0f2fe; color: #0369a1; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }
.weather-desc { font-size: 0.85rem; font-weight: 600; color: var(--accent-color); margin-top: 6px; }
.weather-desc small { font-weight: normal; color: var(--text-muted); }
.weather-mini-box { border-top: 1px solid #eee; padding-top: 8px; }

.map-marker-red {
    background-color: #ff0000;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid #ffffff;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.map-icon-std { width: 25px; height: 41px; }
.popup-img-std { width: 100px; margin-top: 5px; }

.collapse { border-collapse: collapse !important; }
/* Capture Mode for PDF Generation */
.map-capture-situation {
    width: 400px !important;
    height: 400px !important;
}

.map-capture-situation .leaflet-marker-pane > *:not(.situation-marker) { 
    display: none !important; 
}

.map-capture-situation .leaflet-overlay-pane, 
.map-capture-situation .leaflet-popup-pane, 
.map-capture-situation .leaflet-shadow-pane { 
    display: none !important; 
}

.map-capture-situation .situation-marker { 
    display: block !important; 
    opacity: 1 !important; 
    visibility: visible !important; 
}

/* Photo Complement Style */
.photo-item.complement-item {
    border-left: 4px solid #3b82f6 !important; /* Blue indicator sidebar */
    margin-top: -15px !important;
    border-top: 1px dashed #ddd !important;
    background-color: #f8fafc;
}

.photo-item.complement-item .photo-metadata,
.photo-item.complement-item .category-controls,
.photo-item.complement-item .evaluation-section {
    display: none !important;
}

.photo-item.complement-item .photo-preview-container {
    border-color: #3b82f6;
}

/* Responsive Fixes for Foldable & Mobile screens */
@media (max-width: 1100px) {
    .grid-sidebar {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column;
    }
    
    .side-column {
        order: 2; /* Place l'aside de résumé après le contenu principal */
    }

    .action-sticky {
        position: static !important;
    }
}

@media (max-width: 480px) {
    main {
        padding: 10px !important;
    }
    
    .p-16 {
        padding: 12px !important;
    }

    .grid-responsive {
        grid-template-columns: 1fr !important; /* Force une seule colonne sur très petit écran */
    }

    /* Ajustement de la taille de la carte pour mobile */
    #map-container {
        height: 350px;
    }
}

/* Avancement du Chantier Matrix */
.progress-matrix {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.progress-category {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.prog-cat-header {
    background: #f8fafc;
    padding: 10px 15px;
    font-weight: 700;
    font-size: 13px;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.prog-cat-header i {
    color: var(--accent-color);
}

.prog-items {
    padding: 10px 0;
}

.prog-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    font-size: 13px;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.prog-row:last-child {
    border-bottom: none;
}

.prog-row:hover {
    background: #f8fafc;
}

.prog-ctrl {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    width: 140px;
}

.prog-badge {
    width: 90px;
    height: 24px;
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

.prog-badge.active { display: flex; }

.prog-badge.state-none {
    background: #f1f5f9;
    color: #94a3b8;
}

.prog-badge.state-done {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #4ade80;
}

.prog-slider-container {
    display: none;
    align-items: center;
    gap: 10px;
}
.prog-slider-container.active { display: flex; }

.prog-row span { cursor: pointer; user-select: none; }
.prog-row span:hover { color: var(--accent-color); text-decoration: underline; }

.prog-slider {
    -webkit-appearance: none;
    width: 70px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 5px;
    outline: none;
}

.prog-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

.prog-val {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-color);
    width: 30px;
    text-align: right;
}
