/* ==========================================================================
   FLEXI-MAIL — nouveau style (apparence uniquement : aucune fonction modifiée)
   Pour revenir à l'ancien aspect : retirer les lignes "flexi-theme" des pages
   (ou restaurer /root/backups/mail.flexi-cargo.fr-*-avant-nouveau-style).
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Exo+2:ital,wght@1,700;1,800&display=swap');

/* ---- palette : on redéfinit les variables existantes, tout le reste suit ---- */
:root{
  --navy:#030814; --navy-light:#13265a;
  --orange-start:#ff7a00; --orange-end:#ffb020; --orange-deep:#e8590c;
  --bg-warm:#eaf0fb; --bg-white:#ffffff; --text-dark:#0a1738; --text-muted:#5b6c99; --border-light:#d9e2f5;
  --font-sans:'Manrope','Segoe UI',system-ui,sans-serif; --font-serif:'Exo 2','Manrope',system-ui,sans-serif;
  --fx-surface2:#f1f5fd; --fx-unread:#e3ebff; --fx-sel:#dfe9ff; --fx-blue:#1f6bff; --fx-blue2:#123fb8;
  --fx-shadow:0 1px 2px rgba(10,23,56,.06),0 10px 28px rgba(18,63,184,.10);
  --fx-scrim:rgba(3,8,20,.55);
}
@media (prefers-color-scheme:dark){:root:not([data-fx="light"]){
  --bg-warm:#050a18; --bg-white:#0c1530; --text-dark:#eef3ff; --text-muted:#8fa3d4; --border-light:#1b2c5a;
  --fx-surface2:#111d40; --fx-unread:#10224f; --fx-sel:#15306e; --fx-shadow:0 1px 2px rgba(0,0,0,.4),0 12px 32px rgba(0,0,0,.35);
  --fx-scrim:rgba(2,6,20,.7); color-scheme:dark}}
:root[data-fx="dark"]{
  --bg-warm:#050a18; --bg-white:#0c1530; --text-dark:#eef3ff; --text-muted:#8fa3d4; --border-light:#1b2c5a;
  --fx-surface2:#111d40; --fx-unread:#10224f; --fx-sel:#15306e; --fx-shadow:0 1px 2px rgba(0,0,0,.4),0 12px 32px rgba(0,0,0,.35);
  --fx-scrim:rgba(2,6,20,.7); color-scheme:dark}

body{font-family:var(--font-sans);background:var(--bg-warm);color:var(--text-dark)}
:focus-visible{outline:2px solid var(--orange-end);outline-offset:2px}
button,input,select,textarea{font-family:inherit}
input[type=text],input[type=email],input[type=password],input[type=search],select,textarea{
  background:var(--fx-surface2);color:var(--text-dark);border:1px solid var(--border-light);border-radius:13px;padding:11px 14px;transition:border-color .15s,box-shadow .15s}
input[type=text]:focus,input[type=email]:focus,input[type=password]:focus,input[type=search]:focus,select:focus,textarea:focus{outline:0;border-color:var(--fx-blue);box-shadow:0 0 0 3px rgba(31,107,255,.2)}
input::placeholder{color:var(--text-muted)}
input[type=checkbox]{accent-color:var(--fx-blue)}

/* ---- boutons ---- */
.btn-orange{background:linear-gradient(135deg,var(--orange-start),var(--orange-end))!important;color:#1a1200!important;border:0;border-radius:14px;font-weight:800;padding:11px 20px;box-shadow:0 6px 18px rgba(255,122,0,.4);transition:transform .12s,box-shadow .15s}
.btn-orange:hover{opacity:1;transform:translateY(-2px);box-shadow:0 10px 26px rgba(255,122,0,.55)}
.btn-navy{border-radius:13px;font-weight:700;transition:transform .12s,border-color .15s}
.reading-toolbar .btn-navy,.bulk-toolbar-actions .btn-navy,.compose-footer label.btn-navy{background:var(--bg-white)!important;color:var(--text-dark)!important;border:1px solid var(--border-light)!important}
.reading-toolbar .btn-navy:hover,.bulk-toolbar-actions .btn-navy:hover,.compose-footer label.btn-navy:hover{border-color:var(--fx-blue)!important;transform:translateY(-1px)}
#replyBtn{background:linear-gradient(135deg,var(--orange-start),var(--orange-end))!important;color:#1a1200!important;border:0!important;font-weight:800;box-shadow:0 6px 18px rgba(255,122,0,.4)}
#newMessageBtn{display:flex;align-items:center;justify-content:center;gap:10px;height:50px;border-radius:15px;font-size:16px;font-style:italic;font-family:'Exo 2',var(--font-sans);box-shadow:0 8px 22px rgba(255,122,0,.45)}
.icon-btn{border-radius:13px!important}

/* ---- menu latéral ---- */
.sidebar{
  background:radial-gradient(120% 45% at 0% 100%,rgba(255,122,0,.26),transparent 62%),radial-gradient(120% 40% at 100% 0%,rgba(31,107,255,.38),transparent 62%),var(--navy);
  border-right:1px solid rgba(255,255,255,.07);padding:18px 14px;gap:2px}
.sidebar .brand{padding:2px 6px 10px;margin-bottom:6px;flex-wrap:wrap;row-gap:6px}
/* logo Flexi-Cargo en haut à gauche, en grand */
.sidebar .brand img{order:-1;flex:0 0 100%;width:100%;max-width:224px;height:auto;border-radius:14px;mix-blend-mode:screen;filter:drop-shadow(0 0 14px rgba(31,107,255,.4))}
.sidebar .brand-name{font-family:'Exo 2',var(--font-sans);font-style:italic;font-weight:800;font-size:1.3rem;letter-spacing:-.01em}
.sidebar .brand-sub{letter-spacing:.2em;color:#6f86c8;opacity:1;font-weight:800}
.notif-bell-btn{border-radius:11px;color:#9fb0e0}
.notif-bell-btn:hover{background:rgba(255,255,255,.1)}
.mailbox-switcher{background:rgba(255,255,255,.08)!important;border:1px solid rgba(255,255,255,.14)!important;border-radius:13px;padding:11px 14px;font-weight:700;color:#fff!important}
.sidebar nav ul{margin:10px 0}
.sidebar nav li a,.custom-folder-list a,.sidebar .tag-item{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:12px;color:#b4c3ec;font-weight:600;position:relative;transition:background .15s,color .15s,transform .15s}
.sidebar nav li a{justify-content:flex-start}
.sidebar nav li a:hover,.custom-folder-list a:hover,.sidebar .tag-item:hover{background:rgba(255,255,255,.09);color:#fff;transform:translateX(3px)}
.sidebar nav li a.active,.custom-folder-list a.active,.sidebar .tag-item.active{background:linear-gradient(90deg,rgba(31,107,255,.6),rgba(31,107,255,.12));color:#fff;font-weight:800;box-shadow:inset 0 0 0 1px rgba(127,176,255,.35)}
.sidebar nav li a.active::before,.custom-folder-list a.active::before{content:"";position:absolute;left:-14px;top:8px;bottom:8px;width:4px;border-radius:0 4px 4px 0;background:linear-gradient(var(--orange-end),var(--orange-start));box-shadow:0 0 12px var(--orange-start)}
.sidebar nav li a.active .fx-ic,.custom-folder-list a.active .fx-ic{color:var(--orange-end)}
.sidebar nav li a .count{margin-left:auto;background:linear-gradient(135deg,var(--orange-start),var(--orange-end));color:#fff;font-weight:800;font-size:.75rem;padding:1px 9px;border-radius:99px}
.custom-folder-list .count{margin-left:auto;background:linear-gradient(135deg,var(--orange-start),var(--orange-end));color:#fff;border-radius:99px;padding:1px 9px;font-size:.75rem;font-weight:800}
.fx-ic{width:20px;height:20px;flex:none;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.sidebar .tags-section h4{font-size:11px;letter-spacing:.14em;color:#6f86c8;opacity:1;font-weight:800;padding:8px 12px 4px;margin:6px 0 2px}
.sidebar .tags-section h4 button{color:#9fb0e0!important;font-size:1.1rem!important}
.sidebar .tag-dot{width:11px;height:11px;margin:0 4.5px}
.sidebar nav li a.drop-target,.custom-folder-list a.drop-target{background:rgba(255,122,0,.35);outline:2px dashed #fff;outline-offset:-3px}
.sidebar .profile-footer{border-top:1px solid rgba(255,255,255,.1);padding-top:14px}
.avatar-circle{background:linear-gradient(135deg,var(--fx-blue),var(--fx-blue2));font-weight:800}
.profile-footer a{color:#9fb0e0!important}

/* ---- liste des messages ---- */
.message-list-col{background:var(--bg-warm);border-right:1px solid var(--border-light)}
.message-list-header{padding:16px 16px 8px;position:relative}
.message-list-header h1{font-family:'Exo 2',var(--font-sans);font-style:italic;font-weight:800;font-size:1.55rem;letter-spacing:-.01em;margin:0 0 12px;padding-right:52px}
.message-list-header input[type=search]{height:44px;border-radius:14px;background:var(--bg-white)}
.bulk-toolbar{background:transparent;border:0;padding:6px 18px 8px;color:var(--text-muted);font-weight:700}
.bulk-toolbar-actions .btn-navy{padding:6px 12px;border-radius:10px}
.bulk-toolbar .btn-text{color:var(--text-muted);font-weight:700}
.select-all-banner{background:var(--fx-unread);border:0;border-radius:12px;margin:0 10px 8px;color:var(--text-dark)}
.select-all-banner a{color:var(--fx-blue)}
.message-list{padding:0 10px 16px;display:flex;flex-direction:column;gap:6px}
.message-row{align-items:center;gap:12px;padding:12px 14px;border:1px solid transparent;border-radius:16px;background:var(--bg-white);position:relative;transition:transform .12s,border-color .15s,box-shadow .15s}
.message-row:hover{border-color:var(--fx-blue);box-shadow:var(--fx-shadow)}
.message-row.unread{background:var(--fx-unread)}
.message-row.unread::before{content:"";position:absolute;left:-1px;top:14px;bottom:14px;width:4px;border-radius:0 4px 4px 0;background:linear-gradient(var(--orange-end),var(--orange-start))}
.message-row.active{background:var(--fx-sel);border:1px solid var(--fx-blue);border-left:1px solid var(--fx-blue)}
.message-row .row-select{margin:0}
.fx-av{width:42px;height:42px;border-radius:14px;display:grid;place-items:center;color:#fff;font-weight:800;font-size:14px;flex:none}
.message-row .top-line{font-size:.9rem;margin-bottom:2px;gap:8px}
.message-row .top-line span:first-child{color:var(--text-dark);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.message-row .top-line span:last-child{color:var(--text-muted);font-size:.78rem;white-space:nowrap}
.message-row.unread .top-line span:first-child{font-weight:800}
.message-row .subject{color:var(--text-dark);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.message-row.unread .subject{font-weight:800}
.unread-dot{background:var(--orange-start);box-shadow:0 0 8px var(--orange-start)}
/* Lu / non lu bien visibles : non lu = carte claire en gras + « Nouveau » ; lu = carte estompée + « ✓ Lu » */
.message-row.unread{border-color:color-mix(in srgb,var(--fx-blue) 35%,transparent)}
.message-row.read{background:var(--fx-surface2)}
.message-row.read .top-line span:first-child,.message-row.read .subject{color:var(--text-muted);font-weight:500}
.message-row.read .fx-av{opacity:.5;filter:saturate(.4)}
.message-row.read:hover .fx-av,.message-row.read.active .fx-av{opacity:1;filter:none}
.message-row .top-line span:last-child{display:inline-flex;align-items:center;gap:6px}
.read-mark{font-size:.7rem;font-weight:700;color:var(--text-muted);border:1px solid var(--border-light);border-radius:99px;padding:0 7px;line-height:1.5}
.new-mark{font-size:.7rem;font-weight:800;color:#fff;background:linear-gradient(90deg,var(--orange-start),var(--orange-end));border-radius:99px;padding:0 7px;line-height:1.5}
.tag-chip{border-radius:99px;font-weight:800;padding:2px 10px}

/* ---- volet de lecture ---- */
.reading-pane{background:var(--bg-warm)}
.reading-toolbar{padding:14px 22px;gap:8px;border-bottom:1px solid var(--border-light);background:color-mix(in srgb,var(--bg-white) 80%,transparent);backdrop-filter:blur(10px)}
.reading-toolbar .icon-btn{width:42px;height:42px;background:var(--bg-white);border:1px solid var(--border-light);color:var(--text-dark);transition:border-color .15s,box-shadow .15s}
.reading-toolbar .icon-btn:hover{background:var(--bg-white);border-color:var(--fx-blue);box-shadow:0 0 0 3px rgba(31,107,255,.15)}
.reading-toolbar .icon-btn#deleteBtn:hover{border-color:#d6334a;color:#d6334a}
.reading-toolbar .icon-btn#starBtn.starred{color:var(--orange-end);border-color:var(--orange-end)}
.reading-toolbar .btn-navy{height:42px}
.reading-body{margin:20px 26px 26px;padding:26px 28px;background:var(--bg-white);border:1px solid var(--border-light);border-radius:22px;box-shadow:var(--fx-shadow)}
.reading-body .subject-serif{font-family:'Exo 2',var(--font-sans);font-style:italic;font-weight:800;font-size:1.75rem;line-height:1.2;letter-spacing:-.01em;margin:0 0 16px}
.reading-body .sender-line{padding-bottom:16px;border-bottom:1px solid var(--border-light)}
.reading-body .avatar-circle{width:50px;height:50px;border-radius:16px;font-size:1.1rem}
.reading-body .sender-name{font-size:1.05rem;font-weight:800}
.mail-body-frame{border-radius:14px;background:#fff}
.attachment-chip{background:var(--fx-surface2);border:1px solid var(--border-light);border-radius:14px;padding:10px 14px;color:var(--text-dark);transition:border-color .15s}
.attachment-chip:hover{border-color:var(--fx-blue)}
.reply-box{background:var(--fx-surface2);border-radius:16px}
.col-resizer::after{background:var(--border-light)}
.col-resizer:hover::after,.col-resizer.dragging::after{background:var(--orange-start)}
.tag-picker{background:var(--bg-white);border:1px solid var(--border-light);border-radius:16px;box-shadow:0 24px 60px rgba(0,0,0,.45);padding:8px;color:var(--text-dark)}
.tag-picker-item{border-radius:10px;padding:8px 10px;font-weight:600}
.tag-picker-item:hover{background:var(--fx-surface2)}

/* ---- rédaction ---- */
.compose-overlay{background:var(--fx-scrim);backdrop-filter:blur(4px)}
.compose-modal{background:var(--bg-white);color:var(--text-dark);border:1px solid var(--border-light);border-radius:24px;box-shadow:0 30px 80px rgba(0,0,0,.5);width:700px}
.compose-header{padding:18px 22px;border-bottom:1px solid var(--border-light)}
.compose-header h3{font-family:'Exo 2',var(--font-sans);font-style:italic;font-weight:800;font-size:1.3rem}
.compose-header .icon-btn{width:42px;height:42px;background:var(--fx-surface2);color:var(--text-dark);border:1px solid var(--border-light)}
.compose-fields{padding:6px 22px;border-bottom:1px solid var(--border-light)}
.compose-field{padding:4px 0}
.compose-field label{width:54px;font-weight:800;font-size:.8rem}
.compose-field input{background:transparent!important;border:0!important;box-shadow:none!important;font-size:.98rem;font-weight:600;padding:10px 0!important;color:var(--text-dark)}
.cc-toggle{color:var(--fx-blue);font-weight:800}
.compose-format-toolbar{padding:10px 22px;background:var(--fx-surface2)}
.compose-format-toolbar select{background:var(--bg-white)!important;color:var(--text-dark);border-radius:10px;padding:6px 8px;height:34px;width:auto}
.compose-format-toolbar button{background:var(--bg-white)!important;color:var(--text-dark);border:1px solid var(--border-light);border-radius:10px;width:34px;height:34px;font-weight:800}
.compose-format-toolbar button:hover{border-color:var(--fx-blue)}
.toolbar-sep{background:var(--border-light)}
.compose-body{padding:18px 22px;font-size:1rem}
.compose-footer{padding:14px 22px;border-top:1px solid var(--border-light)}
.contact-suggestions{background:var(--bg-white);border:1px solid var(--border-light);border-radius:14px;box-shadow:0 20px 50px rgba(0,0,0,.4)}
.contact-suggestion-item:hover{background:var(--fx-surface2)}
.quoted-original{border-left:3px solid var(--orange-start)}

/* ---- fenêtres de lecture flottantes ---- */
.mail-window{background:var(--bg-white);color:var(--text-dark);border-radius:20px;box-shadow:0 22px 60px rgba(0,0,0,.45),0 0 0 1px var(--border-light)}
.mw-titlebar{background:linear-gradient(135deg,#0a1a45,#030814)!important}
.mail-window:not(.focused) .mw-titlebar{background:#2a3a6e!important}
.mw-title{font-family:'Exo 2',var(--font-sans);font-style:italic;font-weight:800}
.mw-toolbar{background:var(--fx-surface2);border-bottom:1px solid var(--border-light)}
.mw-toolbar button{background:var(--bg-white);color:var(--text-dark);border:1px solid var(--border-light);border-radius:10px;font-weight:700}
.mw-toolbar button:hover{background:var(--bg-white);border-color:var(--fx-blue)}
.mw-subject{font-family:'Exo 2',var(--font-sans);font-style:italic;font-weight:800}
.mw-meta,.mw-attach{border-color:var(--border-light)}
.mail-toast{background:linear-gradient(135deg,var(--fx-blue),var(--fx-blue2));border-radius:13px;font-weight:800}

/* ---- connexion, réglages, administration ---- */
.login-page{background:radial-gradient(60% 60% at 20% 10%,rgba(31,107,255,.4),transparent),radial-gradient(60% 60% at 90% 90%,rgba(255,122,0,.3),transparent),#030814}
.login-card{background:var(--bg-white);color:var(--text-dark);border:1px solid var(--border-light);border-radius:26px;box-shadow:0 30px 90px rgba(0,0,0,.6),0 0 60px rgba(31,107,255,.25)}
.login-card img{height:auto;width:100%;max-width:230px;border-radius:14px;background:#030814}
.login-card h1{font-family:'Exo 2',var(--font-sans);font-style:italic;font-weight:800}
.card,.modal-box{background:var(--bg-white)!important;color:var(--text-dark);border:1px solid var(--border-light);border-radius:22px!important;box-shadow:var(--fx-shadow)!important}
.settings-top a,.admin-top a{color:var(--fx-blue)}
.sig-toolbar button,.sig-import-btn{background:var(--fx-surface2)!important;color:var(--text-dark);border-radius:10px!important}
.sig-editor{background:var(--fx-surface2);color:var(--text-dark);border-radius:14px!important}
.field textarea{background:var(--fx-surface2);color:var(--text-dark);border-radius:13px!important}
.badge-role{background:var(--fx-surface2)!important;color:var(--text-dark)}
.badge-role.admin{background:var(--fx-unread)!important;color:var(--fx-blue)!important}
.row-actions button,.mailbox-line button,.mailbox-add{color:var(--fx-blue)!important}
.row-actions button.danger,.mailbox-line button.danger{color:#d6334a!important}
table{color:var(--text-dark)}
.modal-overlay{background:var(--fx-scrim)!important;backdrop-filter:blur(4px)}
.status-ok{background:#dcf6e8;color:#0e9f55}.status-err{background:#fde4e8;color:#d6334a}

/* ---- bouton clair / sombre ---- */
.fx-theme-btn{position:absolute;top:16px;right:16px;width:42px;height:42px;border-radius:13px;border:1px solid var(--border-light);background:var(--bg-white);display:grid;place-items:center;cursor:pointer;padding:0;color:var(--text-dark);transition:border-color .15s}
.fx-theme-btn:hover{border-color:var(--fx-blue)}
.fx-theme-btn svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* ---- téléphone / tablette ---- */
@media (max-width:1023px){
  .message-list-header{padding-left:16px}
  .message-list-header .mobile-menu-btn{border:1px solid var(--border-light)!important;background:var(--bg-white)!important;border-radius:13px!important;width:42px;height:42px;color:var(--text-dark)}
}
@media (max-width:640px){
  .bottom-tab-bar{background:var(--bg-white);border-top:1px solid var(--border-light);height:64px;padding-bottom:env(safe-area-inset-bottom,0px)}
  .bottom-tab-bar button{color:var(--text-muted);font-weight:800}
  .bottom-tab-bar button.active{color:var(--fx-blue)}
  .bottom-tab-bar .tab-new{color:#fff;background:linear-gradient(135deg,var(--orange-start),var(--orange-end));border-radius:16px;margin:-18px 6px 6px;box-shadow:0 8px 20px rgba(255,122,0,.5);flex:1.1}
  .app-shell{height:calc(100vh - 64px);padding-bottom:64px}
  .reading-body{margin:12px;padding:18px}
  .reading-toolbar .icon-btn{width:40px;height:40px}
  .compose-modal{border-radius:0;border:0}
}
@media (min-width:1024px){.fx-theme-btn{right:16px}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
