/* =============================================================================
   style.css — Feuille de styles du Générateur de Dossiers Juridiques
   =============================================================================
   Design professionnel, sobre et moderne.
   Palette : bleu marine (#1B2A4A), bleu moyen (#2C5282), accents dorés/rouges.
   ============================================================================= */


/* ---------------------------------------------------------------------------
   RESET & BASE
   --------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


:root {
    --primary: #1B2A4A;
    --primary-light: #2C5282;
    --primary-lighter: #3B6BA5;
    --accent: #C53030;
    --accent-light: #FC8181;
    --success: #276749;
    --success-light: #C6F6D5;
    --warning: #C05621;
    --warning-light: #FEFCBF;
    --bg: #F0F4F8;
    --bg-card: #FFFFFF;
    --bg-section: #F7FAFC;
    --border: #CBD5E0;
    --border-light: #E2E8F0;
    --text: #1A202C;
    --text-secondary: #4A5568;
    --text-muted: #718096;
    --text-light: #A0AEC0;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);
    --transition: all 0.2s ease;
}


html {
    font-size: 16px;
    scroll-behavior: smooth;
}


body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}


/* ---------------------------------------------------------------------------
   EN-TÊTE
   --------------------------------------------------------------------------- */
.header {
    background: var(--primary);
    color: white;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}


.header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}


.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}


.logo-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.12);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}


.logo-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}


.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 400;
    margin: 0;
}


/* ---------------------------------------------------------------------------
   CONTENU PRINCIPAL
   --------------------------------------------------------------------------- */
.main {
    flex: 1;
    padding: 32px 16px;
}


.container {
    max-width: 800px;
    margin: 0 auto;
}


.page-header {
    text-align: center;
    margin-bottom: 32px;
}


.page-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}


.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 600px;
    margin: 0 auto;
}


/* ---------------------------------------------------------------------------
   BARRE DE PROGRESSION
   --------------------------------------------------------------------------- */
.progress-container {
    margin-bottom: 32px;
}


.progress-bar {
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}


.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 14.28%;
}


.steps-indicator {
    display: flex;
    justify-content: space-between;
    position: relative;
}


.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: default;
    flex: 1;
}


.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-light);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
    border: 2px solid transparent;
}


.step-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
    transition: var(--transition);
}


.step-dot.active .step-number {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27,42,74,0.15);
}


.step-dot.active .step-label {
    color: var(--primary);
    font-weight: 600;
}


.step-dot.completed .step-number {
    background: var(--success);
    color: white;
    border-color: var(--success);
}


.step-dot.completed .step-label {
    color: var(--success);
}


/* ---------------------------------------------------------------------------
   CARTE FORMULAIRE
   --------------------------------------------------------------------------- */
.form-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
}


/* ---------------------------------------------------------------------------
   ÉTAPES DU FORMULAIRE
   --------------------------------------------------------------------------- */
.form-step {
    display: none;
    padding: 32px;
    animation: fadeIn 0.3s ease;
}


.form-step.active {
    display: block;
}


@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}


/* En-tête de chaque étape */
.step-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}


.step-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: var(--radius);
    background: rgba(27,42,74,0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}


.step-icon.adverse { background: rgba(197,48,48,0.08); color: var(--accent); }
.step-icon.litige { background: rgba(44,82,130,0.08); color: var(--primary-light); }
.step-icon.description { background: rgba(44,82,130,0.08); color: var(--primary-light); }
.step-icon.pieces { background: rgba(192,86,33,0.08); color: var(--warning); }
.step-icon.objectif { background: rgba(39,103,73,0.08); color: var(--success); }
.step-icon.finalisation { background: rgba(39,103,73,0.08); color: var(--success); }


.step-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}


.step-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}


/* ---------------------------------------------------------------------------
   GRILLE DE FORMULAIRE
   --------------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}


.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


.form-group.full-width {
    grid-column: 1 / -1;
}


.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}


.required {
    color: var(--accent);
}


.field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}


/* Champs de saisie */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-card);
    transition: var(--transition);
    outline: none;
}


input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(44,82,130,0.1);
}


input::placeholder,
textarea::placeholder {
    color: var(--text-light);
}


textarea {
    resize: vertical;
    min-height: 80px;
}


/* ---------------------------------------------------------------------------
   GRILLE DES CATÉGORIES
   --------------------------------------------------------------------------- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
}


.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 12px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: inherit;
}


.category-card:hover {
    border-color: var(--primary-light);
    background: var(--bg-section);
    transform: translateY(-1px);
}


.category-card.selected {
    border-color: var(--primary);
    background: rgba(27,42,74,0.04);
    box-shadow: 0 0 0 3px rgba(27,42,74,0.1);
}


.cat-icon {
    font-size: 1.8rem;
    line-height: 1;
}


.cat-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}


.cat-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}


/* Champs dynamiques */
.dynamic-fields-container {
    margin-top: 0;
}


.dynamic-fields-container .form-grid {
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}


.dynamic-fields-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-top: 16px;
    margin-bottom: 4px;
}


/* ---------------------------------------------------------------------------
   SÉLECTEUR D'URGENCE
   --------------------------------------------------------------------------- */
.urgence-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 8px;
}


.urgence-card {
    cursor: pointer;
}


.urgence-card input[type="radio"] {
    display: none;
}


.urgence-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    transition: var(--transition);
    text-align: center;
}


.urgence-card input:checked + .urgence-content {
    border-color: var(--primary);
    background: rgba(27,42,74,0.03);
}


.urgence-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


.urgence-badge.faible { background: #C6F6D5; color: #276749; }
.urgence-badge.moyen { background: #FEFCBF; color: #975A16; }
.urgence-badge.eleve { background: #FED7D7; color: #9B2C2C; }
.urgence-badge.critique { background: #9B2C2C; color: white; }


.urgence-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}


/* ---------------------------------------------------------------------------
   SÉLECTEUR DE TON
   --------------------------------------------------------------------------- */
.ton-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}


.ton-card {
    cursor: pointer;
}


.ton-card input[type="radio"] {
    display: none;
}


.ton-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    transition: var(--transition);
}


.ton-card input:checked + .ton-content {
    border-color: var(--primary);
    background: rgba(27,42,74,0.03);
}


.ton-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}


.ton-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}


/* ---------------------------------------------------------------------------
   ZONE D'UPLOAD
   --------------------------------------------------------------------------- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-section);
}


.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary-light);
    background: rgba(44,82,130,0.03);
}


.upload-icon {
    color: var(--text-light);
    margin-bottom: 8px;
}


.upload-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}


.upload-link {
    color: var(--primary-light);
    font-weight: 600;
    text-decoration: underline;
}


.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}


/* Liste des fichiers uploadés */
.file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}


.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-section);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}


.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}


.file-item-icon {
    color: var(--primary-light);
}


.file-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}


.file-item-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}


.file-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}


.file-item-remove:hover {
    color: var(--accent);
    background: rgba(197,48,48,0.08);
}


/* ---------------------------------------------------------------------------
   RÉCAPITULATIF
   --------------------------------------------------------------------------- */
.recap-card {
    background: var(--bg-section);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
}


.recap-card h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}


.recap-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}


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


.recap-label {
    width: 200px;
    min-width: 200px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}


.recap-value {
    font-size: 0.85rem;
    color: var(--text);
    flex: 1;
}


/* ---------------------------------------------------------------------------
   BOUTONS DE NAVIGATION
   --------------------------------------------------------------------------- */
.form-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background: var(--bg-section);
    border-top: 1px solid var(--border-light);
}


.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}


.btn-primary {
    background: var(--primary);
    color: white;
}


.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}


.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}


.btn-secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text);
}


.btn-success {
    background: var(--success);
    color: white;
    padding: 12px 32px;
    font-size: 0.95rem;
}


.btn-success:hover {
    background: #22543D;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}


.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}


/* ---------------------------------------------------------------------------
   MODALES
   --------------------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
}


.modal-overlay.active {
    display: flex;
}


.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 520px;
    width: 100%;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}


@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}


.modal-header {
    padding: 24px 28px 0;
}


.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}


.modal-body {
    padding: 20px 28px 28px;
}


/* Progression de génération */
.generation-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-section);
    border-radius: var(--radius);
}


.generation-spinner {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}


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


.generation-status {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}


/* Étapes de génération */
.generation-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}


.gen-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition);
}


.gen-step.active {
    color: var(--primary);
    font-weight: 500;
}


.gen-step.done {
    color: var(--success);
}


.gen-step-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}


.gen-step.active .gen-step-icon {
    border-color: var(--primary);
    background: var(--primary);
}


.gen-step.active .gen-step-icon::after {
    content: '';
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s ease infinite;
}


@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}


.gen-step.done .gen-step-icon {
    border-color: var(--success);
    background: var(--success);
}


.gen-step.done .gen-step-icon::after {
    content: '✓';
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    animation: none;
}


/* Modale succès */
.success-modal {
    text-align: center;
    padding: 36px 28px;
}


.success-icon-container {
    margin-bottom: 16px;
}


.success-check {
    color: var(--success);
}


.success-modal h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}


.success-modal p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}


.success-details {
    background: var(--bg-section);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}


.success-details p {
    margin: 4px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}


.success-details strong {
    color: var(--text);
}


.success-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}


/* Modale erreur */
.error-modal {
    text-align: center;
    padding: 36px 28px;
}


.error-icon {
    color: var(--accent);
}


.error-modal h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}


.error-modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9rem;
}


/* ---------------------------------------------------------------------------
   PIED DE PAGE
   --------------------------------------------------------------------------- */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-card);
}


/* ---------------------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }


    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }


    .urgence-grid {
        grid-template-columns: repeat(2, 1fr);
    }


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


    .form-step {
        padding: 24px 20px;
    }


    .form-navigation {
        padding: 16px 20px;
    }


    .step-label {
        display: none;
    }


    .steps-indicator {
        justify-content: center;
        gap: 12px;
    }


    .page-header h2 {
        font-size: 1.35rem;
    }


    .recap-row {
        flex-direction: column;
        gap: 2px;
    }


    .recap-label {
        width: auto;
        min-width: auto;
    }


    .success-actions {
        flex-direction: column;
    }


    .modal {
        max-width: 100%;
    }
}


@media (max-width: 480px) {
    .category-grid {
        grid-template-columns: 1fr;
    }


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


/* ---------------------------------------------------------------------------
   ANIMATIONS DE VALIDATION
   --------------------------------------------------------------------------- */
.form-group.error input,
.form-group.error textarea,
.form-group.error select {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(197,48,48,0.1);
}


.form-group .error-message {
    font-size: 0.75rem;
    color: var(--accent);
    display: none;
}


.form-group.error .error-message {
    display: block;
}


/* Animation de shake pour les erreurs */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}


.shake {
    animation: shake 0.5s ease;
}


/* 🆕 PARTIES ADVERSes MULTIPLES */
.adverse-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.adverse-row input {
    flex: 1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.remove-adverse {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.remove-adverse:hover {
    background: #fecaca;
    transform: none;
}

/* 🆕 GROUPES ADVERSAIRES */
.adverse-group:not(:first-child) {
    border-top: 2px solid var(--border-light);
    padding-top: 20px;
    margin-top: 20px;
}

/* 🆕 MULTI-SELECT PROBLÈMES (copropriété) */
.multi-select-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.multi-select-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
}

.multi-select-item:hover {
    border-color: var(--primary-light);
    background: var(--bg-section);
}

.multi-select-item.selected {
    border-color: var(--primary);
    background: rgba(27,42,74,0.05);
}

.multi-select-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

/* 🆕 CHAMPS DYNAMIQUES COPROPRIÉTÉ */
.form-group[style*="display: none"] {
    display: none !important;
}

/* RESPONSIVE POUR ADVERSAIRES */
@media (max-width: 768px) {
    .adverse-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .remove-adverse {
        align-self: flex-end;
        margin-top: 4px;
    }
}