/* ═══════════════════════════════════════════════
   Constat Auto — Design Site 2 (mobile-first, app-style)
   Palette GHR — Bordeaux + Bleu
   ═══════════════════════════════════════════════ */

:root {
    --ghr-bordeaux: #7a2851;
    --ghr-bordeaux-light: #993366;
    --ghr-bordeaux-dark: #5e2a44;
    --ghr-bleu: #0047ab;
    --ghr-bleu-light: #e8eef5;
    --ghr-rouge: #e8000d;
    --ghr-bg: #f5f0f2;
    --ghr-surface: #ffffff;
    --ghr-border: #e8d8de;
    --ghr-text: #2d1a22;
    --ghr-text-muted: #6a5560;
    --ghr-input-bg: #f8f4f6;
    --ghr-shadow: 0 1px 4px rgba(0,0,0,0.08);
    --ghr-shadow-lg: 0 8px 30px rgba(122,40,81,0.12);
    --ghr-radius: 14px;
    --ghr-radius-sm: 10px;
    --header-h: 52px;
    --bottomnav-h: 64px;
    --sidebar-w: 260px;
}

/* ── Reset ── */
* { box-sizing: border-box; margin: 0; }
html, body { overflow-x: hidden; }
body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--ghr-bg);
    color: var(--ghr-text);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

/* ── Phone frame (desktop only) ── */
@media (min-width: 501px) {
    .phone-frame {
        max-width: 430px;
        margin: 20px auto;
        border-radius: 36px;
        border: 8px solid #1a1a2e;
        box-shadow: 0 20px 60px rgba(0,0,0,0.25);
        overflow: hidden;
        min-height: 90vh;
        background: var(--ghr-bg);
        position: relative;
    }
}
@media (max-width: 500px) {
    .phone-frame { min-height: 100vh; }
}

/* ═══ App Header ═══ */
.app-header {
    height: var(--header-h);
    background: var(--ghr-surface);
    border-bottom: 1px solid var(--ghr-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .burger {
    background: var(--ghr-bordeaux);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-header .logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--ghr-bordeaux);
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header .logo i { font-size: 20px; }

.app-header .spacer { flex: 1; }

.app-header .header-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--ghr-bleu-light);
    color: var(--ghr-bleu);
}

/* ═══ Sidebar (slide from left) ═══ */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--ghr-bordeaux);
    color: #f0d8e0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
    max-width: 85vw;
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-header i { font-size: 22px; color: #fff; }
.sidebar-header h2 { font-size: 16px; font-weight: 700; color: #fff; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a, .sidebar-nav button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: none;
    color: #f0d8e0;
    font-size: 15px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
}
.sidebar-nav a:hover, .sidebar-nav button:hover {
    background: rgba(0,0,0,0.2);
    color: #fff;
}
.sidebar-nav a.active {
    background: rgba(0,0,0,0.25);
    color: #fff;
    border-left: 3px solid #fff;
}
.sidebar-nav i { width: 20px; text-align: center; font-size: 16px; }

.sidebar-section {
    padding: 10px 18px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.5);
}

.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

/* ═══ Bottom Nav ═══ */
.bottomnav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--ghr-surface);
    border-top: 1px solid var(--ghr-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
.bottomnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--ghr-text-muted);
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
    min-width: 64px;
    min-height: 44px;
    justify-content: center;
    transition: color .15s;
}
.bottomnav a i { font-size: 20px; }
.bottomnav a.active { color: var(--ghr-bordeaux); }
.bottomnav a.active i { transform: translateY(-2px); }

/* ═══ Scroll Area ═══ */
.scroll-area {
    padding: 20px 16px;
    padding-bottom: calc(var(--bottomnav-h) + 20px);
}

/* ═══ Cards ═══ */
.card {
    background: var(--ghr-surface);
    border-radius: var(--ghr-radius);
    padding: 20px;
    box-shadow: var(--ghr-shadow);
    margin-bottom: 16px;
    transition: box-shadow .2s;
}
.card:active { box-shadow: var(--ghr-shadow-lg); }

.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 12px;
}
.card-icon.bordeaux { background: var(--ghr-bordeaux); color: #fff; }
.card-icon.bleu { background: var(--ghr-bleu); color: #fff; }
.card-icon.green { background: #2e7d32; color: #fff; }
.card-icon.orange { background: #e65100; color: #fff; }

.card h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.card p { font-size: 13px; color: var(--ghr-text-muted); }

.card-count {
    display: inline-block;
    background: var(--ghr-bleu-light);
    color: var(--ghr-bleu);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
    margin-top: 8px;
}

/* ═══ Page Title ═══ */
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ghr-bordeaux);
    margin-bottom: 4px;
}
.page-subtitle {
    font-size: 13px;
    color: var(--ghr-text-muted);
    margin-bottom: 20px;
}

/* ═══ Constat List Items ═══ */
.constat-item {
    background: var(--ghr-surface);
    border-radius: var(--ghr-radius-sm);
    padding: 16px;
    box-shadow: var(--ghr-shadow);
    margin-bottom: 12px;
}
.constat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}
.constat-item-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--ghr-bordeaux);
}
.constat-item-lieu {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}
.constat-item-vehicules {
    font-size: 13px;
    color: var(--ghr-text-muted);
    margin-bottom: 8px;
}
.constat-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 8px;
    text-transform: uppercase;
}
.constat-badge.brouillon { background: #fff3e0; color: #e65100; }
.constat-badge.envoye { background: #e3f2fd; color: #1976d2; }
.constat-badge.complete { background: #e8f5e9; color: #2e7d32; }

.constat-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.constat-actions .btn-sm {
    font-size: 12px;
    padding: 7px 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--ghr-radius-sm);
    border: none;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    min-height: 44px;
    transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--ghr-bordeaux); color: #fff; }
.btn-secondary { background: var(--ghr-bleu); color: #fff; }
.btn-success { background: #2e7d32; color: #fff; }
.btn-danger { background: var(--ghr-rouge); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--ghr-border); color: var(--ghr-text); }
.btn-ghost { background: transparent; color: var(--ghr-text-muted); }

.btn-sm { font-size: 13px; padding: 8px 14px; min-height: 36px; border-radius: 8px; }
.btn-full { width: 100%; }

/* ═══ Form Elements ═══ */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ghr-text);
    margin-bottom: 5px;
}
.form-label .req { color: var(--ghr-rouge); }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--ghr-border);
    border-radius: var(--ghr-radius-sm);
    font-size: 16px;
    font-family: inherit;
    background: var(--ghr-input-bg);
    color: var(--ghr-text);
    transition: border-color .15s;
    -webkit-appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--ghr-bordeaux);
    background: #fff;
}
.form-textarea { resize: vertical; min-height: 60px; }

.form-row {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}
@media (min-width: 380px) {
    .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
    .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── Radio oui/non ── */
.radio-yn {
    display: flex;
    gap: 8px;
}
.radio-yn label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 2px solid var(--ghr-border);
    border-radius: var(--ghr-radius-sm);
    font-size: 15px;
    cursor: pointer;
    flex: 1;
    justify-content: center;
    font-weight: 600;
    transition: all .15s;
}
.radio-yn label.checked {
    border-color: var(--ghr-bordeaux);
    background: var(--ghr-bordeaux);
    color: #fff;
}
.radio-yn input { display: none; }

/* ── Circumstances checkboxes ── */
.circ-row {
    display: grid;
    grid-template-columns: 28px 1fr 36px 36px;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--ghr-border);
    font-size: 13px;
}
.circ-num {
    font-weight: 700;
    color: var(--ghr-bordeaux);
    font-size: 12px;
    text-align: center;
}
.circ-label { line-height: 1.3; }
.circ-check {
    width: 28px;
    height: 28px;
    border: 2px solid var(--ghr-border);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    background: var(--ghr-input-bg);
    transition: all .15s;
}
.circ-check.checked.A { background: var(--ghr-bordeaux); color: #fff; border-color: var(--ghr-bordeaux); }
.circ-check.checked.B { background: var(--ghr-bleu); color: #fff; border-color: var(--ghr-bleu); }

/* ── Vehicle choc diagram ── */
.choc-diagram {
    width: 120px;
    height: 180px;
    border: 2px solid var(--ghr-border);
    border-radius: 10px;
    background: var(--ghr-input-bg);
    position: relative;
    margin: 8px 0;
    cursor: crosshair;
}
.choc-diagram .car-shape {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 100px;
    background: var(--ghr-surface);
    border: 2px solid var(--ghr-text);
    border-radius: 8px 8px 6px 6px;
}
.choc-point {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--ghr-rouge);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--ghr-rouge);
}

/* ── Signature canvas ── */
.signature-canvas {
    width: 100%;
    height: 120px;
    border: 2px solid var(--ghr-border);
    border-radius: var(--ghr-radius-sm);
    background: #fff;
    cursor: crosshair;
    touch-action: none;
}

/* ═══ Document A4 ═══ */
.page-a4 {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    padding: 15mm;
    margin: 0 auto;
    box-shadow: var(--ghr-shadow-lg);
    font-size: 11px;
    line-height: 1.4;
}
@media (max-width: 900px) {
    .page-a4 { width: 210mm; min-height: auto; }
}

.doc-title {
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.doc-notice {
    font-size: 9px;
    text-align: center;
    color: var(--ghr-text-muted);
    margin-bottom: 12px;
    line-height: 1.3;
}

.doc-section { margin-bottom: 10px; }
.doc-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--ghr-bordeaux);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.doc-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-field { margin-bottom: 4px; }
.doc-field-label {
    font-size: 8px;
    color: var(--ghr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.doc-field-value {
    font-size: 11px;
    font-weight: 600;
    border-bottom: 1px solid var(--ghr-border);
    min-height: 16px;
    padding: 1px 0;
}

/* ═══ Toolbar ═══ */
.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--ghr-surface);
    border-radius: var(--ghr-radius-sm);
    box-shadow: var(--ghr-shadow);
    margin-bottom: 16px;
    align-items: center;
}

/* ═══ Form Panel (style Fiche Véhicule) ═══ */
.form-panel {
    background: var(--ghr-surface);
    border-radius: var(--ghr-radius);
    padding: 20px;
    box-shadow: var(--ghr-shadow);
    margin-bottom: 16px;
}
.form-panel-header {
    background: linear-gradient(135deg, var(--ghr-bordeaux), var(--ghr-bordeaux-light));
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--ghr-radius-sm);
    margin: -20px -20px 16px;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══ VHM-style Sidebar Form (v1) ═══ */
.vhm-layout {
    display: flex;
    min-height: calc(100vh - var(--header-h) - var(--bottomnav-h));
}
.vhm-sidebar {
    width: 280px;
    background: var(--ghr-bordeaux);
    color: #f0d8e0;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
    max-width: 85vw;
}
.vhm-sidebar h3 {
    color: #fff;
    font-size: 14px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}
.vhm-sidebar .form-label { color: #f0d8e0; font-size: 11px; }
.vhm-sidebar .form-input,
.vhm-sidebar .form-select {
    background: rgba(0,0,0,0.25);
    color: #fff;
    border-color: rgba(255,255,255,0.25);
    font-size: 13px;
    padding: 8px 10px;
}
.vhm-sidebar .form-input::placeholder { color: rgba(255,255,255,0.4); }
.vhm-main {
    flex: 1;
    overflow-x: auto;
    padding: 16px;
}

@media (max-width: 900px) {
    .vhm-layout { flex-direction: column; }
    .vhm-sidebar { width: 100%; max-width: 100%; }
    .vhm-main { overflow-x: auto; }
}

/* ═══ Tabs (vehicle A/B) ═══ */
.vehicle-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-radius: var(--ghr-radius-sm);
    overflow: hidden;
    border: 2px solid var(--ghr-border);
}
.vehicle-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    background: var(--ghr-input-bg);
    border: none;
    transition: all .15s;
}
.vehicle-tab.active.a { background: var(--ghr-bordeaux); color: #fff; }
.vehicle-tab.active.b { background: var(--ghr-bleu); color: #fff; }

/* ═══ Empty State ═══ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--ghr-text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 15px; }

/* ═══ Toast ═══ */
.toast {
    position: fixed;
    bottom: calc(var(--bottomnav-h) + 16px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: #fff;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: opacity .3s, transform .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.success { background: #2e7d32; }
.toast.error { background: var(--ghr-rouge); }

/* ═══ Preview Overlay (PDF) ═══ */
.preview-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.preview-overlay.show,
.preview-overlay.open { display: flex; }
.preview-toolbar {
    background: #1a1a1a;
    color: #fff;
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-radius: 8px 8px 0 0;
    width: 92%;
    max-width: 900px;
    justify-content: space-between;
}
.preview-toolbar strong { font-size: 14px; }
.preview-container {
    background: #fff;
    width: 92%;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.preview-container img {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* ═══ Share Link Box ═══ */
.share-box {
    background: var(--ghr-bleu-light);
    border: 1px solid var(--ghr-bleu);
    border-radius: var(--ghr-radius-sm);
    padding: 12px 16px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.share-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--ghr-bleu);
    font-family: monospace;
}
.share-box .btn-sm { flex-shrink: 0; }

/* ═══ Responsive ─══ */
@media (max-width: 500px) {
    .scroll-area { padding: 16px 12px; padding-bottom: calc(var(--bottomnav-h) + 20px); }
    .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
    .doc-grid-2 { grid-template-columns: 1fr; gap: 4px; }
}

/* ═══ Print ═══ */
@media print {
    .app-header, .bottomnav, .sidebar, .sidebar-overlay,
    .toolbar, .form-panel, .vhm-sidebar, .vehicle-tabs,
    .btn, .toast, .preview-overlay { display: none !important; }
    .page-a4 { width: 100%; min-height: auto; padding: 0; box-shadow: none; margin: 0; }
    html, body { background: #fff !important; overflow: visible !important; }
    .phone-frame { border: none !important; border-radius: 0 !important; box-shadow: none !important; }
    @page { size: A4 portrait; margin: 0; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ═══ Animations ═══ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .25s ease; }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}