/* ============================================================
   MONACARE — Design System "Heritage Clinical"
   Inspiré du logo + Design Stitch (Bordeaux #7B1535, Crème #fdf8f9)
   ============================================================ */

@import url('assets/fonts/inter.css'); /* Inter auto-hébergé (§9) — plus de Google Fonts */

.hidden { display: none !important; }

:root {
    /* ── Palette Heritage Clinical (Stitch) ── */
    --primary:            #590021;
    --primary-container:  #7B1535;
    --on-primary:         #ffffff;
    --secondary:          #436653;
    --secondary-container:#c3e9d1;

    /* Surfaces */
    --surface:            #fdf8f9;
    --surface-low:        #f7f2f3;
    --surface-high:       #ece7e8;
    --surface-highest:    #e6e1e2;
    --surface-bright:     #ffffff;

    /* Text */
    --on-surface:         #1c1b1c;
    --on-surface-variant: #564245;
    --outline:            #897174;
    --outline-variant:    #dcc0c3;

    /* State / Feedback */
    --error:              #ba1a1a;
    --success:            #10B981;
    --warning:            #F59E0B;
    --info:               #3B82F6;
    --temp-orange:        #F97316;

    /* Legacy aliases (compatibilité app.js) */
    --monaco-red:         #7B1535;
    --white:              #ffffff;
    --off-white:          #fdf8f9;
    --text-dark:          #1c1b1c;
    --text-muted:         #564245;
    --silver-dark:        #dcc0c3;
    --silver-light:       #f7f2f3;

    /* Bordures, ombres */
    --ghost-border:       rgba(220,192,195,0.4);
    --rose-shadow:        0 8px 32px rgba(86,66,69,0.12);
    --fab-shadow:         0 6px 24px rgba(123,21,53,0.35);

    /* Rayons */
    --radius-sm:   6px;
    --radius-md:   12px;
    --radius-lg:   18px;
    --radius-xl:   24px;
    --radius-full: 999px;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface-low);
    color: var(--on-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ── Demo Wrapper ─────────────────────────────────────────── */
.demo-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(160deg, #f7f2f3 0%, #ece7e8 100%);
}

/* ── Phone Shell ──────────────────────────────────────────── */
.phone {
    width: 390px;
    height: 844px;
    border-radius: 40px;
    overflow: hidden;
    position: relative;
    background: var(--surface);
    box-shadow: 0 40px 80px rgba(89,0,33,0.2), 0 0 0 1px var(--ghost-border);
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

body > .phone {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── Notch ────────────────────────────────────────────────── */
.notch {
    width: 120px;
    height: 30px;
    background: var(--on-surface);
    border-radius: 0 0 20px 20px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

/* ── Layout Containers ────────────────────────────────────── */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    overflow: hidden;
}

.views-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ── Session Banner ───────────────────────────────────────── */
#session-banner {
    display: none;
    background: var(--primary-container);
    color: var(--on-primary);
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    z-index: 50;
    flex-shrink: 0;
}

#session-banner button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s;
}
#session-banner button:hover { background: rgba(255,255,255,0.35); }

/* ── Status Bar ───────────────────────────────────────────── */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--on-surface);
    background: var(--surface);
    flex-shrink: 0;
}
.status-icons { display: flex; gap: 4px; align-items: center; color: var(--on-surface-variant); }

/* ── Role Switcher ────────────────────────────────────────── */
#role-switcher-container {
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--ghost-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

#role-switcher-container label {
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: .5px;
    flex-shrink: 0;
}

#role-select {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--ghost-border);
    border-radius: var(--radius-sm);
    background: var(--surface-bright);
    color: var(--on-surface);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    outline: none;
}
#role-select:focus { border-color: var(--primary-container); }

/* ── App Header ───────────────────────────────────────────── */
.app-header {
    padding: 14px 20px 14px;
    background: linear-gradient(135deg, var(--primary-container), var(--primary));
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.patient-info h2 {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary-container);
    letter-spacing: -0.02em;
}
.patient-info p { font-size: 12px; color: var(--on-surface-variant); margin-top: 1px; }

.header-actions { display: flex; gap: 8px; }
.header-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--ghost-border);
    background: var(--surface-low);
    color: var(--on-surface-variant);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
}
.header-btn:hover {
    background: var(--primary-container);
    color: var(--on-primary);
    border-color: var(--primary-container);
}

/* ── Bottom Nav ───────────────────────────────────────────── */
.bottom-nav {
    display: flex;
    background: rgba(253,248,249,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--ghost-border);
    padding: 8px 0 4px;
    flex-shrink: 0;
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    color: var(--outline);
    transition: color .2s;
}
.nav-btn i { font-size: 18px; }
.nav-btn span { font-size: 10px; font-weight: 600; }
.nav-btn.active { color: var(--primary-container); }
.nav-btn.active i { filter: drop-shadow(0 0 6px rgba(123,21,53,0.3)); }

/* Messages non lus — point rouge sur l'onglet concerné.
   Positionné sur l'icône plutôt que sur le bouton, pour rester collé au
   pictogramme quel que soit la largeur du libellé. */
.nav-btn { position: relative; }
.nav-btn.has-unread i::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--monaco-red, #CE1126);
    border: 2px solid var(--surface, #fff);
    box-sizing: content-box;
}

/* Pastille par conversation dans la liste des contacts : on voit d'emblée
   laquelle ouvrir, sans avoir à toutes les parcourir. */
.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 8px;
    border-radius: 999px;
    background: var(--monaco-red, #CE1126);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
}
.chat-item.has-unread h4 { font-weight: 800; }
.chat-item .chat-title-row { display: flex; align-items: center; }

/* ── Main Content Area ────────────────────────────────────── */
.view { display: none; flex: 1; overflow: hidden; background: var(--surface-low); }
.view.active { display: flex; flex-direction: column; }

.feed-area {
    flex: 1;
    overflow-y: auto;
}

.quick-actions-container {
    padding: 10px 20px;
    background: var(--surface-bright);
    margin: 8px 12px;
    border-radius: var(--radius-lg);
    box-shadow: var(--rose-shadow);
}

.quick-actions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar { display: none; }

.quick-btn {
    padding: 6px 14px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--ghost-border);
    background: var(--surface-low);
    color: var(--on-surface-variant);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s, border-color .2s;
}
.quick-btn:hover {
    background: var(--surface-high);
}
/* ── Section Cards ────────────────────────────────────────── */
.view-section {
    background: var(--surface-bright);
    margin: 12px 12px 0;
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--rose-shadow);
}
.view-section:last-child { margin-bottom: 12px; }

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--on-surface);
    display: flex;
    align-items: center;
    gap: 6px;
}
.section-title i { color: var(--primary-container); }

/* ── Vital Cards (Constantes) ─────────────────────────────── */
.vitals-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vital-card {
    background: white;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 10px rgba(89,0,33,0.07);
    border: 1px solid rgba(220,192,195,0.35);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
}
.vital-card:active { transform: scale(0.98); }

/* Bulle icône à gauche */
.vital-icon-bubble {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

/* Bloc texte central */
.vital-info {
    flex: 1;
    min-width: 0;
}
.vital-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 3px;
}
.vital-value {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--on-surface);
}
.vital-value .vital-unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-variant);
    margin-left: 3px;
}
.vital-value.empty {
    font-size: 20px;
    color: #ccc;
    font-weight: 400;
}
.vital-time {
    font-size: 10px;
    font-weight: 500;
    color: var(--on-surface-variant);
    margin-top: 4px;
    line-height: 1.2;
    letter-spacing: .2px;
}
.vital-time.stale {
    color: #F97316;
    font-weight: 600;
}
.vital-status {
    font-size: 10px;
    font-weight: 600;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Indicateur d'état à droite */
.vital-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.vital-badge.normal  { background: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
.vital-badge.alert   { background: #CE1126; box-shadow: 0 0 0 3px rgba(206,17,38,0.18); }
.vital-badge.empty   { background: #e2e8f0; }

/* ── Add Vitals Button ────────────────────────────────────── */
.add-btn {
    background: none;
    border: none;
    color: var(--primary-container);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 4px 0;
    transition: opacity .2s;
}
.add-btn:hover { opacity: 0.7; }

/* ── Pain Trackers ────────────────────────────────────────── */
.pain-trackers { display: flex; flex-direction: column; gap: 12px; }
.pain-card {
    background: var(--surface-low);
    padding: 12px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-container);
}
.pain-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--on-surface);
}
.pain-bar {
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--surface-high);
    position: relative;
}
.pain-bar::after {
    content: '';
    position: absolute;
    left: 0; top: 0; height: 100%;
    border-radius: var(--radius-full);
}
.pain-bar.val-4::after { width: 40%; background: var(--warning); }
.pain-bar.val-6::after { width: 60%; background: var(--primary-container); }
.pain-time {
    font-size: 10px;
    color: var(--on-surface-variant);
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

/* ── Clinical Notes ───────────────────────────────────────── */
.clinical-note {
    font-size: 13px;
    color: var(--on-surface);
    background: var(--surface-low);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-container);
    line-height: 1.5;
}
.clinical-note strong { display: block; margin-bottom: 4px; font-weight: 700; }

/* ── History / Tabs ───────────────────────────────────────── */
.history-btn {
    background: rgba(123,21,53,0.08);
    border: none;
    font-size: 11px;
    color: var(--primary-container);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    transition: .2s;
}
.history-btn:hover { background: rgba(123,21,53,0.16); }

.history-tabs {
    display: flex;
    background: var(--surface-high);
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    padding: 3px;
    gap: 3px;
}
.history-tabs .hist-tab {
    flex: 1; padding: 8px;
    border: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--on-surface-variant);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: .2s;
}
.history-tabs .hist-tab.active {
    background: var(--surface-bright);
    color: var(--primary-container);
    box-shadow: 0 1px 4px var(--ghost-border);
}

/* ── Vault / Coffre Médical ───────────────────────────────── */

/* Le contenu du coffre déverrouillé scrolle indépendamment */
#vault-view {
    overflow-y: auto;
}
#vault-content {
    overflow-y: auto;
    flex: 1;
}

.vault-section { padding: 12px; }

.vault-item {
    background: var(--surface-bright);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--rose-shadow);
    cursor: pointer;
    transition: transform .15s;
}
.vault-item:active { transform: scale(0.98); }

.vault-icon-wrapper {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.vault-icon-wrapper.red    { background: rgba(123,21,53,0.1); color: var(--primary-container); }
.vault-icon-wrapper.green  { background: rgba(67,102,83,0.1); color: var(--secondary); }
.vault-icon-wrapper.blue   { background: rgba(59,130,246,0.1); color: var(--info); }
.vault-icon-wrapper.orange { background: rgba(249,115,22,0.1); color: var(--temp-orange); }
.vault-icon-wrapper.locked { background: var(--surface-high); color: var(--outline); }

.vault-item-info { flex: 1; }
.vault-item-info h4 { font-size: 14px; font-weight: 700; color: var(--on-surface); }
.vault-item-info p  { font-size: 11px; color: var(--on-surface-variant); margin-top: 2px; }

.visibility-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.tag-medical { background: rgba(123,21,53,0.1); color: var(--primary-container); }
.tag-family  { background: rgba(67,102,83,0.1);  color: var(--secondary); }
.tag-team    { background: rgba(67,102,83,0.12); color: var(--secondary); }
.tag-sys     { background: var(--surface-high);  color: var(--outline); }

/* ── Activity Feed (Flux Monaco) ─────────────────────────── */
.feed-header {
    padding: 12px 16px 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--ghost-border);
}
.feed-header h3 { font-size: 16px; font-weight: 800; color: var(--on-surface); letter-spacing: -0.02em; }

.activity-feed { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.activity-item {
    background: var(--surface-bright);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--rose-shadow);
    display: flex;
    gap: 12px;
}
.activity-avatar {
    width: 42px; height: 42px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.activity-body { flex: 1; }
.activity-body p { font-size: 13px; color: var(--on-surface); line-height: 1.4; }
.activity-body strong { color: var(--primary-container); font-weight: 700; }
.activity-meta { font-size: 11px; color: var(--on-surface-variant); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.activity-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.tag-pro   { background: rgba(123,21,53,0.1); color: var(--primary-container); }
.tag-fam   { background: rgba(67,102,83,0.1); color: var(--secondary); }
.tag-sys   { background: var(--surface-high); color: var(--outline); }

/* ── Chat ─────────────────────────────────────────────────── */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--ghost-border);
}
.list-header h3 { font-size: 16px; font-weight: 800; color: var(--on-surface); letter-spacing: -0.02em; }
.icon-btn {
    background: rgba(123,21,53,0.08);
    border: none;
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    color: var(--primary-container);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.icon-btn:hover { background: rgba(123,21,53,0.16); }

.chat-list { display: flex; flex-direction: column; flex: 1; overflow-y: auto; background: var(--surface); }
.chat-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 14px;
    background: var(--surface-bright);
    margin: 0 12px 8px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow: var(--rose-shadow);
    transition: transform .15s;
}
.chat-item:active { transform: scale(0.98); }

.chat-avatar {
    width: 46px; height: 46px;
    border-radius: var(--radius-md);
    display: flex; justify-content: center; align-items: center;
    color: white; font-size: 18px; flex-shrink: 0;
}
.chat-avatar.group  { background: linear-gradient(135deg, var(--primary-container), var(--primary)); }
.chat-avatar.assist { background: linear-gradient(135deg, #3B82F6, #6366F1); }

.chat-content { flex: 1; overflow: hidden; }
.chat-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.chat-title-row h4 { font-size: 14px; font-weight: 700; color: var(--on-surface); }
.chat-title-row .time { font-size: 11px; color: var(--on-surface-variant); }
.chat-content p { font-size: 12px; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Chat Room */
.room-header {
    display: flex; align-items: center; padding: 14px 16px;
    background: var(--surface); border-bottom: 1px solid var(--ghost-border); gap: 14px;
}
.room-title h3 { font-size: 15px; font-weight: 700; color: var(--on-surface); }
.room-title p  { font-size: 11px; color: var(--primary-container); font-weight: 600; }

.chat-area { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-low); }
.message { display: flex; flex-direction: column; max-width: 85%; }
.message.received { align-self: flex-start; }
.message.sent     { align-self: flex-end; }
.sender-info { font-size: 11px; color: var(--on-surface-variant); margin-bottom: 3px; margin-left: 5px; }
.message.sent .sender-info { text-align: right; margin-right: 5px; }
.bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
}
.message.received .bubble {
    background: var(--surface-bright);
    color: var(--on-surface);
    border-bottom-left-radius: 4px;
    box-shadow: var(--rose-shadow);
}
.message.sent .bubble {
    background: var(--primary-container);
    color: white;
    border-bottom-right-radius: 4px;
}

.input-area {
    background: var(--surface);
    padding: 12px 16px 20px;
    display: flex; align-items: center; gap: 8px;
    border-top: 1px solid var(--ghost-border);
}
.action-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-full);
    border: 1px solid var(--ghost-border);
    background: var(--surface-low);
    color: var(--on-surface-variant);
    cursor: pointer; font-size: 14px;
    display: flex; justify-content: center; align-items: center;
}
.input-wrapper {
    flex: 1;
    background: var(--surface-low);
    border-radius: var(--radius-full);
    padding: 0 14px;
    display: flex; align-items: center;
    border: 1px solid var(--ghost-border);
}
.input-wrapper input {
    width: 100%; border: none; background: transparent;
    padding: 11px 0; font-size: 14px; outline: none;
    font-family: 'Inter', sans-serif; color: var(--on-surface);
}
.send-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-container);
    border: none; color: white;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; font-size: 14px;
    transition: transform .15s;
}
.send-btn:hover { transform: scale(1.08); }

/* ── Attachment popup ─────────────────────────────────────── */
.attachment-popup {
    position: absolute; bottom: 80px; left: 16px;
    background: var(--surface-bright);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    border: 1px solid var(--ghost-border);
    display: flex; flex-direction: column; z-index: 50;
    overflow: hidden;
}
.attachment-popup.hidden { display: none; }
.attach-item {
    background: transparent; border: none;
    padding: 12px 18px; font-size: 13px;
    color: var(--on-surface); display: flex; align-items: center;
    gap: 10px; font-weight: 500; cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background .15s;
}
.attach-item:hover { background: var(--surface-low); }

/* ── Modals ───────────────────────────────────────────────── */
.modal {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(28,27,28,0.5);
    backdrop-filter: blur(6px);
    display: flex; justify-content: center; align-items: flex-end;
    z-index: 2000;
    border-radius: 35px;
}
.modal-content {
    background: var(--surface-bright);
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 24px 20px 32px;
    box-shadow: 0 -12px 40px rgba(89,0,33,0.12);
    max-height: 85%;
    overflow-y: auto;
    text-align: center;
}
.modal-content::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--surface-high);
    border-radius: 2px;
    margin: 0 auto 20px;
}
.modal-content h3 { font-size: 17px; font-weight: 800; margin-bottom: 4px; color: var(--on-surface); }
.modal-btn {
    width: 100%; padding: 14px;
    border: none; border-radius: var(--radius-md);
    font-weight: 700; font-size: 14px;
    font-family: 'Inter', sans-serif;
    cursor: pointer; margin-bottom: 10px;
    transition: opacity .2s;
}
.modal-btn:not(.cancel) { background: var(--primary-container); color: white; }
.modal-btn:not(.cancel):hover { opacity: 0.9; }
.modal-btn.cancel { background: var(--surface-high); color: var(--on-surface); margin-bottom: 0; }

/* ── Charts (canvas areas) ────────────────────────────────── */
.chart-container { width: 100%; height: 140px; position: relative; }

/* ── Home Indicator ───────────────────────────────────────── */
.home-indicator {
    width: 120px; height: 4px;
    background: var(--on-surface);
    border-radius: 2px;
    margin: 4px auto 8px;
    position: absolute; bottom: 6px;
    left: 50%; transform: translateX(-50%);
    z-index: 3000;
    opacity: 0.15;
}

/* ── Dictation Button ─────────────────────────────────────── */
.dictation-btn {
    margin: 0 16px 16px;
    background: var(--primary-container);
    color: white; border: none;
    padding: 14px; border-radius: var(--radius-lg);
    font-family: 'Inter', sans-serif;
    font-size: 14px; font-weight: 700;
    display: flex; justify-content: center; align-items: center;
    gap: 10px; cursor: pointer;
    box-shadow: var(--fab-shadow);
    transition: transform .15s;
}
.dictation-btn:hover { transform: translateY(-1px); }

/* ── Settings Modal Content ───────────────────────────────── */
.settings-section { margin-bottom: 20px; }
.settings-section h4 {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--on-surface-variant);
    margin-bottom: 10px;
}
.settings-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--ghost-border);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    background: var(--surface-low);
    color: var(--on-surface);
    margin-bottom: 8px;
    outline: none;
    transition: border-color .2s;
}
.settings-input:focus { border-color: var(--primary-container); background: white; }
.pro-list-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface-low);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    gap: 10px;
}
.pro-list-item .pro-avatar {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(123,21,53,0.1);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary-container); font-size: 14px; flex-shrink: 0;
}
.pro-list-item h4 { font-size: 13px; font-weight: 700; color: var(--on-surface); }
.pro-list-item p  { font-size: 11px; color: var(--on-surface-variant); }

/* ── Biometric Gate ───────────────────────────────────────── */
.bio-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 16px;
    flex: 1;
}
.bio-icon {
    width: 72px; height: 72px;
    border-radius: var(--radius-xl);
    background: rgba(123,21,53,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px;
    color: var(--primary-container);
}
.bio-gate h3 { font-size: 18px; font-weight: 800; color: var(--on-surface); }
.bio-gate p  { font-size: 13px; color: var(--on-surface-variant); line-height: 1.5; }
.bio-btn {
    background: var(--primary-container);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: var(--radius-lg);
    font-family: 'Inter', sans-serif;
    font-size: 15px; font-weight: 700;
    cursor: pointer;
    box-shadow: var(--fab-shadow);
    display: flex; align-items: center; gap: 10px;
    transition: transform .15s;
}
.bio-btn:hover { transform: translateY(-1px); }

/* ── Feed Post Cards (Flux Monaco) ───────────────────────── */
.feed-post {
    background: var(--surface-bright);
    border-radius: var(--radius-lg);
    margin: 10px 12px 0;
    box-shadow: var(--rose-shadow);
    overflow: hidden;
    animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 8px;
}
.post-avatar {
    width: 38px; height: 38px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px;
    flex-shrink: 0;
    color: white;
    background: linear-gradient(135deg, var(--primary-container), var(--primary));
}
.post-meta { flex: 1; }
.post-meta h4 { font-size: 13px; font-weight: 700; color: var(--on-surface); }
.post-meta p  { font-size: 11px; color: var(--on-surface-variant); margin-top: 1px; }

.post-content {
    padding: 4px 14px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--on-surface);
    line-height: 1.4;
}
.post-content p { margin: 0; }

.post-image {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    display: block;
}

.post-actions {
    display: flex;
    gap: 6px;
    padding: 6px 14px 12px;
    border-top: 1px solid var(--ghost-border);
    margin-top: 4px;
}
.reply-btn {
    background: none;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--on-surface-variant);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.reply-btn:hover { background: var(--surface-low); color: var(--primary-container); }

.post-comments {
    padding: 0 14px;
}
.comment-item {
    font-size: 12px;
    color: var(--on-surface);
    background: var(--surface-low);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    margin-bottom: 6px;
    line-height: 1.4;
}
.comment-input-row {
    display: flex;
    gap: 6px;
    padding: 6px 14px 10px;
}
.comment-input-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--ghost-border);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    background: var(--surface-low);
    color: var(--on-surface);
    outline: none;
}
.comment-input-row input:focus { border-color: var(--primary-container); }
.comment-send-btn {
    width: 30px; height: 30px;
    border-radius: var(--radius-full);
    background: var(--primary-container);
    border: none; color: white;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* Tags dans les posts */
.tag-team   { background: rgba(67,102,83,0.12);  color: var(--secondary); }
.tag-medical { background: rgba(123,21,53,0.1); color: var(--primary-container); }
.tag-urgent { background: rgba(186,26,26,0.12); color: var(--error); }

/* ── Biometric Gate (coffre) ──────────────────────────────── */
.biometric-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    gap: 16px;
    flex: 1;
    background: var(--surface-low);
}
.biometric-overlay .bio-icon {
    width: 80px; height: 80px;
    border-radius: var(--radius-xl);
    background: rgba(123,21,53,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    color: var(--primary-container);
    margin-bottom: 4px;
}
.biometric-overlay h3 { font-size: 18px; font-weight: 800; color: var(--on-surface); }
.biometric-overlay p  { font-size: 13px; color: var(--on-surface-variant); line-height: 1.5; max-width: 240px; }
.biometric-overlay .code-section {
    width: 100%;
    border-top: 1px solid var(--ghost-border);
    padding-top: 16px;
    margin-top: 4px;
}
.biometric-overlay .code-section p { font-size: 12px; margin-bottom: 8px; }
.biometric-overlay .code-row {
    display: flex;
    gap: 8px;
}
.biometric-overlay .code-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--ghost-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    letter-spacing: 2px;
    outline: none;
    background: var(--surface-bright);
    color: var(--on-surface);
}
.biometric-overlay .code-row input:focus { border-color: var(--primary-container); }
.biometric-overlay .code-row button {
    padding: 10px 16px;
    background: var(--primary-container);
    color: white; border: none;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-weight: 700; font-size: 13px;
    cursor: pointer;
}

/* ── Vault Header Banner ──────────────────────────────────── */
.vault-header-banner {
    background: linear-gradient(135deg, var(--primary-container), var(--primary));
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.vault-header-banner p { font-size: 11px; color: rgba(255,255,255,0.7); }
.unlocked-badge {
    background: rgba(16,185,129,0.25);
    color: #6ee7b7;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: .3px;
    text-transform: uppercase;
}

/* ── Chat empty state ─────────────────────────────────────── */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 24px;
    text-align: center;
    gap: 12px;
    color: var(--on-surface-variant);
}
.chat-empty-state i { font-size: 36px; opacity: 0.3; }
.chat-empty-state p { font-size: 13px; line-height: 1.5; }
.chat-new-btn {
    background: var(--primary-container);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-weight: 700; font-size: 13px;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    box-shadow: var(--fab-shadow);
    transition: transform .15s;
}
.chat-new-btn:hover { transform: translateY(-1px); }

/* ── Feedback states ──────────────────────────────────────── */
.empty-msg {
    text-align: center;
    color: var(--on-surface-variant);
    font-size: 13px;
    padding: 24px 0;
    opacity: 0.6;
}

/* ── Responsive Mobile ────────────────────────────────────── */
@media (max-width: 600px) {
    html, body {
        height: 100dvh;
        min-height: 0;
        margin: 0;
        overflow: hidden;                 /* pas de scroll de PAGE : seules les vues internes défilent */
        background: var(--surface);
        touch-action: manipulation;       /* empêche le double-tap zoom */
        -webkit-text-size-adjust: 100%;   /* pas de re-dimensionnement auto du texte */
    }
    .demo-wrapper {
        height: 100dvh;
        min-height: 0;
        padding: 0;
        background: var(--surface);
    }
    .phone {
        width: 100%;
        height: 100dvh;                   /* remplit exactement l'écran visible */
        min-height: 0;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        position: relative;
        top: auto; left: auto;
        transform: none;
    }
    .notch, .home-indicator { display: none; }
    /* Safe-areas : en-tête sous l'encoche, nav du bas au-dessus de la barre d'accueil */
    .app-header { padding-top: calc(14px + env(safe-area-inset-top)); }
    .bottom-nav { padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
}

/* ── HEADER DROPDOWN MENU ───────────────────────────────── */
.header-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    width: 200px;
    z-index: 9999;
    overflow: hidden;
    animation: dropIn 0.15s ease;
}
@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s;
    font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-low); }
.dropdown-item i { width: 16px; text-align: center; color: var(--outline); }
.dropdown-divider { height: 1px; background: var(--outline-variant); margin: 4px 0; }
.dropdown-danger { color: var(--error, #ba1a1a) !important; }
.dropdown-danger i { color: var(--error, #ba1a1a) !important; }

/* ── VISIBILITY TAG INTERACTIF ─────────────────────────── */
.visibility-tag {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: opacity 0.15s;
}
.visibility-tag:hover { opacity: 0.75; }
.visibility-tag::after {
    content: ' ▾';
    font-size: 9px;
    opacity: 0.6;
}

/* Popup de choix de visibilité — positionné en fixed via JS (getBoundingClientRect) */
.visibility-popup {
    background: white;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    min-width: 175px;
    overflow: hidden;
    animation: dropIn 0.12s ease;
}
.vis-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: .3px;
    transition: background 0.1s;
}
.vis-option:hover { background: var(--surface-low); }
.vis-option i { width: 14px; text-align: center; }

/* Menu déroulant visibilité au clic sur la flèche d'envoi */
.send-vis-popup {
    background: white;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    min-width: 190px;
    overflow: hidden;
    animation: dropIn 0.12s ease;
}
.send-vis-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .3px;
    transition: background 0.1s;
    border-bottom: 1px solid #f0e8e9;
}
.send-vis-option:last-child { border-bottom: none; }
.send-vis-option:hover { background: var(--surface-low); }
.send-vis-option i { width: 14px; text-align: center; color: var(--monaco-red); }

/* Bouton supprimer sur les posts */
.delete-post-btn {
    background: none;
    border: none;
    color: #ccc;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s;
    line-height: 1;
}
.delete-post-btn:hover { color: #CE1126; }


/* MC-11 — Image dont la lecture est refusée (droits révoqués) ou en cours de
   résolution. Le refus est un comportement ATTENDU : le message doit rester
   lisible, seule la photo bascule en repli discret. */
img.media-unavailable {
    display: block;
    min-width: 140px;
    min-height: 44px;
    padding: 12px 14px;
    margin-top: 6px;
    border: 1px dashed var(--outline, #d8c8ca);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.03);
    color: var(--on-surface-variant, #897174);
    font-size: 12px;
    font-style: italic;
    cursor: default;
}
img[data-loading] {
    min-width: 140px;
    min-height: 44px;
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(0,0,0,.04), rgba(0,0,0,.08), rgba(0,0,0,.04));
}
