/* =========================================================
   webmail_app.css
   ---------------------------------------------------------
   ✅ Fix principal :
   - vFrame remplit 100% de wm-view-body
   - wm-view-body prend toute la hauteur dispo (flex:1)
   - min-height:0 sur les bons parents (grid + flex)
   ---------------------------------------------------------
   + Inclus:
   - Multi-suppression (checkbox + bouton)
   - Badge non-lu inline après le nom de dossier si > 0
   ========================================================= */

   :root{
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: rgba(15,23,42,.10);
  
    --primary: #2563eb;
    --danger: #ef4444;
  
    --r-xl: 18px;
    --shadow-soft: 0 10px 24px rgba(2,6,23,.06);
  }
  
  *{ box-sizing:border-box; }
  html,body{ height:100%; }
  body{
    margin:0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
    background: radial-gradient(1200px 600px at 20% 0%, #e8efff 0%, transparent 55%),
                radial-gradient(1000px 600px at 80% 0%, #e9fff1 0%, transparent 55%),
                var(--bg);
    color:var(--text);
  }
  
  /* App shell */
  .wm-app{
    margin-top: 90px;
    height:83vh;
    display:flex;
    flex-direction:column;
  
    /* ✅ CRUCIAL : permet aux enfants flex de “shrink” */
    min-height:0;
  }
  
  .wm-topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding: 14px 18px;
    margin: 12px 12px 0;
    background: rgba(255,255,255,.75);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--r-xl);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-soft);
  }
  
  .wm-brand{ display:flex; gap:12px; align-items:center; }
  .wm-logo{
    width:42px;height:42px;
    display:grid;place-items:center;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(37,99,235,.15), rgba(16,185,129,.12));
    border: 1px solid rgba(37,99,235,.15);
  }
  .wm-title-main{ font-weight:700; letter-spacing:-.2px; }
  .wm-title-sub{ font-size:12px; color:var(--muted); margin-top:2px; }
  
  .wm-actions{ display:flex; gap:10px; align-items:center; }
  
  .wm-btn{
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 10px 12px;
    border-radius: 12px;
    cursor:pointer;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
    user-select:none;
  }
  .wm-btn:hover{ transform: translateY(-1px); box-shadow: 0 10px 18px rgba(2,6,23,.06); }
  .wm-btn:active{ transform: translateY(0px) scale(.99); }
  
  .wm-btn-ghost{ background: rgba(255,255,255,.55); }
  .wm-btn-primary{
    border-color: rgba(37,99,235,.25);
    background: linear-gradient(135deg, rgba(37,99,235,1), rgba(29,78,216,1));
    color: white;
    box-shadow: 0 14px 24px rgba(37,99,235,.20);
  }
  .wm-btn-danger{
    border-color: rgba(239,68,68,.25);
    background: rgba(239,68,68,.10);
    color: #b91c1c;
  }
  
  .wm-search{
    display:flex; align-items:center; gap:8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.65);
    border-radius: 14px;
  }
  .wm-search input{ border:0; outline:0; background:transparent; width:260px; font-size:14px; }
  
  /* =========================================================
     Main grid (3 colonnes)
     ✅ CRUCIAL : min-height:0 pour que la colonne droite puisse “stretch”
     ========================================================= */
  .wm-main{
    flex:1;
    display:grid;
    grid-template-columns: 240px 420px 1fr;
    gap: 12px;
    padding: 12px;
  
    /* ✅ CRUCIAL : sinon les enfants overflow/100% hauteur cassent */
    min-height:0;
  }
  
  .wm-sidebar, .wm-list, .wm-view{
    background: rgba(255,255,255,.78);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--r-xl);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    overflow:hidden;
  
    /* ✅ CRUCIAL */
    min-height:0;
  }
  
  /* Sidebar */
  .wm-sidebar{ display:flex; flex-direction:column; }
  .wm-sidebar-head{ padding: 14px 14px 10px; }
  .wm-sidebar-title{ font-weight: 700; }
  
  .wm-folders{
    padding: 6px;
    display:flex;
    flex-direction:column;
    gap: 4px;
    overflow:auto;
  
    /* ✅ CRUCIAL */
    min-height:0;
  }
  
  .wm-folder{
    display:flex; justify-content:space-between; align-items:center;
    padding: 10px 10px;
    border-radius: 14px;
    cursor:pointer;
    transition: background .12s ease, transform .12s ease;
  }
  .wm-folder:hover{ background: rgba(2,6,23,.04); }
  .wm-folder.is-active{
    background: rgba(37,99,235,.10);
    border: 1px solid rgba(37,99,235,.18);
  }
  
  .wm-count{
    font-size: 12px;
    color: var(--muted);
    background: rgba(2,6,23,.04);
    padding: 3px 8px;
    border-radius: 999px;
  }
  
  /* ✅ Non-lus inline après le texte (ex: Boîte de réception (3)) */
  .wm-unseen-inline{
    font-size: 12px;
    color: rgba(37,99,235,.95);
    font-weight: 800;
    margin-left: 6px;
  }
  
  .wm-sidebar-foot{ padding: 12px 14px; border-top: 1px solid var(--line); }
  
  /* List */
  .wm-list{
    display:flex;
    flex-direction:column;
  
    /* ✅ CRUCIAL */
    min-height:0;
  }
  
  .wm-list-head{
    padding: 14px;
    display:flex; align-items:center; justify-content:space-between;
    border-bottom: 1px solid var(--line);
    gap: 10px;
  }
  .wm-list-title{ font-weight:700; }
  
  .wm-list-right{
    display:flex;
    align-items:center;
    gap: 10px;
  }
  .wm-list-total{ font-size:12px; color: var(--muted); }
  
  .wm-selected-pill{
    display:inline-block;
    margin-left: 6px;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(239,68,68,.12);
    color: #b91c1c;
    border: 1px solid rgba(239,68,68,.20);
  }
  
  /* ✅ La liste doit “prendre la hauteur restante” */
  .wm-list-scroll{
    overflow:auto;
    padding: 10px;
    flex:1;
    min-height:0; /* ✅ CRUCIAL */
  }
  
  .wm-month{
    margin: 10px 0;
    border: 1px solid rgba(15,23,42,.08);
    background: rgba(255,255,255,.66);
    border-radius: 16px;
    overflow:hidden;
  }
  .wm-month-head{
    display:flex; align-items:center; justify-content:space-between;
    padding: 10px 12px;
    cursor:pointer;
    user-select:none;
    transition: background .12s ease;
  }
  .wm-month-head:hover{ background: rgba(2,6,23,.03); }
  .wm-month-title{ font-weight: 750; }
  .wm-month-right{ display:flex; align-items:center; gap: 8px; }
  .wm-month-count{
    font-size: 12px;
    color: var(--muted);
    background: rgba(2,6,23,.04);
    padding: 3px 8px;
    border-radius: 999px;
  }
  .wm-month-chevron{ color: var(--muted); transition: transform .12s ease; }
  .wm-month.is-open .wm-month-chevron{ transform: rotate(90deg); }
  .wm-month-body{ display:none; padding: 8px 10px 10px; }
  .wm-month.is-open .wm-month-body{ display:block; }
  
  .wm-item{
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 16px;
    padding: 10px 10px;
    margin: 8px 0;
    cursor:pointer;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
    position:relative;
    background: rgba(255,255,255,.75);
  }
  .wm-item:hover{ transform: translateY(-1px); box-shadow: 0 14px 24px rgba(2,6,23,.06); }
  
  .wm-item.is-unread{
    background: rgba(37,99,235,.10);
    border-color: rgba(37,99,235,.18);
  }
  
  /* ✅ Multi-selection */
  .wm-item.is-selected{
    outline: 2px solid rgba(239,68,68,.28);
    box-shadow: 0 18px 30px rgba(239,68,68,.08);
  }
  .wm-selectbox{
    position:absolute;
    top: 10px;
    left: 10px;
    width: 18px;
    height: 18px;
    cursor:pointer;
    accent-color: var(--danger);
  }
  .wm-item-content{ padding-left: 26px; }
  
  .wm-item-top{ display:flex; justify-content:space-between; gap:10px; }
  .wm-item-from{ font-weight:650; }
  .wm-item-date{ font-size:12px; color: var(--muted); }
  .wm-item-subject{ margin-top:6px; color: rgba(15,23,42,.92); }
  .wm-item-snippet{ margin-top:4px; font-size:13px; color: var(--muted); }
  
  .wm-list-foot{
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    display:flex;
    align-items:center;
    justify-content:flex-end;
  }
  
  /* =========================================================
     Viewer (aperçu droite)
     ✅ C’EST ICI que la frame redevient “parfaite”
     ========================================================= */
  .wm-view{
    display:flex;
    flex-direction:column;
  
    /* ✅ CRUCIAL */
    min-height:0;
  }
  
  .wm-view-head{
    padding: 14px;
    border-bottom: 1px solid var(--line);
    display:flex;
    justify-content:space-between;
    gap: 12px;
  
    flex: 0 0 auto;
  }
  
  .wm-view-subject{ font-weight: 750; font-size: 16px; }
  .wm-view-from, .wm-view-date{ font-size: 12px; color: var(--muted); margin-top: 4px; }
  
  .wm-view-actions{ display:flex; gap: 8px; align-items:center; }
  .wm-view-actions select{
    border:1px solid var(--line);
    background: rgba(255,255,255,.6);
    border-radius: 12px;
    padding: 9px 10px;
    outline:0;
  }
  
  /* ✅ wm-view-body prend TOUTE la place restante sous le head */
  .wm-view-body{
    flex: 1 1 auto;
    padding: 10px;
  
    /* ✅ CRUCIAL : permet au child height:100% de fonctionner */
    min-height:0;
  }
  
  /* ✅ iframe = 100% de wm-view-body */
  #vFrame{
    width:100%;
    height:100%;
    border:0;
    background: white;
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px rgba(15,23,42,.06);
  }
  
  /* Modal */
  .wm-modal{
    position:fixed; inset:0;
    display:none;
    align-items:center;
    justify-content:center;
    background: rgba(2,6,23,.30);
    backdrop-filter: blur(6px);
    padding: 18px;
  }
  .wm-modal.is-open{ display:flex; }
  .wm-modal-card{
    width:min(720px, 100%);
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(255,255,255,.8);
    border-radius: var(--r-xl);
    box-shadow: 0 12px 40px rgba(2,6,23,.08);
  }
  .wm-modal-head{
    padding: 14px;
    border-bottom: 1px solid var(--line);
    display:flex;
    align-items:center;
    justify-content:space-between;
  }
  .wm-modal-title{ font-weight: 750; }
  .wm-modal-body{ padding: 14px; display:grid; gap: 12px; }
  .wm-field{ display:grid; gap: 6px; font-size: 13px; color: var(--muted); }
  .wm-field input, .wm-field textarea{
    font: inherit;
    color: var(--text);
    border:1px solid var(--line);
    background: rgba(255,255,255,.65);
    border-radius: 14px;
    padding: 10px 12px;
    outline:0;
  }
  .wm-field textarea{ resize: vertical; min-height: 180px; }
  .wm-modal-foot{
    padding: 14px;
    border-top: 1px solid var(--line);
    display:flex;
    justify-content:flex-end;
    gap: 8px;
  }
  
  /* Toast */
  .wm-toast{
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    background: rgba(15,23,42,.92);
    color: white;
    padding: 10px 12px;
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    opacity: 0;
    pointer-events:none;
    transition: opacity .15s ease, transform .15s ease;
  }
  .wm-toast.is-show{ opacity:1; transform: translateX(-50%) translateY(-2px); }
  .wm-muted{ color: var(--muted); font-size: 12px; }
  
  .wm-infinite-sentinel{ height: 1px; }
  
  /* Drag & Drop */
  .wm-item.is-dragging{ opacity: .65; transform: scale(.995); }
  .wm-folder.is-drop-mode{ outline: 1px dashed rgba(37,99,235,.25); outline-offset: 2px; }
  .wm-folder.is-drop-target{
    background: rgba(37,99,235,.12) !important;
    border: 1px solid rgba(37,99,235,.22) !important;
    box-shadow: 0 12px 22px rgba(37,99,235,.10);
  }
  
  /* Responsive */
  @media (max-width: 1100px){
    .wm-main{ grid-template-columns: 220px 1fr; grid-template-rows: 1fr 1fr; }
    .wm-view{ grid-column: 2; grid-row: 2; }
  }
  @media (max-width: 820px){
    .wm-topbar{ flex-direction:column; gap: 10px; align-items:stretch; }
    .wm-actions{ justify-content:space-between; }
    .wm-search input{ width: 180px; }
    .wm-main{ grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
    .wm-sidebar{ order: 1; }
    .wm-list{ order: 2; }
    .wm-view{ order: 3; min-height: 46vh; }
  }