/* ── shared.css — webmail.myflex.io design system ───────────────────────────
   Loaded on every page (authenticated + public where applicable).
   Module-specific overrides go in each page's own <style> block.
   ─────────────────────────────────────────────────────────────────────────── */

/* ── CSS variables (dark theme defaults) ────────────────────────────────────── */
:root {
  --bg0:    #0d0f12;
  --bg1:    #13161b;
  --bg2:    #1a1e25;
  --bg3:    #222730;
  --bg4:    #2a3040;
  --border:  #2e3441;
  --border2: #3a4254;
  --text0:  #e8ecf2;
  --text1:  #b0bac8;
  --text2:  #6e7a8a;
  --accent:  #4f8ef7;
  --accent2: #2d6ae0;
  --green:  #3ecf8e;
  --red:    #f76f6f;
  --yellow: #f7c94f;
  --r:      6px;
}

/* ── Light theme overrides ──────────────────────────────────────────────────── */
html[data-theme="light"] {
  --bg0:    #f0f2f5;
  --bg1:    #ffffff;
  --bg2:    #f4f6fa;
  --bg3:    #e8ecf3;
  --bg4:    #d6dce8;
  --border:  #d0d6e2;
  --border2: #b8c4d4;
  --text0:  #1a1e28;
  --text1:  #3d4a5c;
  --text2:  #7a8898;
  --accent:  #3a7de8;
  --accent2: #2260c0;
  --green:  #1a9e6a;
  --red:    #d43535;
  --yellow: #b07a0a;
}
html[data-theme="light"] body {
  background: var(--bg0);
  color: var(--text0);
}

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

/* ── Toast notifications ────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toast-msg {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 9px 14px;
  font-size: 12px;
  color: var(--text0);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  animation: slideIn .2s ease;
  min-width: 180px;
}
.toast-msg.ok  { border-left: 3px solid var(--green); }
.toast-msg.err { border-left: 3px solid var(--red); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modal overlay ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

/* ── Modal chrome ───────────────────────────────────────────────────────────── */
/* .modal width/max-height stays per-module since it varies by content */
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  color: var(--text0);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  /* v3.16 MOBILE — touch target */
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── Form fields ────────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label {
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.field-group input,
.field-group select,
.field-group textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  color: var(--text0);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  -webkit-appearance: none;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus { border-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--bg2);
  color: var(--text1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg3); }

.btn-danger {
  background: rgba(247,111,111,.1);
  color: var(--red);
  border: 1px solid rgba(247,111,111,.3);
  border-radius: var(--r);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-danger:hover { background: rgba(247,111,111,.2); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

/* ── Status messages ────────────────────────────────────────────────────────── */
.status-msg { font-size: 12px; padding: 8px 12px; border-radius: var(--r); }
.status-msg.ok  { background: rgba(62,207,142,.1);  color: var(--green); border: 1px solid rgba(62,207,142,.25); }
.status-msg.err { background: rgba(247,111,111,.1); color: var(--red);   border: 1px solid rgba(247,111,111,.25); }

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Table scroll wrapper ───────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Nav chrome (injected by nav.js) ────────────────────────────────────────── */

/* Sidebar resize handle */
.nav-resize-handle { width:4px; background:var(--border,#2e3441); cursor:col-resize; flex-shrink:0; transition:background .15s; position:relative; z-index:10; }
.nav-resize-handle:hover, .nav-resize-handle.dragging { background:var(--accent,#4f8ef7); }

/* Module nav */
.nav-module-section { border-top:1px solid var(--border,#2e3441); padding:8px 0; margin-top:auto; }
.nav-module-title { padding:6px 14px; font-size:10px; text-transform:uppercase; letter-spacing:.6px; color:var(--text2,#6e7a8a); display:flex; align-items:center; justify-content:space-between; }
.nav-module-toggle { background:none; border:none; color:var(--text2,#6e7a8a); cursor:pointer; font-size:11px; padding:0 4px; transition:color .15s; }
.nav-module-toggle:hover { color:var(--text0,#e8ecf2); }
.nav-module-item { display:flex; align-items:center; gap:9px; padding:7px 14px; color:var(--text1,#b0bac8); text-decoration:none; font-size:12px; transition:background .1s; cursor:pointer; border:none; background:none; width:100%; font-family:inherit; }
.nav-module-item:hover { background:var(--bg2,#1a1e25); color:var(--text0,#e8ecf2); }
.nav-module-item.active { color:var(--accent,#4f8ef7); background:var(--bg2,#1a1e25); }
.nav-module-item .nmi-icon { font-size:14px; width:18px; text-align:center; flex-shrink:0; }
.nav-module-item .nmi-name { flex:1; text-align:left; }

/* Profile section */
.nav-profile-section { border-top:1px solid var(--border,#2e3441); padding:8px 12px; display:flex; align-items:center; gap:8px; cursor:pointer; transition:background .1s; position:relative; }
.nav-profile-section:hover { background:var(--bg2,#1a1e25); }
.nav-profile-avatar { width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:600; color:#fff; flex-shrink:0; }
.nav-profile-info { flex:1; overflow:hidden; }
.nav-profile-name { font-size:12px; font-weight:500; color:var(--text0,#e8ecf2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nav-profile-role { font-size:10px; color:var(--text2,#6e7a8a); text-transform:uppercase; letter-spacing:.3px; }

/* Profile dropdown */
#nav-dropdown { position:fixed; bottom:50px; left:12px; background:var(--bg2,#1a1e25); border:1px solid var(--border,#2e3441); border-radius:8px; box-shadow:0 -8px 24px rgba(0,0,0,.5); z-index:600; min-width:200px; padding:4px 0; display:none; }
#nav-dropdown.open { display:block; }
.ndd-item { padding:9px 14px; cursor:pointer; font-size:12px; color:var(--text1,#b0bac8); display:flex; align-items:center; gap:8px; transition:background .1s; }
.ndd-item:hover { background:var(--bg3,#222730); color:var(--text0,#e8ecf2); }
.ndd-item.danger { color:var(--red,#f76f6f); }
.ndd-item.danger:hover { background:rgba(247,111,111,.08); }
.ndd-sep { height:1px; background:var(--border,#2e3441); margin:3px 0; }

/* Profile modal */
#nav-profile-modal { position:fixed; inset:0; background:rgba(0,0,0,.65); z-index:700; display:none; align-items:center; justify-content:center; backdrop-filter:blur(4px); }
#nav-profile-modal.open { display:flex; }
.npm-wrap { background:var(--bg1,#13161b); border:1px solid var(--border,#2e3441); border-radius:10px; width:400px; max-width:95vw; max-height:90vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,.5); }
.npm-h { padding:13px 16px; border-bottom:1px solid var(--border,#2e3441); display:flex; align-items:center; }
.npm-h h3 { font-size:14px; font-weight:600; flex:1; color:var(--text0,#e8ecf2); }
.npm-hc { background:none; border:none; color:var(--text2,#6e7a8a); font-size:20px; cursor:pointer; }
.npm-b { padding:14px 16px; display:flex; flex-direction:column; gap:11px; }
.npm-f { padding:11px 16px; border-top:1px solid var(--border,#2e3441); display:flex; gap:8px; justify-content:flex-end; }
.npm-avrow { display:flex; align-items:center; gap:12px; padding-bottom:12px; border-bottom:1px solid var(--border,#2e3441); }
.npm-bigav { width:50px; height:50px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:18px; font-weight:600; color:#fff; flex-shrink:0; }
.npm-swatches { display:flex; gap:6px; flex-wrap:wrap; }
.npm-sw { width:20px; height:20px; border-radius:50%; cursor:pointer; border:2px solid transparent; transition:border-color .15s; }
.npm-sw:hover, .npm-sw.sel { border-color:#fff; }
.npm-fg { display:flex; flex-direction:column; gap:4px; }
.npm-fg label { font-size:11px; color:var(--text2,#6e7a8a); text-transform:uppercase; letter-spacing:.5px; }
.npm-fg input { background:var(--bg2,#1a1e25); border:1px solid var(--border,#2e3441); border-radius:6px; padding:7px 10px; color:var(--text0,#e8ecf2); font-family:inherit; font-size:13px; outline:none; width:100%; }
.npm-fg input:focus { border-color:var(--accent,#4f8ef7); }
.npm-fg input:disabled { opacity:.4; cursor:not-allowed; }
.npm-sectitle { font-size:12px; font-weight:500; color:var(--text1,#b0bac8); padding-top:4px; border-top:1px solid var(--border,#2e3441); }
.npm-bp { background:var(--accent,#4f8ef7); color:#fff; border:none; border-radius:6px; padding:8px 16px; font-family:inherit; font-size:13px; font-weight:500; cursor:pointer; }
.npm-bp:hover { background:var(--accent2,#2d6ae0); }
.npm-bs { background:var(--bg2,#1a1e25); color:var(--text1,#b0bac8); border:1px solid var(--border,#2e3441); border-radius:6px; padding:8px 14px; font-family:inherit; font-size:13px; cursor:pointer; }
.npm-status { font-size:12px; padding:7px 10px; border-radius:6px; }
.npm-status.ok  { background:rgba(62,207,142,.1); color:#3ecf8e; border:1px solid rgba(62,207,142,.25); }
.npm-status.err { background:rgba(247,111,111,.1); color:#f76f6f; border:1px solid rgba(247,111,111,.25); }

/* Mobile hamburger bar — hidden on desktop */
.nav-hamburger-bar { display:none; }
.nav-mob-backdrop  { display:none; }

/* ── Mobile adjustments ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Toast — full-width strip at bottom */
  #toast { right: 12px; left: 12px; bottom: 16px; }

  /* Hamburger top bar */
  .nav-hamburger-bar {
    display: flex;
    align-items: center;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 48px;
    background: var(--bg1, #13161b);
    border-bottom: 1px solid var(--border, #2e3441);
    z-index: 520;
    padding: 0 8px;
    gap: 8px;
    box-sizing: border-box;
  }
  .nav-hamburger-btn {
    background: none; border: none;
    color: var(--text0, #e8ecf2);
    font-size: 18px; cursor: pointer;
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; border-radius: 6px; transition: background .1s;
  }
  .nav-hamburger-btn:hover { background: var(--bg2, #1a1e25); }
  .nav-hamburger-title {
    font-size: 14px; font-weight: 600;
    color: var(--text0, #e8ecf2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Sidebar — fixed overlay */
  #sidebar, .sidebar {
    position: fixed !important;
    top: 0 !important; left: -250px !important;
    height: 100% !important;
    width: 240px !important; min-width: 240px !important; max-width: 240px !important;
    z-index: 530 !important;
    transition: left 0.25s ease !important;
    overflow-y: auto !important; overflow-x: hidden !important;
  }
  #sidebar.mob-open, .sidebar.mob-open { left: 0 !important; }

  /* Backdrop */
  .nav-mob-backdrop {
    display: none;
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,.5);
    z-index: 525; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-mob-backdrop.open { display: block; }

  /* Hide resize handle on touch */
  .nav-resize-handle { display: none !important; }

  /* Push content below fixed top bar */
  body { padding-top: 48px !important; }

  /* Touch-friendly nav targets */
  .nav-module-item { padding: 11px 14px !important; min-height: 44px; }
  .nav-profile-section { min-height: 52px; padding: 10px 12px !important; }
  .nav-module-toggle { min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; }

  /* Profile dropdown repositioned on mobile */
  #nav-dropdown { left: 8px !important; right: 8px !important; bottom: auto !important; top: 56px !important; min-width: unset !important; width: auto !important; }

  /* Modal — full width, scrollable */
  .modal { width: 95vw !important; max-height: 90vh; overflow-y: auto; }

  /* Modal footer — equal-width buttons */
  .modal-footer .btn-primary,
  .modal-footer .btn-secondary {
    min-height: 44px;
    font-size: 14px;
    flex: 1;
    min-width: 80px;
    justify-content: center;
    display: flex;
    align-items: center;
  }

  /* Inputs — 16px prevents iOS auto-zoom */
  .field-group input,
  .field-group select,
  .field-group textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 10px;
  }
}
