:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-app: #0f172a;
        --bg-card: #1e293b;
        --text-main: #f1f5f9;
        --border: #334155;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- HEADER --- */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0; z-index: 100;
}

.logo { font-weight: bold; font-size: 1.2rem; }
.logo span { color: var(--primary); }

.lang-switch { display: flex; gap: 10px; }
.lang-switch a { text-decoration: none; font-size: 1.2rem; opacity: 0.6; transition: 0.2s; }
.lang-switch a.active, .lang-switch a:hover { opacity: 1; transform: scale(1.1); }

/* --- LAYOUT PRINCIPAL --- */
.main-layout, .container .grid {
    display: grid;
    /* Desktop par défaut */
    grid-template-columns: 350px 1fr; 
    gap: 2rem;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
    width: 100%;
}

/* --- CONFIG PANEL (GAUCHE) --- */
.config-panel, .form-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.form-group { margin-bottom: 1rem; }
label { 
    font-size: 0.85rem; 
    font-weight: 600; 
    color: var(--text-muted); 
    display: block; 
    margin-bottom: 0.4rem; 
}

/* Inputs optimisés pour mobile (taille 16px pour éviter le zoom iOS) */
input, select, textarea {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 16px; 
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea { min-height: 80px; resize: vertical; }

/* --- ZONE PAPIER (DROITE) --- */
.paper-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.paper {
    background: white;
    color: #000; /* Toujours noir sur papier */
    
    /* Responsive A4 logic */
    width: 100%;
    max-width: 210mm; /* Largeur max A4 */
    min-height: 297mm;
    
    padding: 2.5rem; /* Marges du document */
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    font-family: 'Charter', 'Georgia', Times, serif;
    font-size: 11pt;
    line-height: 1.6;
    white-space: pre-wrap;
    outline: none;
    border-radius: 2px;
}

/* --- BOUTONS --- */
.btn-group { display: flex; gap: 10px; flex-direction: column; }

.btn-primary, .btn-secondary {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    width: 100%;
    transition: 0.2s;
    font-size: 0.95rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }

/* --- MOBILE RESPONSIVE (TÉLÉPHONES) --- */
@media (max-width: 900px) {
    .main-layout, .container .grid {
        grid-template-columns: 1fr; /* Une seule colonne */
        padding: 1rem;
        margin: 1rem auto;
        gap: 1.5rem;
    }

    /* Le panneau de config passe au-dessus */
    .config-panel {
        order: 1; 
    }
    
    /* Le papier passe en dessous */
    .paper-container {
        order: 2;
    }

    .paper {
        /* On réduit les marges internes sur mobile pour gagner de la place */
        padding: 1.5rem; 
        font-size: 10pt; /* Texte légèrement plus petit */
        min-height: 50vh; /* Hauteur ajustée */
    }

    header { padding: 0.8rem 1rem; }
    .logo span strong { display: none; } /* Simplifier le logo sur très petits écrans */
}

/* --- IMPRESSION --- */
@media print {
    header, .config-panel, .ad-slot, .btn-group, footer, .seo-content { 
        display: none !important; 
    }
    body { background: white; margin: 0; }
    .main-layout, .container .grid { display: block; margin: 0; padding: 0; width: 100%; max-width: none; }
    .paper-container { display: block; }
    .paper { 
        box-shadow: none; 
        border: none; 
        width: 100%; 
        max-width: 100%;
        margin: 0; 
        padding: 0; 
        min-height: 0;
    }
}