/* --- style.css --- */
:root {
    --primary: #2563EB; --primary-hover: #1D4ED8; --bg-app: #F3F4F6;
    --bg-panel: #FFFFFF; --text-dark: #111827; --text-grey: #6B7280;
    --border: #E5E7EB; --shadow-paper: 0 20px 25px -5px rgba(0,0,0,0.1);
}

/* RTL / LTR Automatique */
[dir="rtl"] { text-align: right; font-family: 'Cairo', sans-serif; }
[dir="ltr"] { text-align: left; font-family: 'Inter', sans-serif; }
[dir="rtl"] .editor-panel { border-left: 1px solid var(--border); border-right: none; }
[dir="ltr"] .editor-panel { border-right: 1px solid var(--border); border-left: none; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background-color: var(--bg-app); color: var(--text-dark); height: 100vh; overflow-y: hidden; display: flex; flex-direction: column; }

/* HEADER */
header { background: var(--bg-panel); height: 60px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; flex-shrink: 0; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--primary); text-decoration: none; }
.lang-nav a { text-decoration: none; color: var(--text-grey); font-weight: 600; margin-left: 15px; font-size: 0.9rem; }
.lang-nav a:hover, .lang-nav a.active { color: var(--primary); border-bottom: 2px solid var(--primary); }

/* MAIN */
main { display: flex; height: calc(100vh - 60px); width: 100%; overflow: hidden; }
.editor-panel { width: 40%; min-width: 350px; background: var(--bg-panel); padding: 2rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.5rem; }
.preview-panel { flex: 1; background: #E5E5E5; display: flex; flex-direction: column; align-items: center; padding: 2rem; overflow-y: auto; }

/* INPUTS */
.main-search { width: 100%; padding: 12px; border: 2px solid var(--border); border-radius: 8px; font-size: 1rem; background: #F9FAFB; }
.chips-container { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { font-size: 0.85rem; padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; color: var(--text-grey); }
.chip:hover, .chip.active { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.dynamic-fields { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 20px; }
label { font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; display: block; }
input, textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.btn { padding: 12px; border-radius: 8px; font-weight: 600; border: none; cursor: pointer; width: 100%; margin-top: 10px; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: white; border: 1px solid var(--border); }

/* PAPIER */
#paper-doc { width: 210mm; min-height: 297mm; background: white; padding: 25mm; box-shadow: var(--shadow-paper); margin-bottom: 2rem; color: black; line-height: 1.6; white-space: pre-wrap; }
[dir="ltr"] #paper-doc { font-family: 'Merriweather', serif; font-size: 11pt; }
[dir="rtl"] #paper-doc { font-family: 'Amiri', serif; font-size: 13pt; text-align: right; }
.preview-actions { position: sticky; bottom: 20px; background: #1e293b; padding: 10px 20px; border-radius: 50px; display: flex; gap: 15px; color: white; z-index: 10; }
.preview-actions button { background: none; border: none; color: white; cursor: pointer; font-size: 1.2rem; }

/* PRINT FIX */
@media print {
    body * { visibility: hidden; }
    #paper-doc, #paper-doc * { visibility: visible; }
    #paper-doc { position: fixed; left: 0; top: 0; width: 100%; margin: 0; padding: 20mm !important; box-shadow: none; z-index: 9999; }
    header, .preview-actions { display: none; }
}
@media (max-width: 900px) { main { flex-direction: column; height: auto; overflow: visible; } .editor-panel { width: 100%; border: none; } }