/* ======================================================================
   Nouveautés : dossiers, spam, éditeur, aperçus, 2FA, stockage, annonces,
   couleurs au choix et thème sombre (dans l'application uniquement)
   ====================================================================== */

/* ----- Couleurs au choix ----- */
html[data-accent=violet] { --primary: #a98bff; --primary-hover: #b9a0ff; --sidebar-bg: #e4d7ff; }
html[data-accent=bleu] { --primary: #5aa9ff; --primary-hover: #74b7ff; --sidebar-bg: #cfe6ff; }
html[data-accent=vert] { --primary: #3ddc84; --primary-hover: #5ae597; --sidebar-bg: #d7f5df; }
html[data-accent=rose] { --primary: #ff6fb5; --primary-hover: #ff86c1; --sidebar-bg: #ffd9ec; }

/* ----- Barre latérale : dossiers personnels et stockage ----- */
.folders-head { display: flex; align-items: center; justify-content: space-between; margin: 12px 4px 2px 12px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted, var(--muted)); }
.icon-btn.mini { width: 26px; height: 26px; border-radius: 8px; }
.icon-btn.mini .ico { width: 15px; height: 15px; }
.custom-folders { display: grid; gap: 4px; }
.custom-folders a { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--sidebar-muted, var(--muted)); font-weight: 700; border: 2px solid transparent; }
.custom-folders a span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.custom-folders a:hover { background: var(--sidebar-hover); color: var(--text); }
.custom-folders a.active { background: var(--sidebar-active-bg); border-color: #111; box-shadow: 3px 3px 0 #111; color: var(--text); }
.folders-empty { margin: 2px 12px; font-size: 12.5px; color: var(--sidebar-muted, var(--muted)); opacity: .8; }
.quota { margin-top: auto; padding: 4px 8px 0; display: grid; gap: 5px; }
.quota:not([hidden]) + .side-help { margin-top: 0; }
.quota-bar { height: 9px; border: 2px solid #111; border-radius: 9px; background: #fff; overflow: hidden; }
.quota-bar span { display: block; height: 100%; background: var(--ok); transition: width .4s; }
.quota.warn .quota-bar span { background: #f0a500; }
.quota.full .quota-bar span { background: var(--danger); }
.quota small { font-size: 11.5px; font-weight: 600; color: var(--sidebar-muted, var(--muted)); }
.quota.full small { color: var(--danger); }

/* ----- Annonce ----- */
.announce { display: flex; align-items: flex-start; gap: 10px; margin: 0 12px 10px; padding: 10px 8px 10px 12px; border: 2px solid #111; border-radius: var(--radius-sm); box-shadow: 3px 3px 0 #111; background: #e9f9ff; color: #111; font-size: 13.5px; font-weight: 600; }
.announce p { margin: 1px 0 0; flex: 1; line-height: 1.4; white-space: pre-wrap; }
.announce.warning { background: #ffd9cc; }
.announce.success { background: #d9f7e6; }
.announce .icon-btn { width: 28px; height: 28px; color: #111; }
.announce-ico { font-size: 18px; line-height: 1.2; }
.announce.preview { margin: 0; box-shadow: none; }
.ann-form { display: grid; gap: 10px; }
.ann-form select { width: auto; }

/* ----- Lecture : déplacer, aperçus ----- */
.move-select { display: inline-flex; align-items: center; gap: 4px; padding: 0 2px 0 8px; height: 36px; border: 2px solid transparent; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font-weight: 600; }
.move-select:hover { border-color: #111; background: var(--hover); }
.move-select select { border: 0 !important; background-color: transparent !important; box-shadow: none !important; padding: 6px 26px 6px 2px !important; width: auto; font-size: 13.5px; font-weight: 700; background-position: right 4px center; }
.att.is-image { flex-direction: column; align-items: stretch; padding: 6px; max-width: 220px; }
.att.is-image img { width: 100%; height: 130px; object-fit: cover; border-radius: 8px; border: 2px solid #111; background: #fff; }
.att.is-image span { padding: 4px 6px 2px; }
.att-type { display: grid; place-items: center; width: 38px; height: 46px; border-radius: 6px; background: #e5243b; color: #fff; font-weight: 800; font-size: 12px; border: 2px solid #111; flex: none; }
.att.previewable { cursor: zoom-in; }
.viewer-box { width: min(1000px, 100%); height: min(86dvh, 900px); }
.viewer-box .modal-head { gap: 8px; }
.viewer-box h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; background: #2a2833 radial-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0 / 16px 16px; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

/* ----- Éditeur mis en forme ----- */
.editor-bar { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 16px; border-bottom: 2px solid #111; background: var(--surface-2); }
.editor-bar button { min-width: 34px; height: 32px; padding: 0 8px; border: 2px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; font-size: 15px; color: var(--text); }
.editor-bar button:hover { border-color: #111; background: var(--surface); }
.editor-bar .sep { width: 2px; height: 22px; background: var(--line); margin: 0 4px; }
.editor { flex: 1; min-height: 280px; max-height: 50dvh; overflow-y: auto; padding: 18px 22px; outline: none; line-height: 1.6; word-wrap: break-word; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor blockquote { margin: 8px 0; padding: 4px 0 4px 14px; border-left: 4px solid var(--primary); color: var(--muted); }
.editor ul, .editor ol { padding-left: 26px; }
.editor a { color: var(--link); }
.emoji-pop { position: absolute; top: calc(100% + 6px); right: 12px; z-index: 5; display: grid; grid-template-columns: repeat(10, 34px); gap: 2px; padding: 8px; background: var(--surface); border: 2px solid #111; border-radius: var(--radius-sm); box-shadow: 5px 5px 0 #111; }
.emoji-pop button { font-size: 20px; padding: 0; min-width: 34px; }

/* ----- Paramètres : photo, apparence, filtres ----- */
.avatar-edit { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border: 2px solid #111; border-radius: var(--radius); background: var(--surface); box-shadow: 4px 4px 0 #111; }
.avatar-actions { display: grid; gap: 4px; }
.avatar-actions small { font-size: 12.5px; }
.avatar.has-img { overflow: hidden; padding: 0; background: #fff; }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 64px; height: 64px; font-size: 21px; }
.theme-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-choices button { display: grid; gap: 8px; justify-items: center; padding: 10px; border: 2px solid #111; border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; }
.theme-choices button.on { box-shadow: 4px 4px 0 #111; background: var(--selected); color: #111; }
.tc-prev { width: 100%; height: 48px; border-radius: 8px; border: 2px solid #111; }
.tc-prev.light { background: linear-gradient(90deg, #b8f2e6 0 28%, #fff5e1 28%); }
.tc-prev.dark { background: linear-gradient(90deg, #2e2b3a 0 28%, #22202c 28%); }
.tc-prev.auto { background: linear-gradient(110deg, #fff5e1 0 50%, #22202c 50%); }
.accent-choices { display: flex; gap: 12px; flex-wrap: wrap; }
.accent-choices button { width: 52px; height: 52px; border-radius: 50%; border: 2px solid #111; cursor: pointer; background: linear-gradient(135deg, var(--a) 0 55%, var(--b) 55%); }
.accent-choices button.on { box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px #111; }
.folder-admin, .filter-list, .block-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.folder-admin li, .filter-list li, .block-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.folder-admin li span, .filter-list li span, .block-list li span { flex: 1; min-width: 0; }
.link-btn.danger { color: var(--danger); }
.filter-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.filter-form select, .filter-form input:not([type=checkbox]) { width: auto; padding: 7px 34px 7px 10px; font-size: 14px; }
.filter-form input[name=value] { padding-right: 10px; width: 150px; }
.filter-form .check { font-weight: 600; font-size: 13px; flex-basis: 100%; }

/* ----- Double authentification ----- */
.otp-input { font-family: var(--font-mono); font-size: 28px !important; letter-spacing: .25em; text-align: center; padding: 12px !important; }
.otp-input.small { font-size: 20px !important; letter-spacing: .18em; }
.twofa-setup { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr { width: 170px; height: 170px; border: 2px solid #111; border-radius: 12px; box-shadow: 4px 4px 0 #111; background: #fff; padding: 6px; }
.twofa-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; flex: 1; min-width: 220px; }

/* ======================================================================
   Thème sombre
   ====================================================================== */
html[data-theme=dark] {
  color-scheme: dark;
  --bg: #22202c; --surface: #2e2b3a; --surface-2: #37344a; --input-bg: #1d1b26;
  --text: #f6efe0; --muted: #b8afa0; --line: #46425a; --hover: #3a3650; --selected: #4c4470;
  --link: #8fb3ff; --sidebar-bg: #2b2838; --sidebar-active-bg: #3d3955; --sidebar-muted: #d0c7b6; --sidebar-hover: #37344a;
  --list-bg: #28253200; --reader-bg: #22202c; --me-bg: #2e2b3a; --label: #f6efe0; --preview-bg: #37344a;
  --backdrop: rgba(0, 0, 0, .55); --illu-fg: #111;
}
html[data-theme=dark][data-accent=orange] { --sidebar-bg: #23353a; }
html[data-theme=dark][data-accent=violet] { --sidebar-bg: #2f2846; }
html[data-theme=dark][data-accent=bleu] { --sidebar-bg: #22304a; }
html[data-theme=dark][data-accent=vert] { --sidebar-bg: #213a2d; }
html[data-theme=dark][data-accent=rose] { --sidebar-bg: #3d2535; }
html[data-theme=dark] body { background: var(--bg) radial-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px) 0 0 / 18px 18px; }
html[data-theme=dark] .icon-btn, html[data-theme=dark] .compose-fields .row, html[data-theme=dark] .adm-table th { color: var(--text); }
html[data-theme=dark] .icon-btn:hover { color: #111; }
html[data-theme=dark] .modal-head, html[data-theme=dark] .modal-head .icon-btn { color: #111; }
.editor .sig { color: var(--muted); }
html[data-theme=dark] .modal-foot, html[data-theme=dark] .stabs { background: #2a2735; }
html[data-theme=dark] .stab.active, html[data-theme=dark] .danger-zone { background: var(--surface); }
html[data-theme=dark] .settings-body { background: var(--bg); }
html[data-theme=dark] .msg.selected .msg-preview, html[data-theme=dark] .msg.selected time { color: #e2d8f5; }
html[data-theme=dark] .adm-warn, html[data-theme=dark] .bubble.from-staff, html[data-theme=dark] .bubble.note, html[data-theme=dark] .reset-link,
html[data-theme=dark] .code-display, html[data-theme=dark] .atab.active, html[data-theme=dark] .seg button.on, html[data-theme=dark] .t-row.selected,
html[data-theme=dark] .u-row.selected, html[data-theme=dark] .by-support { color: #111; }
html[data-theme=dark] .t-row.selected .t-from, html[data-theme=dark] .t-row.selected time, html[data-theme=dark] .u-row.selected .u-main span,
html[data-theme=dark] .bubble.from-staff time, html[data-theme=dark] .bubble.note time { color: #3b362b; }
html[data-theme=dark] .t-row.selected, html[data-theme=dark] .u-row.selected { background: #ffe066; }
html[data-theme=dark] .adm-table tr.bad td { background: #3d2a30; }
html[data-theme=dark] .t-account, html[data-theme=dark] .facts div { background: var(--surface-2); }
html[data-theme=dark] .bubble.from-user { background: var(--surface-2); }
html[data-theme=dark] .quota-bar { background: #1d1b26; }
html[data-theme=dark] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6efe0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
html[data-theme=dark] .move-select select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6efe0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") !important; }
html[data-theme=dark] .strength { background: #1d1b26; }
html[data-theme=dark] .switch span::before { background: var(--text); }
html[data-theme=dark] .toast { background: #f6efe0; color: #111; }

@media (max-width: 900px) {
  .emoji-pop { grid-template-columns: repeat(7, 34px); right: 6px; }
  .viewer-box { height: 100dvh; }
  .filter-form input[name=value] { width: 100%; }
}
