/* --- 0. CSS CUSTOM PROPERTIES --- */
:root {
  --brand:        #e67e22;
  --brand-dark:   #d35400;
  --brand-shadow: rgba(230, 126, 34, 0.22);
  --text-dark:   #2c3e50;
  --text-muted:  #95a5a6;
  --text-sub:    #7f8c8d;
  --bg-light:    #f4f6f9;
  --bg-card:     #ffffff;
  --border:      #ecf0f1;
  --border-dark: #ddd;
  --green:       #27ae60;
  --blue:        #2980b9;
  --red:         #e74c3c;
  --shadow-sm:   0 2px 12px rgba(0,0,0,0.06);
  --radius:      12px;
  --radius-sm:   8px;
}

/* --- 1. RESET & GLOBAL --- */
* {
    box-sizing: border-box; /* CRUCIAL : Les paddings ne s'ajoutent plus � la largeur */
}

html, body { 
    height: 100%;       /* Prend tout l'�cran */
    margin: 0; 
    padding: 0;
    overflow: hidden;   /* Emp�che le scrollbar global du navigateur */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background-color: #f4f6f9; 
    color: #333; 
    font-size: 16px;
    line-height: 1.6;
}

h1, h2, h3 { color: #2c3e50; }
.hidden { display: none !important; }

/* --- 2. HEADER (Fixe : 60px) --- */
header {
    height: 70px;
    background-color: var(--brand);
    padding: 0 25px;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    position: relative;
}

header h1 { margin: 0; font-size: 1.5em; color: white; }
nav button { background: none; border: none; padding: 10px 20px; cursor: pointer; font-size: 1em; color: rgba(255,255,255,0.8); transition: 0.3s; border-radius: 8px; }
nav button:hover { background-color: rgba(255,255,255,0.18); color: white; }
nav button.active { background-color: var(--brand-dark); color: white; font-weight: bold; }

/* --- 3. MAIN (Le conteneur principal) --- */
main {
    height: calc(100vh - 70px);
    width: 100%;
    padding: 20px;
    position: relative;
}

/* Gestion du scroll par section */
section {
    height: 100%;       /* Prend toute la place dans main */
    display: flex;
    flex-direction: column;
}

/* Les sections "longues" ont le droit de scroller */
#sec-dashboard, #sec-patients, #sec-finances, #sec-config, #sec-gestion, #sec-stats {
    overflow-y: auto;   /* Scroll vertical autoris� */
    padding-right: 5px; /* Petit espace pour la scrollbar */
}

/* L'agenda INTERDIT le scroll global (c'est FullCalendar qui g�re) */
#sec-agenda {
    overflow: hidden; 
}

.container-limited { max-width: 1600px; margin: 0 auto; width: 100%; }

/* --- 4. AGENDA FULL SCREEN (C�ur du probl�me r�solu) --- */
.agenda-card { 
    background: white; 
    height: 100%;       /* Remplit toute la section */
    padding: 15px; 
    border-radius: 10px; 
    display: flex; 
    flex-direction: column; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.agenda-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 10px;
    flex-shrink: 0;     /* Ne r�tr�cit jamais */
}

#calendar-container { 
    flex: 1;            /* Prend TOUT l'espace restant en hauteur */
    overflow: hidden;   /* Coupe ce qui d�passe */
    position: relative; 
}

#calendar { 
    height: 100%;       /* Force FullCalendar � remplir le conteneur */
    width: 100%;
}

/* Cache les scrollbars internes de FullCalendar (Chrome/Safari) */
.fc-scroller::-webkit-scrollbar {
    display: none; 
}
/* Cache les scrollbars internes (Firefox/IE) */
.fc-scroller {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* --- 5. COMPOSANTS UI --- */
.card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); margin-bottom: 20px; }

/* Flexbox Utils */
.flex-row { display: flex; gap: 15px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; }
.align-end { align-items: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.gap-10 { gap: 10px; } .gap-15 { gap: 15px; } .mb-15 { margin-bottom: 15px; } .mb-20 { margin-bottom: 20px; } .mt-0 { margin-top: 0; } .w-full { width: 100%; }

/* Boutons */
.btn { padding: 11px 22px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: 0.2s; font-size: 1em; }
.btn-sm { padding: 8px 16px; font-size: 0.9em; }
.btn-blue { background-color: #3498db; color: white; } .btn-blue:hover { background-color: #2980b9; }
.btn-green { background-color: #27ae60; color: white; } .btn-green:hover { background-color: #219150; }
.btn-orange { background-color: var(--brand); color: white; } .btn-orange:hover { background-color: var(--brand-dark); }
.btn-red { background-color: #e74c3c; color: white; } .btn-red:hover { background-color: #c0392b; }
.btn-grey { background-color: #95a5a6; color: white; } .btn-grey:hover { background-color: #7f8c8d; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th { text-align: left; padding: 12px 10px; background-color: #f8f9fa; color: #7f8c8d; font-size: 0.82em; text-transform: uppercase; border-bottom: 2px solid #eee; }
td { padding: 12px 10px; border-bottom: 1px solid #ecf0f1; font-size: 1em; }
tr:hover { background-color: #f5f7fa; }

/* Formulaires */
label { display: block; margin-bottom: 6px; font-weight: bold; font-size: 0.95em; color: #7f8c8d; }
input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="password"], input[type="email"], select {
    width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 1em; outline: none; transition: 0.3s;
}
input:focus, select:focus { border-color: #3498db; box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* KPI Dashboard */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 20px; }
.kpi-card { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); text-align: center; }
.kpi-title { margin: 0; font-size: 0.9em; text-transform: uppercase; color: #95a5a6; letter-spacing: 1px; }
.kpi-value { font-size: 2.2em; font-weight: bold; margin-top: 10px; color: #2c3e50; }
.text-green { color: #27ae60; } .text-blue { color: #2980b9; }

/* Finances Toolbar */
.toolbar { background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #eee; }
.tabs { display: flex; border-bottom: 2px solid #eee; margin-bottom: 20px; }
.tab { padding: 10px 20px; cursor: pointer; color: #7f8c8d; font-weight: 600; font-size: 1em; }
.tab:hover { color: #3498db; }
.tab.active { border-bottom: 3px solid var(--brand); color: var(--brand); margin-bottom: -3px; }
.import-area { padding: 30px; border: 2px dashed #ddd; text-align: center; background: #fafafa; margin-bottom: 20px; border-radius: 8px; }

/* Badges */
.badge { padding: 5px 10px; border-radius: 12px; font-size: 0.85em; color: white; display: inline-block; font-weight: 600; }
.bg-green { background-color: #27ae60; } .bg-red { background-color: #e74c3c; } .bg-orange { background-color: #f39c12; } .bg-grey { background-color: #95a5a6; }

/* Config Comptes */
.accounts-container { display: flex; gap: 30px; flex-wrap: wrap; }
.account-panel { flex: 1; min-width: 300px; }
.account-title { font-size: 1.2em; font-weight: bold; margin-bottom: 10px; }
.account-separator { width: 1px; background-color: #eee; }
.cal-list { list-style: none; padding: 0; margin: 0; border: 1px solid #eee; border-radius: 6px; }
.cal-item { padding: 10px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }

/* Modales */
.modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    /* Fond blanc presque opaque pour la confidentialit� */
    background-color: rgba(255, 255, 255, 0.98); 
    /* Effet de flou si le navigateur le supporte */
    backdrop-filter: blur(10px); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 1000; 
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-content { 
    background: white; 
    padding: 30px; 
    border-radius: 12px; 
    width: 550px; 
    max-width: 90%; 
    position: relative; 
    animation: slideIn 0.3s; 
    /* Ombre plus douce car sur fond blanc */
    box-shadow: 0 10px 40px rgba(0,0,0,0.15); 
    border: 1px solid #eee;
}
.close { position: absolute; top: 15px; right: 20px; font-size: 1.8em; cursor: pointer; color: #aaa; }
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Scroll Liste */
.scroll-list { max-height: 60vh; overflow-y: auto; }

/* --- DASHBOARD FILTERS --- */
.filter-btn {
    font-size: 0.9em;
    padding: 6px 12px;
}
.active-filter {
    background-color: #2c3e50 !important;
    color: white !important;
}
.loader-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--brand);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.w-full { width: 100%; }

/* --- NOUVEAU DASHBOARD (Assistant) --- */
.timeline-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 30px;
}

.timeline-slots {
    display: flex;
    gap: 20px;
}

.nav-arrow {
    background: none;
    border: none;
    font-size: 2em;
    color: #bdc3c7;
    cursor: pointer;
    transition: color 0.2s;
}
.nav-arrow:hover { color: #2c3e50; }

/* Boutons fléchés du dashboard */
.timeline-nav-btn {
    background: none;
    border: 2px solid #ecf0f1;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.2em;
    cursor: pointer;
    color: #7f8c8d;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.timeline-nav-btn:hover {
    background: #ecf0f1;
    border-color: #bdc3c7;
    color: #2c3e50;
}

/* --- CONFIG CARD GRID --- */
.config-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 10px;
}

.config-card {
    background: white;
    border-radius: 12px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.config-card:hover {
    border-color: var(--brand);
    transform: translateY(-3px);
    box-shadow: 0 6px 18px var(--brand-shadow);
}
.config-card-icon { font-size: 2.2em; margin-bottom: 10px; }
.config-card h3 { margin: 0 0 6px; color: #2c3e50; font-size: 1em; }
.config-card p  { margin: 0; font-size: 0.82em; color: #95a5a6; }

/* --- ICON PICKER --- */
.icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    padding: 6px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dde;
}
.icon-option {
    font-size: 1.3em;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.12s, transform 0.1s;
    user-select: none;
}
.icon-option:hover    { background: #ecf0f1; transform: scale(1.15); }
.icon-option.selected { background: #3498db22; outline: 2px solid #3498db; border-radius: 6px; }

/* --- CALENDRIER LIST ITEMS --- */
.cal-list { list-style: none; padding: 0; margin: 0; }
.cal-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}
.cal-list-item:last-child { border-bottom: none; }
.cal-item-icon { font-size: 1.3em; flex-shrink: 0; }
.cal-item-name { font-weight: 600; color: #2c3e50; }

.time-slot {
    width: 260px;
    text-align: center;
    transition: transform 0.3s ease, opacity 0.3s;
}

.time-slot.present {
    width: 320px;
}

.slot-label {
    font-size: 0.85em;
    font-weight: bold;
    color: #95a5a6;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.slot-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    min-height: 170px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Slot Actuel (EN COURS) */
.present .slot-card {
    border: 3px solid var(--brand);
    box-shadow: 0 8px 30px var(--brand-shadow);
    z-index: 2;
}
.present .slot-label { color: var(--brand); }

/* Slot Pass� */
.past .slot-card {
    opacity: 0.7;
    background: #f9f9f9;
}

.patient-name {
    font-weight: bold;
    font-size: 1.25em;
    color: #2c3e50;
    margin-bottom: 5px;
}

.patient-time {
    font-size: 1.8em;
    color: #34495e;
    font-family: 'Segoe UI', monospace; /* Pour un look horloge */
}

.slot-action {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, white);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}
.slot-action:hover {
    background: var(--brand);
    color: white;
}

/* --- LOGIN SCREEN --- */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    z-index: 9999; /* Au-dessus de tout ! */
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.login-card h1 { color: var(--brand); margin-bottom: 20px; }
.login-card input { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 6px; }
.login-card button { width: 100%; padding: 12px; font-size: 1.1em; }

/* --- GESTION FINANCIÈRE --- */

.gestion-month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    background: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.gestion-nav-btn {
    background: none;
    border: 2px solid #ddd;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 1.2em;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
.gestion-nav-btn:hover { background: #ecf0f1; border-color: #bdc3c7; }

.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}
@media (max-width: 900px) { .summary-cards { grid-template-columns: repeat(2, 1fr); } }

.summary-card {
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    text-align: center;
}
.summary-label {
    font-size: 0.78em;
    color: #7f8c8d;
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.summary-value {
    font-size: 1.5em;
    font-weight: 700;
    color: #2c3e50;
}
.income-color  { color: #27ae60; }
.expense-color { color: #e74c3c; }

.income-center-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}
.income-center-row:last-child { border-bottom: none; }

.export-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Badges catégorie dépense */
.cat-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.78em;
    font-weight: 600;
    background: #ecf0f1;
    color: #2c3e50;
}
.cat-loyer      { background: #d5eaff; color: #2471a3; }
.cat-materiel   { background: #d5f5e3; color: #1a7a45; }
.cat-abonnement { background: #fdebd0; color: #935116; }
.cat-formation  { background: #f2d7f7; color: #6c3483; }
.cat-assurance  { background: #ffdede; color: #a93226; }
.cat-autre      { background: #ecf0f1; color: #566573; }

/* Icône action dans tableau */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 1em;
    border-radius: 4px;
    transition: background 0.15s;
}
.btn-icon:hover { background: #ecf0f1; }
.btn-danger-icon:hover { background: #fdecea; }

/* --- Badge non payé (Dashboard timeline) --- */
.badge-unpaid {
    background: #e74c3c;
    color: white;
    font-size: 0.65em;
    padding: 2px 7px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 6px;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Tri colonnes Finances --- */
.sort-btn { cursor: pointer; user-select: none; }
.sort-btn:hover { color: #3498db; }
.fin-sort-btn { font-size: 0.8em; color: #aaa; margin-left: 3px; }

/* --- Filtres rapides Patients --- */
.patient-filters-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.patient-filters-row select { flex: 1; min-width: 180px; }

/* --- Estimation des charges --- */
.charges-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.92em;
}
.charges-row.charges-net {
    border-bottom: none;
    border-top: 2px solid #8e44ad;
    margin-top: 6px;
    padding-top: 10px;
}
.charges-disclaimer {
    font-size: 0.78em;
    color: #95a5a6;
    margin-top: 10px;
    margin-bottom: 0;
    font-style: italic;
}

/* --- Summary cards — couleurs par métrique --- */
.summary-card:nth-child(1) { border-top: 3px solid #27ae60; }
.summary-card:nth-child(2) { border-top: 3px solid #2980b9; }
.summary-card:nth-child(3) { border-top: 3px solid #e74c3c; }
.summary-card:nth-child(4) { border-top: 3px solid var(--brand); }

/* --- Étiquette de section colorée (Statistiques) --- */
.stats-section-label {
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-left: 4px solid;
    padding: 4px 10px;
    margin: 0 0 12px;
    background: transparent;
}

/* --- Section divider (Statistiques) --- */
.section-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 36px 0 24px;
}
.section-divider-line { flex: 1; height: 2px; background: #ecf0f1; }
.section-divider-label {
    font-size: 0.88em;
    font-weight: 700;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

/* --- Export card --- */
.export-card-title { font-size: 1em; color: #2c3e50; margin-bottom: 6px; }
.export-card-hint { font-size: 0.85em; color: #95a5a6; margin: 0 0 15px; }

/* --- Quick action cards descriptions --- */
.quick-card-desc { font-size: 0.82em; color: #95a5a6; margin: 4px 0 0; }

/* --- Horloge dans le header --- */
.header-clock {
    font-size: 1em;
    font-weight: 700;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    font-family: 'Segoe UI', monospace;
    white-space: nowrap;
}

/* --- Agenda — overrides FullCalendar --- */
.agenda-header {
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}
.fc .fc-button {
    border-radius: 8px !important;
    font-size: 0.85em !important;
}
.fc .fc-toolbar-title {
    font-size: 1.1em !important;
    font-weight: 700 !important;
}
/* ─────────────────────────────────────────────────────
   DESIGN SYSTEM — SESSION 5 (refonte UI)
   ───────────────────────────────────────────────────── */

/* --- CLASSES UTILITAIRES --- */
.text-muted  { color: var(--text-muted); }
.text-sub    { color: var(--text-sub); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }
.font-mono   { font-family: 'Segoe UI', monospace; }
.italic      { font-style: italic; }

/* Color swatch (config types RDV) */
.color-swatch {
    width: 20px; height: 20px;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Bouton retour unifie */
.btn-back {
    background: none; border: none; cursor: pointer;
    color: var(--text-sub); font-size: 0.9em;
    padding: 6px 0; margin-bottom: 16px;
    display: inline-flex; align-items: center; gap: 6px;
    transition: color 0.2s;
}
.btn-back:hover { color: var(--text-dark); }

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 2.2em;
    display: block;
    margin-bottom: 8px;
    opacity: 0.45;
}
.empty-state p {
    margin: 0;
    font-size: 0.9em;
}
.empty-row td {
    text-align: center;
    padding: 28px 12px;
    color: var(--text-muted);
    font-size: 0.9em;
    font-style: italic;
}

/* --- TABLEAUX — LISIBILITE --- */
tbody tr:nth-child(even) { background: #f9fafb; }
tbody tr:nth-child(even):hover { background: #f5f7fa; }
td { word-break: break-word; }
td.td-actions { max-width: none; white-space: nowrap; }
td.td-date    { white-space: nowrap; max-width: none; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- BOUTONS D'ACTION DANS TABLEAUX --- */
.action-cell  { display: flex; gap: 4px; align-items: center; }
.btn-xs {
    padding: 6px 12px;
    font-size: 0.88em;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.15s;
}
.btn-xs.btn-blue   { background: #3498db; color: white; }
.btn-xs.btn-red    { background: #e74c3c; color: white; }
.btn-xs.btn-grey   { background: #95a5a6; color: white; }
.btn-xs.btn-orange { background: var(--brand); color: white; }
.btn-xs:hover { opacity: 0.85; }

/* --- BADGES ROLES & ORIGINES --- */
.badge-role-superuser { background: #8e44ad; }
.badge-role-user      { background: #2980b9; }
.badge-origin {
    padding: 3px 8px; border-radius: 10px;
    font-size: 0.78em; font-weight: 600; color: white;
    display: inline-block;
}
.badge-rosa       { background: var(--brand); }
.badge-mobminder  { background: #9b59b6; }
.badge-google     { background: #3498db; }
.badge-manuel     { background: #95a5a6; }
.badge-archived {
    background: var(--brand); color: white;
    padding: 2px 7px; border-radius: 8px;
    font-size: 0.75em; font-weight: 600;
    display: inline-block; margin-left: 4px;
}

/* --- MODAUX SCROLLABLES --- */
.modal-content {
    overflow-y: auto;
    max-height: 90vh;
}
.modal { cursor: pointer; }
.modal .modal-content { cursor: default; }

/* --- FOCUS VISIBLE --- */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* --- QR ERROR --- */
.qr-error {
    color: var(--red);
    font-size: 0.85em;
    background: #fdecea;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 8px;
}

/* --- DATE LABEL DANS SLOT TIMELINE --- */
.slot-date-label {
    font-size: 0.72em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

/* --- LIEN JUSTIFICATIF --- */
.receipt-link { color: var(--blue); text-decoration: none; }
.receipt-link:hover { color: #2471a3; text-decoration: underline; }

/* ─────────────────────────────────────────────────────
   RESPONSIVE — MOBILE / TABLETTE
   ───────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .config-card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    header {
        height: auto;
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 6px;
    }
    header h1 { font-size: 1.1em; }
    nav {
        order: 3;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    nav button { padding: 6px 10px; font-size: 0.85em; }
    .header-clock { display: none; }
    main { height: auto; min-height: calc(100vh - 110px); overflow-y: auto; }
    #sec-dashboard, #sec-patients, #sec-finances,
    #sec-config, #sec-gestion { overflow-y: visible; height: auto; }
}

@media (max-width: 600px) {
    .config-card-grid { grid-template-columns: 1fr; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .modal-content {
        padding: 20px !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 12px 12px 0 0 !important;
    }
    .modal { align-items: flex-end; }
    .timeline-container { flex-direction: column; align-items: center; }
    .timeline-slots { flex-direction: column; gap: 12px; width: 100%; }
    .time-slot, .time-slot.present { width: 100%; max-width: 360px; }
    .flex-row { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .login-card { width: 94vw; padding: 24px; }
}

/* ========== THEME PICKER ========== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 20px;
}
.theme-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  background: var(--bg-card);
  position: relative;
}
.theme-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.theme-card-selected { border-color: var(--brand); background: #fef9f4; }
.theme-preview-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin: 0 auto 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
}
.theme-label { font-size: 0.92em; font-weight: 600; color: var(--text-dark); display: block; }
.theme-check {
  position: absolute;
  top: 8px; right: 10px;
  color: var(--brand);
  font-weight: 700;
  font-size: 1.1em;
}
@media (max-width: 600px) {
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Tour guidé (démo) ────────────────────────────────────────────────────── */

.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: all;
    background: transparent;
    transition: background 0.3s ease;
}

.tour-spotlight {
    position: fixed;
    z-index: 9001;
    border-radius: 10px;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
    transition: left 0.35s ease, top 0.35s ease, width 0.35s ease, height 0.35s ease, opacity 0.25s ease;
    outline: 2px solid rgba(255, 255, 255, 0.35);
}

.tour-tooltip {
    position: fixed;
    z-index: 9002;
    background: #fff;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    transition: top 0.35s ease, left 0.35s ease;
    pointer-events: all;
}

/* Flèche pointant vers l'élément (position calculée via --tour-arrow-offset) */
.tour-tooltip.arrow-top::before,
.tour-tooltip.arrow-bottom::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    left: var(--tour-arrow-offset, 50%);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0,0,0,0.06);
}
.tour-tooltip.arrow-top::before    { top: -7px; }
.tour-tooltip.arrow-bottom::before { bottom: -7px; box-shadow: 2px 2px 4px rgba(0,0,0,0.06); }

/* Intérieur de la bulle */
.tour-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.tour-counter {
    font-size: 0.78em;
    color: #aaa;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.tour-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #ccc;
    font-size: 1em;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
.tour-close:hover { color: #888; }

.tour-progress {
    height: 3px;
    background: #eee;
    border-radius: 2px;
    margin-bottom: 14px;
    overflow: hidden;
}
.tour-progress-bar {
    height: 100%;
    background: var(--brand, #6a9f7e);
    border-radius: 2px;
    transition: width 0.35s ease;
}

.tour-title {
    margin: 0 0 10px;
    font-size: 0.98em;
    color: #2c3e50;
    line-height: 1.3;
}

.tour-body {
    font-size: 0.875em;
    color: #444;
    line-height: 1.65;
}
.tour-body p          { margin: 0 0 8px; }
.tour-body p:last-child { margin-bottom: 0; }
.tour-note {
    color: #aaa !important;
    font-size: 0.82em !important;
    font-style: italic;
}

.tour-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    gap: 8px;
}
.tour-btn-prev {
    background: none;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.85em;
    cursor: pointer;
    color: #666;
    transition: background 0.15s;
}
.tour-btn-prev:hover { background: #f5f5f5; }

.tour-btn-next {
    background: var(--brand, #6a9f7e);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.tour-btn-next:hover  { background: var(--brand-dark, #4e8a65); }
.tour-btn-next:active { transform: scale(0.97); }

/* ── Notes de séance (historique patient) ────────────────────────────────── */
.hist-notes-toggle {
    cursor: pointer;
    font-size: 0.95em;
    margin-left: 6px;
    opacity: 0.7;
    transition: opacity 0.15s;
    user-select: none;
}
.hist-notes-toggle:hover { opacity: 1; }

/* ── Éditeur de notes rich text (RTE) ───────────────────────────────────── */
.rte-container { margin-top: 15px; }

.rte-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--brand);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-radius 0.15s;
    text-align: left;
}
.rte-toggle-btn:hover { background: var(--brand-dark); }
.rte-toggle-active { border-radius: 8px 8px 0 0 !important; }

.rte-panel {
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.rte-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}
.rte-btn {
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-size: 0.85em;
    color: #444;
    line-height: 1.4;
}
.rte-btn:hover { background: #e0e0e0; border-color: #ccc; }
.rte-sep {
    width: 1px;
    height: 18px;
    background: #ccc;
    margin: 0 4px;
    flex-shrink: 0;
}

.rte-editor {
    min-height: 110px;
    max-height: 320px;
    overflow-y: auto;
    padding: 10px 14px;
    outline: none;
    font-family: inherit;
    font-size: 0.9em;
    line-height: 1.65;
    background: white;
    color: #333;
}
.rte-editor:empty::before {
    content: attr(data-placeholder);
    color: #bbb;
    pointer-events: none;
}
.rte-editor ul, .rte-editor ol { margin: 4px 0; padding-left: 22px; }
.rte-editor li { margin: 2px 0; }

/* ── Journal des notes de séances (fiche patient) ───────────────────────── */
.notes-journal-entry {
    margin-bottom: 14px;
    padding: 11px 14px;
    border-left: 3px solid var(--brand);
    background: color-mix(in srgb, var(--brand) 5%, white);
    border-radius: 0 6px 6px 0;
}
.notes-journal-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8em;
    color: #888;
    margin-bottom: 7px;
    font-weight: 500;
}
.notes-journal-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.notes-journal-entry:hover .notes-journal-actions { opacity: 1; }
.notes-journal-content {
    font-size: 0.88em;
    line-height: 1.7;
    color: #333;
}
.notes-journal-content ul, .notes-journal-content ol { margin: 3px 0; padding-left: 20px; }

/* ── Dialogs applicatifs (appAlert / appConfirm) ─────────────────────────── */
.app-dialog {
    max-width: 420px;
    display: flex;
    gap: 18px;
    align-items: flex-start;
    padding: 26px 24px 22px;
}
.app-dialog-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35em;
    flex-shrink: 0;
}
.app-dialog-icon--success { background: #e8f8f0; }
.app-dialog-icon--error   { background: #fdecea; }
.app-dialog-icon--warning { background: #fff4e5; }
.app-dialog-icon--info    { background: color-mix(in srgb, var(--brand) 12%, white); }
.app-dialog-icon--danger  { background: #fdecea; }
.app-dialog-body  { flex: 1; min-width: 0; }
.app-dialog-title { margin: 0 0 8px 0; font-size: 1em; font-weight: 700; color: #1a1a1a; }
.app-dialog-msg   { margin: 0; font-size: 0.92em; color: #555; line-height: 1.6; }
.app-dialog-footer { margin-top: 22px; display: flex; justify-content: flex-end; }
.app-dialog-footer--split { justify-content: space-between; }

/* ── Toast Notifications ─────────────────────────────────────────────────── */
#toast-container { position:fixed; bottom:20px; right:20px; z-index:10000; display:flex; flex-direction:column-reverse; gap:8px; pointer-events:none; }
.toast { padding:11px 18px; border-radius:8px; font-size:0.88em; color:#fff; opacity:0; transform:translateY(10px); transition:opacity 0.3s, transform 0.3s; box-shadow:0 3px 10px rgba(0,0,0,0.18); max-width:300px; pointer-events:auto; }
.toast.show { opacity:1; transform:translateY(0); }
.toast-success { background:#27ae60; }
.toast-error   { background:#e74c3c; }
.toast-warning { background:#e67e22; }
.toast-info    { background:#3498db; }

/* ── Recherche globale header ─────────────────────────────────────────────── */
#global-search-input::placeholder { color: rgba(255,255,255,0.6); }
#global-search-input:focus { background: rgba(255,255,255,0.28) !important; }
.global-search-dropdown { position:absolute; top:calc(100% + 6px); left:0; right:0; background:#fff; border-radius:10px; box-shadow:0 4px 16px rgba(0,0,0,0.15); max-height:320px; overflow-y:auto; z-index:5000; }
.gs-item { padding:10px 14px; cursor:pointer; border-bottom:1px solid #f0f0f0; display:flex; flex-direction:column; gap:2px; }
.gs-item:last-child { border-bottom:none; }
.gs-item:hover { background: color-mix(in srgb, var(--brand) 8%, white); }
.gs-item-name { font-weight:600; font-size:0.9em; color:#2c3e50; }
.gs-item-rdv  { font-size:0.8em; color:#7f8c8d; }
.gs-empty { padding:12px 14px; font-size:0.88em; color:#aaa; text-align:center; }

/* ── Champs obligatoires ─────────────────────────────────────────────────── */
label .req { color: var(--brand); margin-left: 2px; font-weight: bold; }

/* ── Page Santé Système ──────────────────────────────────────────────────── */
.stat-box { background: #f8f9fa; border-radius: 8px; padding: 12px; text-align: center; font-size: 0.9em; color: #7f8c8d; }
.stat-box strong { display: block; font-size: 1.5em; color: #2c3e50; margin-top: 4px; }

/* ── Tags patients ───────────────────────────────────────────────────────── */
.tag-chip { display:inline-flex; align-items:center; gap:4px; padding:3px 9px; border-radius:12px; font-size:0.78em; font-weight:600; color:#fff; }
.tag-chip-remove { cursor:pointer; opacity:0.75; background:none; border:none; color:inherit; font-size:0.9em; padding:0; margin-left:2px; }
.tag-chip-remove:hover { opacity:1; }

/* ── Bouton notes timeline ───────────────────────────────────────────────── */
.slot-notes-btn { display:none; margin:6px auto 0; font-size:0.78em; background:var(--brand-light, #e8f4ee); border:1px solid var(--brand); color:var(--brand); padding:4px 10px; border-radius:10px; cursor:pointer; width:calc(100% - 20px); text-align:center; }
.slot-notes-btn:hover { background:var(--brand); color:white; }


/* ── Impression ──────────────────────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
}
