/* --- DESIGN SYSTEM GLOBAL JMD --- */
:root {
    --primary: #0073aa; --primary-dark: #005177;
    --text-dark: #1e293b; --text-light: #64748b;
    --bg-app: #f1f5f9; --white: #ffffff;
    --radius: 8px; --sidebar-width: 260px; --border: #e2e8f0;
    --success: #10b981; --warning: #f59e0b; --danger: #ef4444;
}

body { margin: 0; font-family: 'Segoe UI', sans-serif; background: var(--bg-app); color: var(--text-dark); }

/* --- LOGIN --- */
#login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-app); display: flex; justify-content: center; align-items: center; z-index: 2000; }
.login-card { background: var(--white); padding: 50px; width: 100%; max-width: 400px; border-radius: var(--radius); text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.1); }

/* --- LAYOUT --- */
#app-layout { display: flex; min-height: 100vh; flex-direction: row; } /* Auth gérée côté serveur (PHP) */
.sidebar { width: var(--sidebar-width); min-width: var(--sidebar-width); background: var(--white); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; padding: 30px; box-sizing: border-box; display: flex; flex-direction: column; overflow-y: auto; }
.main-content { flex-grow: 1; padding: 40px; width: calc(100% - var(--sidebar-width)); box-sizing: border-box; }

/* --- ELEMENTS COMMUNS --- */
.jmd-logo { font-family: 'Times New Roman', serif; font-weight: 700; font-size: 2rem; letter-spacing: -1px; color: var(--text-dark); margin-bottom: 20px; }
.jmd-dot { color: var(--primary); font-size: 2.5rem; line-height: 0; position: relative; top: 4px; }
.npec-input { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: var(--radius); margin-bottom: 10px; box-sizing: border-box; }
.npec-btn { padding: 12px 24px; background-color: var(--primary); color: white; border: none; border-radius: var(--radius); cursor: pointer; font-weight: 600; width: 100%; margin-top:10px; }
.npec-btn:hover { background-color: var(--primary-dark); }

/* --- MENU --- */
.nav-menu { list-style: none; padding: 0; margin-top: 40px; }
.nav-item { margin-bottom: 5px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 15px; color: var(--text-light); text-decoration: none; border-radius: var(--radius); transition: 0.2s; font-weight: 500; font-size: 0.95rem; }
.nav-link:hover { background-color: #f8fafc; color: var(--primary); }
.nav-link.active { background-color: #f0f9ff; color: var(--primary); font-weight: 600; }
.nav-link.exit { color: #ef4444; }
.nav-link.exit:hover { background-color: #fef2f2; }

/* --- ICONES SVG (Mask) --- */
.icon-nav { width: 20px; height: 20px; background-color: currentColor; -webkit-mask-size: contain; mask-size: contain; mask-repeat: no-repeat; }
.i-home { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z' fill='none' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E"); }
.i-scale { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5zm0 9l2-1v6l-2 1-2-1v-6l2 1zm-8 2.5v5l6 3V16l-6-3zm10 5v-5.5l6-3v5l-6 3.5z' fill='none' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E"); }
.i-money { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm0 18a8 8 0 110-16 8 8 0 010 16zM8.5 7.5A4.5 4.5 0 0113 7h1v2h-1a2.5 2.5 0 100 5h1v2h-1a4.5 4.5 0 01-4.5-4.5H7v-4h1.5z' fill='currentColor'/%3E%3C/svg%3E"); }
.i-gift { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 22l-9-9c-3-3-3-7 0-10 2.5-2.5 6.5-2.5 9 0l.5.5.5-.5c2.5-2.5 6.5-2.5 9 0 3 3 3 7 0 10l-9 9z' fill='none' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E"); }
.i-calc { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4a2 2 0 01-2-2V4a2 2 0 012-2zm2 4v4h12V6H6zm0 6h3v3H6v-3zm5 0h3v3h-3v-3zm5 0h3v3h-3v-3zm-10 5h3v3H6v-3zm5 0h3v3h-3v-3zm5 0h3v3h-3v-3z' fill='none' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E"); }
.i-list { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.i-write { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z' fill='currentColor'/%3E%3C/svg%3E"); }
.i-tool { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.77 3.77z' fill='none' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E"); }
.i-mail { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z' stroke='currentColor' stroke-width='2' fill='none'/%3E%3Cpolyline points='22,6 12,13 2,6' stroke='currentColor' stroke-width='2' fill='none'/%3E%3C/svg%3E"); }
.i-logout { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4m7 14l5-5-5-5m5 5H9' stroke='currentColor' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.i-rdv { -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' stroke='currentColor' stroke-width='2' fill='none'/%3E%3Cline x1='16' y1='2' x2='16' y2='6' stroke='currentColor' stroke-width='2'/%3E%3Cline x1='8' y1='2' x2='8' y2='6' stroke='currentColor' stroke-width='2'/%3E%3Cline x1='3' y1='10' x2='21' y2='10' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' stroke='currentColor' stroke-width='2' fill='none'/%3E%3Cline x1='16' y1='2' x2='16' y2='6' stroke='currentColor' stroke-width='2'/%3E%3Cline x1='8' y1='2' x2='8' y2='6' stroke='currentColor' stroke-width='2'/%3E%3Cline x1='3' y1='10' x2='21' y2='10' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E"); }

/* --- COMPOSANTS MÉTIER (Simulateur, Cartes, etc.) --- */
.card-simulator { background: var(--white); padding: 40px; border-radius: var(--radius); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); margin-bottom: 30px; }
.result-box { background: #f0fdf4; border-left: 5px solid #22c55e; padding: 25px; margin-top: 30px; border-radius: var(--radius); }
.calc-row { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.calc-group { flex: 1; min-width: 200px; }
.calc-label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.9em; }
.alert-info { background: #e0f2fe; border-left: 4px solid #0284c7; color: #0c4a6e; padding: 15px; border-radius: 4px; font-size: 0.9em; line-height: 1.5; margin-bottom: 20px; }
.alert-warning { background: #fff7ed; border-left: 4px solid #f97316; padding: 20px; border-radius: var(--radius); margin: 20px 0; color: #9a3412; }

/* Checkboxes */
.checkbox-wrapper { background: #f8fafc; padding: 15px; border-radius: var(--radius); border: 1px solid #e2e8f0; margin-bottom: 12px; display: flex; gap: 15px; cursor: pointer; }

/* Financial Cards */
.financial-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 30px; }
.fin-card { padding: 20px; border-radius: var(--radius); border: 1px solid #e2e8f0; text-align: center; }
.fin-opco { background: #f0f9ff; border-color: #bae6fd; color: #0369a1; }
.fin-reste { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.fin-value { font-size: 2rem; font-weight: 800; display: block; margin: 10px 0; }
.fin-detail { font-size: 0.85rem; opacity: 0.8; line-height: 1.4; }

/* Mails */
#mail-section { display: none; margin-top: 30px; padding-top: 30px; border-top: 2px dashed #e2e8f0; }
.mail-options { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; }
.mail-opt-label { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #cbd5e1; padding: 8px 12px; border-radius: 20px; font-size: 0.8rem; cursor: pointer; user-select: none; }
.mail-opt-label:hover { background: #f1f5f9; border-color: var(--primary); }
.mail-container { position: relative; }
.mail-textarea { width: 100%; height: 450px; padding: 20px; border-radius: var(--radius); border: 1px solid #cbd5e1; font-family: 'Courier New', monospace; font-size: 0.9rem; line-height: 1.5; background: #fff; color: #1e293b; resize: vertical; box-sizing: border-box; outline: none; }
.btn-copy { position: absolute; top: 15px; right: 15px; background: #f1f5f9; color: var(--text-dark); border: 1px solid #cbd5e1; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; font-weight: 600; }
.btn-copy:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* Knowledge Base (Cadre) */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; } 
.kb-card { background: white; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; transition: transform 0.2s; display: flex; flex-direction: column; } 
.kb-card:hover { transform: translateY(-3px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }
.card-header { padding: 20px; border-bottom: 1px solid #f1f5f9; cursor: pointer; display: flex; justify-content: space-between; align-items: start; } 
.card-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 5px; color: var(--text-dark); } 
.card-badge { font-size: 0.75rem; padding: 4px 8px; border-radius: 4px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; margin-left: 10px; } 
.b-ent { background: #e0f2fe; color: #0369a1; } .b-cfa { background: #f3e8ff; color: #7e22ce; } .b-ctr { background: #dcfce7; color: #15803d; } .b-ma { background: #ffedd5; color: #c2410c; }
.card-body { padding: 20px; font-size: 0.95rem; color: #475569; line-height: 1.6; display: none; background: #fafafa; } 
.card-body.open { display: block; animation: slideDown 0.3s; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 900px) { 
    #app-layout { flex-direction: column; } 
    .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--border); } 
}

/* Print */
@media print {
    body { background: white; color: black; font-size: 12pt; }
    .sidebar, .npec-btn, #login-overlay, .btn-copy, .mail-options, h3 span { display: none !important; }
    #app-layout { display: block; }
    .main-content { width: 100%; margin: 0; padding: 0; }
    .card-simulator { box-shadow: none; border: none; padding: 0; }
    .result-box { border: 1px solid #22c55e; background: #fff; }
    .fin-card { border: 1px solid #000; break-inside: avoid; }
    .main-content::before { content: "FICHE DE SIMULATION FINANCIÈRE - AFDAS / JMD"; display: block; font-weight: bold; font-size: 1.5em; color: #0073aa; margin-bottom: 20px; border-bottom: 2px solid #0073aa; }
}