/* ============================================================
   Forsa Immo Planner v2 — PAU Cahier de Charges Viewer
   ============================================================ */

.fip-app.fip-v2 {
    max-width: 1400px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: #1d2327;
    line-height: 1.5;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}
.fip-app.fip-v2 *, .fip-app.fip-v2 *::before, .fip-app.fip-v2 *::after { box-sizing: border-box; }

/* ---------- Header ---------- */
.fip-v2 .fip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    color: #fff;
    gap: 20px;
}
.fip-v2 .fip-header h2 { margin: 0 0 2px; color: #fff; font-size: 20px; }
.fip-v2 .fip-header p { margin: 0; opacity: 0.9; font-size: 13px; }
.fip-v2 .fip-header-logo-img { max-height: 42px; background: #fff; padding: 4px 8px; border-radius: 4px; }

/* ---------- Main Layout: Map + Panel ---------- */
.fip-v2 .fip-main-layout {
    display: flex;
    min-height: 650px;
}

/* --- Map side --- */
.fip-v2 .fip-map-container {
    flex: 1;
    position: relative;
    min-width: 0;
}
.fip-v2 .fip-map {
    width: 100%;
    height: 100%;
    min-height: 650px;
    z-index: 1;
}

/* Map overlays */
.fip-v2 .fip-map-overlay-top {
    position: absolute;
    top: 12px;
    left: 60px;
    right: 12px;
    z-index: 1000;
}
.fip-v2 .fip-search-bar input {
    width: 100%;
    max-width: 320px;
    padding: 10px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    outline: none;
}
.fip-v2 .fip-search-bar input:focus {
    border-color: #1e3a5f;
}

/* Legend toggle */
.fip-v2 .fip-legend-toggle {
    position: absolute;
    bottom: 50px;
    left: 12px;
    z-index: 1000;
}
.fip-v2 .fip-btn-icon {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.fip-v2 .fip-btn-icon:hover { background: #f0f0f0; }

/* Legend panel */
.fip-v2 .fip-legend-panel {
    position: absolute;
    bottom: 90px;
    left: 12px;
    z-index: 1000;
    background: #fff;
    border-radius: 8px;
    padding: 14px 16px;
    max-height: 360px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    min-width: 260px;
}
.fip-v2 .fip-legend-panel h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #1e3a5f;
}
.fip-v2 .fip-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    cursor: pointer;
}
.fip-v2 .fip-legend-item:hover { background: #f5f5f5; border-radius: 4px; }
.fip-v2 .fip-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #aaa;
    flex-shrink: 0;
}
.fip-v2 .fip-legend-code { font-weight: 700; min-width: 40px; }

/* Status bar */
.fip-v2 .fip-map-status {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255,255,255,0.95);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
}
.fip-v2 .fip-map-status.success { background: rgba(220,252,231,0.95); }
.fip-v2 .fip-map-status.error { background: rgba(254,226,226,0.95); }

/* --- Info Panel side --- */
.fip-v2 .fip-info-panel {
    width: 440px;
    flex-shrink: 0;
    background: #fafbfc;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    max-height: 700px;
}

/* Empty state */
.fip-v2 .fip-panel-empty {
    padding: 40px 30px;
    text-align: center;
}
.fip-v2 .fip-empty-icon { font-size: 48px; margin-bottom: 12px; }
.fip-v2 .fip-panel-empty h3 { margin: 0 0 8px; color: #1e3a5f; }
.fip-v2 .fip-panel-empty p { color: #666; font-size: 14px; }
.fip-v2 .fip-empty-hint {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    text-align: left;
}
.fip-v2 .fip-select-large {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    margin-top: 8px;
}

/* Zone info panel */
.fip-v2 .fip-panel-zone {
    padding: 0;
}

/* Zone header */
.fip-v2 .fip-zone-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 20px 12px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
}
.fip-v2 .fip-zone-badge {
    font-size: 18px;
    font-weight: 800;
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    background: #1e3a5f;
    text-align: center;
    min-width: 60px;
    line-height: 1.2;
}
.fip-v2 .fip-zone-header h3 {
    margin: 0 0 6px;
    font-size: 16px;
    color: #1d2327;
    line-height: 1.3;
}
.fip-v2 .fip-zone-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.fip-v2 .fip-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}
.fip-v2 .fip-tag-classification {
    background: #e8f4fd;
    color: #1e5a8f;
}
.fip-v2 .fip-tag-type {
    background: #e8fde8;
    color: #1e5a2f;
}

.fip-v2 .fip-zone-desc {
    padding: 12px 20px;
    margin: 0;
    font-size: 13px;
    color: #555;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
}

/* Sections */
.fip-v2 .fip-section {
    border-bottom: 1px solid #e8e8e8;
}
.fip-v2 .fip-section-title {
    margin: 0;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 700;
    color: #1e3a5f;
    background: #fff;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
    user-select: none;
}
.fip-v2 .fip-section-title:hover { background: #f5f8fb; }
.fip-v2 .fip-section-title .fip-toggle {
    font-size: 11px;
    color: #999;
    transition: transform 0.2s;
}
.fip-v2 .fip-section-title.collapsed .fip-toggle { transform: rotate(-90deg); }
.fip-v2 .fip-section-warning { background: #fffbeb; }

.fip-v2 .fip-section-body {
    padding: 0 20px 16px;
    background: #fff;
}

/* Implantation */
.fip-v2 .fip-implantation-type {
    font-size: 15px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 10px;
}
.fip-v2 .fip-implant-icons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.fip-v2 .fip-implant-icon {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid;
}
.fip-v2 .fip-implant-icon.allowed {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}
.fip-v2 .fip-implant-icon.forbidden {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
    text-decoration: line-through;
    opacity: 0.6;
}
.fip-v2 .fip-implant-desc {
    font-size: 13px;
    color: #555;
    margin: 0;
    line-height: 1.5;
}

/* Rules grid */
.fip-v2 .fip-rules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.fip-v2 .fip-rule-card {
    background: #f6f8fa;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}
.fip-v2 .fip-rule-card.fip-rule-highlight {
    background: #eef4ff;
    border-color: #3b82f6;
}
.fip-v2 .fip-rule-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
}
.fip-v2 .fip-rule-value {
    font-size: 16px;
    font-weight: 800;
    color: #1d2327;
}

/* Usages */
.fip-v2 .fip-usages-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.fip-v2 .fip-usages-cols h5 {
    margin: 0 0 8px;
    font-size: 13px;
}
.fip-v2 .fip-usages-cols ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.fip-v2 .fip-usages-cols li {
    padding: 4px 0;
    font-size: 12px;
    line-height: 1.4;
    border-bottom: 1px solid #f0f0f0;
}
.fip-v2 .fip-usages-allowed li::before { content: '✅ '; }
.fip-v2 .fip-usages-forbidden li::before { content: '🚫 '; }

/* Architecture */
.fip-v2 .fip-archi-list {}
.fip-v2 .fip-archi-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}
.fip-v2 .fip-archi-item:last-child { border-bottom: none; }
.fip-v2 .fip-archi-label {
    font-weight: 700;
    color: #1e3a5f;
    min-width: 100px;
    text-transform: capitalize;
    flex-shrink: 0;
}
.fip-v2 .fip-archi-value { color: #444; }

/* Parking */
.fip-v2 #fip-parking-text {
    margin: 0;
    font-size: 13px;
    color: #444;
}

/* Special conditions */
.fip-v2 .fip-warning-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.fip-v2 .fip-warning-list li {
    padding: 8px 12px;
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    margin-bottom: 6px;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #92400e;
}

/* Check my lot */
.fip-v2 .fip-section-check .fip-section-title {
    background: #f0f7ff;
}
.fip-v2 .fip-check-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}
.fip-v2 .fip-check-inputs label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}
.fip-v2 .fip-check-inputs input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}
.fip-v2 .fip-check-result {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
}
.fip-v2 .fip-check-result.valid {
    background: #dcfce7;
    border: 1px solid #22c55e;
    color: #166534;
}
.fip-v2 .fip-check-result.invalid {
    background: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

/* Panel actions */
.fip-v2 .fip-panel-actions {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
}

/* Buttons */
.fip-v2 .fip-btn {
    padding: 10px 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    background: #fff;
    color: #333;
    font-weight: 600;
    transition: all 0.15s;
}
.fip-v2 .fip-btn:hover { background: #f0f0f0; }
.fip-v2 .fip-btn-primary {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
    flex: 1;
}
.fip-v2 .fip-btn-primary:hover { background: #2c5282; }
.fip-v2 .fip-btn-help {
    background: #fff;
    color: #1e3a5f;
    border: 2px solid #1e3a5f;
}

/* Modal */
.fip-v2 .fip-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; }
.fip-v2 .fip-modal-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); }
.fip-v2 .fip-modal-content { position: relative; background: #fff; border-radius: 10px; padding: 30px; max-width: 420px; width: 90%; }
.fip-v2 .fip-modal-close { position: absolute; top: 12px; right: 16px; font-size: 24px; background: none; border: none; cursor: pointer; color: #999; }
.fip-v2 .fip-modal h3 { margin: 0 0 8px; color: #1e3a5f; }
.fip-v2 .fip-input-group { margin-bottom: 14px; }
.fip-v2 .fip-input-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.fip-v2 .fip-input-group input { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
.fip-v2 .fip-error { color: #dc2626; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .fip-v2 .fip-main-layout {
        flex-direction: column;
    }
    .fip-v2 .fip-info-panel {
        width: 100%;
        max-height: none;
        border-left: none;
        border-top: 1px solid #e0e0e0;
    }
    .fip-v2 .fip-map {
        min-height: 400px;
    }
    .fip-v2 .fip-rules-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .fip-v2 .fip-usages-cols {
        grid-template-columns: 1fr;
    }
    .fip-v2 .fip-check-inputs {
        grid-template-columns: 1fr;
    }
    .fip-v2 .fip-header {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 500px) {
    .fip-v2 .fip-rules-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---------- Print styles ---------- */
@media print {
    .fip-v2 .fip-map-container,
    .fip-v2 .fip-panel-actions,
    .fip-v2 .fip-section-check,
    .fip-v2 .fip-legend-toggle,
    .fip-v2 .fip-map-overlay-top,
    .fip-v2 .fip-map-status { display: none !important; }

    .fip-v2 .fip-main-layout { display: block; }
    .fip-v2 .fip-info-panel {
        width: 100%;
        max-height: none;
        border: none;
    }
    .fip-v2 .fip-section-body { display: block !important; }
    .fip-v2 .fip-section-title .fip-toggle { display: none; }
}

/* ============ V2 ADDITIONS ============ */

/* Language toggle */
.fip-v2 .fip-header-right { display: flex; align-items: center; gap: 12px; }
.fip-v2 .fip-header-logo-img { max-height: 42px; background: #fff; padding: 4px 8px; border-radius: 4px; }
.fip-v2 .fip-lang-btn {
    padding: 6px 14px; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.4);
    border-radius: 6px; color: #fff; font-size: 13px; font-weight: 700; cursor: pointer;
}
.fip-v2 .fip-lang-btn:hover { background: rgba(255,255,255,0.3); }

/* RTL support */
.fip-v2.fip-rtl { direction: rtl; text-align: right; }
.fip-v2.fip-rtl .fip-zone-header { flex-direction: row-reverse; }
.fip-v2.fip-rtl .fip-section-title { flex-direction: row-reverse; }
.fip-v2.fip-rtl .fip-implant-icons { direction: ltr; }
.fip-v2.fip-rtl .fip-archi-item { flex-direction: row-reverse; }
.fip-v2.fip-rtl .fip-archi-label { text-align: right; }

/* City selector */
.fip-v2 .fip-map-controls {
    display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap;
}
.fip-v2 .fip-city-select {
    padding: 10px 12px; border: 2px solid #ddd; border-radius: 8px; font-size: 13px;
    background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15); min-width: 180px;
    cursor: pointer;
}

/* GPS button */
.fip-v2 .fip-gps-btn {
    width: 42px; height: 42px; border: 2px solid #ddd; border-radius: 8px; font-size: 18px;
    background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.fip-v2 .fip-gps-btn:hover { background: #eef4ff; border-color: #1e3a5f; }
.fip-v2 .fip-gps-btn.locating { animation: fip-pulse 1s infinite; }
@keyframes fip-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Search results dropdown */
.fip-v2 .fip-search-bar { position: relative; flex: 1; min-width: 200px; }
.fip-v2 .fip-search-results {
    position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #ddd;
    border-radius: 0 0 8px 8px; max-height: 250px; overflow-y: auto; z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.fip-v2 .fip-search-result-item {
    padding: 10px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f0f0f0;
}
.fip-v2 .fip-search-result-item:hover { background: #eef4ff; }
.fip-v2 .fip-search-result-item:last-child { border-bottom: none; }

/* Zone boundary highlight */
.fip-zone-highlight {
    stroke: #1e3a5f;
    stroke-width: 3;
    stroke-dasharray: 8 4;
    fill-opacity: 0.15;
}

/* PDF export button style */
.fip-v2 .fip-btn-pdf {
    background: #dc2626; color: #fff; border-color: #dc2626;
}
.fip-v2 .fip-btn-pdf:hover { background: #b91c1c; }
