/* Invox Mail : présentation inspirée d'Outlook sur le web (Fluent). */
:root {
    --brand: #0f6cbd; --brand-dark: #115ea3; --brand-light: #ebf3fc; --brand-soft: #cfe4fa;
    --bg: #f5f5f5; --surface: #ffffff; --surface-2: #fafafa; --border: #e0e0e0; --border-2: #d1d1d1;
    --text: #242424; --text-2: #616161; --text-3: #8a8a8a; --hover: #f0f0f0; --selected: #ebf3fc; --unread: #0f6cbd;
    --danger: #c50f1f; --warn: #bc4b09; --ok: #107c10; --flag: #c50f1f;
    --radius: 6px; --font: "Segoe UI", "Segoe UI Web", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="dark"] {
    --bg: #1f1f1f; --surface: #292929; --surface-2: #2e2e2e; --border: #3d3d3d; --border-2: #4a4a4a;
    --text: #ffffff; --text-2: #d6d6d6; --text-3: #adadad; --hover: #333333; --selected: #1f3a54; --brand-light: #1f3a54; --brand-soft: #24476b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* ----- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 4px;
       border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; height: 36px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; color: inherit; font-size: 16px; text-decoration: none; }
.icon-btn:hover { background: rgba(0, 0, 0, .07); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 14px; }

/* ----- Connexion */
.login-page { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(140deg, #e9f2fb 0%, #f5f5f5 55%, #dfe9f5 100%); padding: 16px; }
.login-box { width: 100%; max-width: 420px; background: #fff; padding: 40px 44px; border-radius: 8px; box-shadow: 0 8px 32px rgba(0, 0, 0, .12); }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color: #424242; margin-bottom: 24px; }
.login-box h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
.login-box label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: 13px; }
.login-box input[type=email], .login-box input[type=password] { width: 100%; height: 36px; padding: 0 10px; border: 1px solid #c7c7c7; border-bottom-color: #616161; border-radius: 4px; outline: none; }
.login-box input:focus { border-bottom: 2px solid var(--brand); }
.login-box .check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 16px 0 20px; }
.notice { padding: 10px 12px; border-radius: 4px; margin: 12px 0; font-size: 13px; }
.notice.info { background: var(--brand-light); color: #0c3b5e; }
.notice.error { background: #fdf3f4; color: var(--danger); border: 1px solid #eeacb2; }
.app-logo { width: 30px; height: 30px; border-radius: 7px; display: inline-grid; place-items: center; background: var(--brand); color: #fff; font-size: 16px; }

/* ----- Structure de l'application */
body.app { overflow: hidden; }
#app { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 48px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 8px 0 12px; background: var(--brand); color: #fff; }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .15); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; min-width: 200px; }
.brand .app-logo { background: #fff; color: var(--brand); }
.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--brand); }
.search input { width: 100%; height: 32px; border: 0; border-radius: 4px; padding: 0 34px; background: #e8f1fb; color: #242424; outline: none; }
.search input:focus { background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.search .clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: #616161; cursor: pointer; display: none; }
.search.has-text .clear { display: block; }
.top-right { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.avatar-btn { border: 0; background: transparent; padding: 4px; cursor: pointer; border-radius: 50%; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 600; font-size: 12px; color: #fff; background: #8764b8; flex: none; text-transform: uppercase; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.avatar.me { background: #ca5010; border: 2px solid rgba(255, 255, 255, .7); }

.shell { flex: 1; display: flex; min-height: 0; }
.rail { width: 52px; flex: none; background: var(--surface-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding-top: 8px; gap: 4px; }
.rail-btn { width: 44px; border: 0; background: transparent; border-radius: 6px; padding: 8px 0 6px; cursor: pointer; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; }
.rail-btn i { font-size: 20px; }
.rail-btn:hover { background: var(--hover); }
.rail-btn.active { color: var(--brand); background: var(--brand-light); }

.folders { width: 236px; flex: none; background: var(--surface-2); border-right: 1px solid var(--border); padding: 12px 8px; overflow-y: auto; display: flex; flex-direction: column; }
.new-mail { width: 100%; height: 36px; margin-bottom: 14px; }
.folders-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; font-weight: 600; color: var(--text-2); font-size: 13px; }
.folder-list { list-style: none; padding: 0; margin: 0; flex: 1; }
.folder { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 4px; cursor: pointer; position: relative; user-select: none; }
.folder i { color: var(--text-2); font-size: 16px; width: 18px; text-align: center; }
.folder .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder .count { font-weight: 600; color: var(--brand); font-size: 12px; }
.folder .count.total { color: var(--text-3); font-weight: 400; }
.folder:hover { background: var(--hover); }
.folder.active { background: var(--selected); font-weight: 600; }
.folder.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--brand); }
.folder.unread .name { font-weight: 600; }
.folder.drop-target { outline: 2px dashed var(--brand); background: var(--brand-light); }
.folder .more { visibility: hidden; border: 0; background: transparent; cursor: pointer; color: var(--text-2); padding: 0 2px; }
.folder:hover .more { visibility: visible; }
.quota { padding: 10px 8px 0; border-top: 1px solid var(--border); margin-top: 8px; }
.quota-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.quota-bar span { display: block; height: 100%; background: var(--brand); }
.quota-bar.warn span { background: var(--warn); }
.quota-bar.full span { background: var(--danger); }

.mail-view, .contacts-view { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.commandbar { height: 44px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); background: var(--surface); overflow-x: auto; scrollbar-width: none; }
.cmd { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; white-space: nowrap; color: var(--text); text-decoration: none; }
.cmd i { color: var(--brand); font-size: 16px; }
.cmd:hover { background: var(--hover); }
.cmd:disabled { opacity: .4; cursor: default; background: transparent; }
.cmd.right { margin-left: auto; }
.primary-cmd { font-weight: 600; }
.sep { width: 1px; height: 20px; background: var(--border-2); margin: 0 6px; flex: none; }

.panes { flex: 1; display: flex; min-height: 0; }
.list-pane { width: 380px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.pane-bottom .panes { flex-direction: column; }
.pane-bottom .list-pane { width: auto; height: 45%; border-right: 0; border-bottom: 1px solid var(--border); }
.pane-off .reading-pane { display: none; }
.pane-off .list-pane { width: auto; flex: 1; }
.pane-off.reading .reading-pane { display: flex; }
.pane-off.reading .list-pane { display: none; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 8px 16px; }
.list-head h2 { margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-tools { display: flex; align-items: center; gap: 4px; }
.list-tools select, .contact-search { height: 28px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--surface); padding: 0 6px; }
.contact-search { width: 180px; }
.list { flex: 1; overflow-y: auto; outline: none; }
.group-label { padding: 12px 16px 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.item { display: flex; gap: 10px; padding: 9px 12px 9px 13px; border-left: 3px solid transparent; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; user-select: none; }
.item:hover { background: var(--hover); }
.item.selected { background: var(--selected); }
.item.unread { border-left-color: var(--unread); }
.item .avatar { width: 32px; height: 32px; font-size: 12px; position: relative; }
.item .check { display: none; position: absolute; inset: 0; border-radius: 50%; background: var(--brand); color: #fff; place-items: center; font-size: 16px; }
.select-mode .item .check, .item.checked .check { display: grid; }
.select-mode .item:not(.checked) .check { background: var(--surface); color: transparent; border: 1px solid var(--border-2); }
.item .body { flex: 1; min-width: 0; }
.item .row1, .item .row2 { display: flex; align-items: baseline; gap: 8px; }
.item .from { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.unread .from, .item.unread .subject { font-weight: 600; }
.item.unread .subject { color: var(--brand); }
.item .date { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.item.unread .date { color: var(--brand); font-weight: 600; }
.item .subject { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.item .icons { display: flex; gap: 4px; color: var(--text-2); font-size: 13px; }
.item .icons .bi-flag-fill { color: var(--flag); }
.item .preview { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.item .hover-actions { display: none; position: absolute; right: 8px; top: 6px; background: var(--surface); border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.item:hover .hover-actions { display: flex; }
.item:hover .date { visibility: hidden; }
.hover-actions button { border: 0; background: transparent; width: 28px; height: 26px; cursor: pointer; color: var(--text-2); }
.hover-actions button:hover { color: var(--brand); }
.item.dragging { opacity: .5; }
.list-foot { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.list-empty { padding: 48px 16px; text-align: center; color: var(--text-2); }
.list-empty i { font-size: 36px; display: block; margin-bottom: 8px; color: var(--text-3); }

.reading-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.empty-state { margin: auto; text-align: center; color: var(--text-3); }
.empty-state i { font-size: 56px; }
.msg { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.msg-head { padding: 16px 20px 8px; border-bottom: 1px solid var(--border); }
.msg-subject { font-size: 20px; font-weight: 600; margin: 0 0 12px; word-break: break-word; }
.msg-meta { display: flex; gap: 12px; align-items: flex-start; }
.msg-meta .avatar { width: 40px; height: 40px; font-size: 15px; }
.msg-meta .who { flex: 1; min-width: 0; }
.msg-meta .who b { font-weight: 600; }
.msg-meta .addr { color: var(--text-2); font-size: 13px; }
.msg-meta .to { color: var(--text-2); font-size: 12px; margin-top: 2px; word-break: break-word; }
.msg-actions { display: flex; align-items: center; gap: 2px; }
.msg-actions .icon-btn { color: var(--brand); }
.msg-date { font-size: 12px; color: var(--text-2); text-align: right; margin-top: 4px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 6px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.banner button { border: 0; background: transparent; color: var(--brand); cursor: pointer; padding: 0; font-weight: 600; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.att { display: flex; align-items: center; gap: 8px; width: 220px; padding: 6px 8px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--surface); text-decoration: none; color: var(--text); }
.att:hover { background: var(--hover); }
.att i { font-size: 22px; color: var(--brand); }
.att .n { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.att .s { display: block; font-size: 11px; color: var(--text-2); }
.att .x { margin-left: auto; border: 0; background: transparent; cursor: pointer; color: var(--text-2); }
.msg-body { flex: 1; border: 0; width: 100%; background: #fff; min-height: 200px; }

/* ----- Rédaction */
.compose { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.compose-bar { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.compose-bar .status { margin-left: auto; font-size: 12px; color: var(--text-2); }
.field { display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--border); min-height: 40px; position: relative; }
.field > label { width: 52px; flex: none; color: var(--text-2); }
.field > input { flex: 1; border: 0; outline: none; height: 38px; background: transparent; }
.field .toggles { display: flex; gap: 8px; }
.field .toggles button { border: 0; background: transparent; color: var(--brand); cursor: pointer; }
.chips { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 0; min-height: 38px; cursor: text; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 13px; background: var(--brand-light); color: var(--text); font-size: 13px; max-width: 280px; }
.chip.bad { background: #fdf3f4; color: var(--danger); }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--text-2); padding: 0 4px; }
.chips input { flex: 1; min-width: 140px; border: 0; outline: none; height: 28px; background: transparent; }
.suggest { position: absolute; left: 76px; top: 100%; z-index: 30; min-width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); }
.suggest div { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.suggest div.active, .suggest div:hover { background: var(--selected); }
.suggest .avatar { width: 28px; height: 28px; font-size: 11px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.toolbar button, .toolbar select, .toolbar label { height: 30px; min-width: 30px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; display: inline-grid; place-items: center; color: var(--text); }
.toolbar button:hover, .toolbar label:hover { background: var(--hover); }
.toolbar select { padding: 0 4px; }
.toolbar .tsep { width: 1px; height: 20px; background: var(--border-2); margin: 5px 4px; }
.editor { flex: 1; overflow-y: auto; padding: 16px 20px; outline: none; font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 11pt; line-height: 1.45; background: var(--surface); }
.editor blockquote { border-left: 3px solid var(--border-2); margin: 0 0 0 .4em; padding-left: .8em; color: var(--text-2); }
.editor img { max-width: 100%; }
.compose-atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--border); }
.compose-atts:empty { display: none; }
.drop-hint { display: none; position: absolute; inset: 0; background: rgba(15, 108, 189, .08); border: 2px dashed var(--brand); z-index: 40; place-items: center; font-weight: 600; color: var(--brand); }
.compose.dragging .drop-hint { display: grid; }

/* ----- Contacts */
.contact-card { padding: 24px 28px; overflow-y: auto; }
.contact-card h2 { margin: 12px 0 4px; font-size: 22px; font-weight: 600; }
.contact-card dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; margin-top: 20px; }
.contact-card dt { color: var(--text-2); }
.contact-card dd { margin: 0; word-break: break-word; }
.form-grid { display: grid; gap: 12px; max-width: 480px; margin-top: 16px; }
.form-grid label { font-weight: 600; font-size: 13px; display: grid; gap: 4px; }
.form-grid input, .form-grid textarea, .form-grid select { border: 1px solid var(--border-2); border-radius: 4px; padding: 6px 8px; background: var(--surface); font-weight: 400; }
.form-grid .row { display: flex; gap: 8px; }
.contact-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.contact-row:hover { background: var(--hover); }
.contact-row.selected { background: var(--selected); }
.contact-row .n { font-weight: 600; }
.contact-row .e { color: var(--text-2); font-size: 12px; }
.section-label { padding: 14px 16px 6px; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }

/* ----- Menus, fenêtres, notifications */
.menu-wrap { position: relative; }
.menu { display: none; position: absolute; right: 0; top: 100%; z-index: 50; min-width: 220px; max-height: 60vh; overflow-y: auto; background: var(--surface); color: var(--text);
        border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); padding: 4px 0; }
.menu.open { display: block; }
.commandbar .menu { left: 0; right: auto; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px 14px; text-align: left; cursor: pointer; color: var(--text); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--hover); }
.menu form { margin: 0; }
.menu-head { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ctx { position: fixed; display: block; }
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: 8px; box-shadow: 0 16px 48px rgba(0, 0, 0, .3); padding: 24px; }
.modal h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal .sig { min-height: 110px; border: 1px solid var(--border-2); border-radius: 4px; padding: 8px; outline: none; background: var(--surface); font-family: Calibri, Arial, sans-serif; }
.modal .checks { display: grid; gap: 8px; margin-top: 4px; }
.modal .checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #242424; color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); z-index: 200; display: flex; gap: 14px; align-items: center; }
.toast.error { background: var(--danger); }
.toast button { border: 0; background: transparent; color: #9fd0ff; font-weight: 600; cursor: pointer; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.only-mobile { display: none; }

/* ----- Petits écrans : une colonne à la fois */
@media (max-width: 900px) {
    .only-mobile { display: inline-grid; }
    .brand { min-width: 0; }
    .brand span:last-child { display: none; }
    .rail { display: none; }
    .folders { position: fixed; top: 48px; bottom: 0; left: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 24px rgba(0, 0, 0, .2); }
    .nav-open .folders { transform: none; }
    .list-pane { width: auto; flex: 1; border-right: 0; }
    .reading-pane { display: none; }
    .reading .reading-pane { display: flex; }
    .reading .list-pane { display: none; }
    .cmd span { display: none; }
    .pane-bottom .panes { flex-direction: row; }
    .pane-bottom .list-pane { height: auto; }
}
@media print {
    .topbar, .rail, .folders, .commandbar, .list-pane, .msg-actions, .banner { display: none !important; }
    body.app { overflow: visible; }
}
