/* ═══════════════════════════════════════════════════════════════════════
   NEXUS — Layout & Alignment Fixes
   Fixes spacing, padding, alignment and visibility issues across all pages
═══════════════════════════════════════════════════════════════════════ */

/* ── 1. LOGIN PAGE ──────────────────────────────────────────────────── */
/* Left panel text color fix — dark background needs light text */
.left .l-h1,
.left .l-brand-name,
.left .l-tagline { color: rgba(255,255,255,.9) !important; }
.left .l-eyebrow { color: var(--gold) !important; }

/* Right panel vertical centering on short screens */
.right {
  overflow-y: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
@media (max-width: 860px) {
  body.login-page { flex-direction: column; overflow: auto; }
  .left  { min-height: 280px; flex: none; padding: 32px 28px; }
  .right { width: 100%; flex: none; padding: 36px 28px; min-height: unset; }
  .l-h1  { font-size: clamp(26px, 6vw, 40px) !important; }
  .l-roles { display: none; }
}

/* ── 2. SIDEBAR ─────────────────────────────────────────────────────── */
/* Ensure main content is never hidden behind sidebar */
.nx-main {
  margin-left: 240px !important;
  min-width: 0;
  width: calc(100% - 240px);
}
@media (max-width: 767px) {
  .nx-main { margin-left: 0 !important; width: 100% !important; }
}

/* Sidebar overflow fix — long labels shouldn't break layout */
.nx-a-lbl { 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap; 
}
.nx-section-hd { 
  padding: 12px 10px 4px; 
}

/* ── 3. PAGE HEADER BARS ────────────────────────────────────────────── */
/* wf_ pages use pg-head / wf-ph / topbar — fix sticky positioning */
.pg-head {
  position: sticky;
  top: 52px;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,.07);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.wf-ph {
  top: 52px !important;
  z-index: 30;
}

/* Dashboard / admin pages — topbar spacing */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,.07);
  flex-wrap: wrap;
}
.topbar h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.4px;
  margin: 0;
}

/* ── 4. CONTENT BODY PADDING ─────────────────────────────────────────── */
/* Ensure page content doesn't touch the edges */
.pg-body,
.wf-body,
.board-content,
.admin-body {
  padding: 20px 22px !important;
}
@media (max-width: 767px) {
  .pg-body,
  .wf-body,
  .board-content {
    padding: 14px 14px 28px !important;
  }
}

/* Dashboard section body */
div[style*="padding:20px 28px"],
div[style*="padding: 20px 28px"] {
  padding: 20px 22px !important;
}

/* ── 5. TAB BARS ──────────────────────────────────────────────────────── */
.tab-bar {
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,.07);
  padding: 0 22px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: sticky;
  top: 104px; /* below nx-header (52px) + pg-head (~52px) */
  z-index: 40;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-item {
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #9A9BAD;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tab-item:hover { color: #1A1B23; }
.tab-item.active { color: #E8A94B; border-bottom-color: #E8A94B; }

/* ── 6. CARDS ─────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 16px;
  overflow: hidden;
}
.card-head {
  padding: 13px 17px;
  border-bottom: 1px solid rgba(0,0,0,.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-head h3,
.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #1A1B23;
}
.card-pad { padding: 15px 17px; }

/* Stats grid cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 16px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1;
}
.stat-lbl {
  font-size: 11px;
  color: #9A9BAD;
  font-weight: 600;
  margin-top: 4px;
}

/* ── 7. TABLES ────────────────────────────────────────────────────────── */
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.tbl thead th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9A9BAD;
  background: #F5F6FA;
  padding: 9px 13px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,.07);
  white-space: nowrap;
}
table.tbl tbody td {
  padding: 10px 13px;
  border-bottom: 1px solid rgba(0,0,0,.07);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border: none; }
table.tbl tbody tr:hover td { background: #FAFBFF; }

/* Responsive tables — horizontal scroll on mobile */
.card > div[style*="overflow-x:auto"],
.card[style*="overflow-x:auto"] {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 767px) {
  table.tbl { min-width: 600px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 8. FORM CONTROLS ─────────────────────────────────────────────────── */
.fc, input.fc, select.fc, textarea.fc {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--ff, 'DM Sans', sans-serif);
  background: #fff;
  color: #1A1B23;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.fc:focus, input.fc:focus, select.fc:focus, textarea.fc:focus {
  border-color: rgba(232,169,75,.55);
  box-shadow: 0 0 0 3px rgba(232,169,75,.18);
}
.fc::placeholder { color: #9A9BAD; }
textarea.fc { resize: vertical; min-height: 64px; }
.fg, .form-group, .field { margin-bottom: 13px; }
.fg label, .form-group label, .field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #5A5C72;
  margin-bottom: 5px;
}
.frow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) { .frow { grid-template-columns: 1fr; } }

/* ── 9. BUTTONS ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: var(--ff, 'DM Sans', sans-serif);
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-pri, .btn-primary {
  background: #E8A94B;
  color: #1A1B23;
  box-shadow: 0 3px 10px rgba(232,169,75,.3);
}
.btn-pri:hover, .btn-primary:hover { background: #C78A2E; }
.btn-ghost {
  background: #F5F6FA;
  color: #5A5C72;
  border: 1px solid rgba(0,0,0,.10);
}
.btn-ghost:hover { background: #E8EAF2; }
.btn-green {
  background: rgba(26,158,110,.10);
  color: #137A52;
  border: 1px solid rgba(26,158,110,.2);
}
.btn-green:hover { background: #1A9E6E; color: #fff; }
.btn-teal {
  background: rgba(26,143,168,.09);
  color: #1A8FA8;
  border: 1px solid rgba(26,143,168,.2);
}
.btn-teal:hover { background: #1A8FA8; color: #fff; }
.btn-red {
  background: rgba(217,64,64,.09);
  color: #D94040;
  border: 1px solid rgba(217,64,64,.2);
}
.btn-red:hover { background: #D94040; color: #fff; }
.btn-sm  { padding: 5px 11px; font-size: 12px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; border-radius: 6px; }

/* ── 10. MODALS ───────────────────────────────────────────────────────── */
.modal-bd {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,14,40,.38);
  z-index: 600;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.modal-bd.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 60px rgba(0,0,0,.18);
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: mboxIn .22s cubic-bezier(.32,1,.23,1);
}
.modal-sm { width: 420px; }
@keyframes mboxIn {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.modal-hd {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(0,0,0,.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-hd h3 { font-size: 15px; font-weight: 800; margin: 0; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: #F5F6FA;
  border: none;
  cursor: pointer;
  color: #9A9BAD;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: #D94040; background: rgba(217,64,64,.09); }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-ft {
  padding: 13px 22px;
  border-top: 1px solid rgba(0,0,0,.07);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .modal-box, .modal-sm { width: 100%; border-radius: 20px 20px 0 0; }
  .modal-bd { align-items: flex-end; padding: 0; }
}

/* ── 11. ALERTS / BANNERS ─────────────────────────────────────────────── */
.alert-panel {
  border-radius: 14px;
  padding: 13px 16px;
  margin-bottom: 16px;
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 11px;
}
.alert-panel.warn {
  background: rgba(232,169,75,.08);
  border-color: rgba(232,169,75,.25);
  color: #C78A2E;
}
.alert-panel.info {
  background: rgba(26,143,168,.08);
  border-color: rgba(26,143,168,.2);
  color: #1A8FA8;
}
.alert-panel.success {
  background: rgba(26,158,110,.08);
  border-color: rgba(26,158,110,.2);
  color: #137A52;
}

/* ── 12. EMPTY STATES ─────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 44px 20px;
  color: #9A9BAD;
}
.empty-icon { font-size: 32px; margin-bottom: 10px; }
.empty-text { font-size: 14px; font-weight: 700; }
.empty-sub  { font-size: 12px; margin-top: 4px; }

/* ── 13. MONO / BADGE TAGS ────────────────────────────────────────────── */
.mono {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
}
.mono-gold   { background: rgba(232,169,75,.12); color: #C78A2E; }
.mono-blue   { background: rgba(59,109,214,.08); color: #3B6DD6; }
.mono-gray   { background: #F5F6FA; color: #5A5C72; }
.mono-green  { background: rgba(26,158,110,.10); color: #137A52; }
.mono-red    { background: rgba(217,64,64,.10); color: #D94040; }

/* ── 14. TOAST NOTIFICATIONS ─────────────────────────────────────────── */
.toast-bar {
  position: fixed;
  top: 70px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: #fff;
  border: 1px solid rgba(0,0,0,.09);
  border-radius: 12px;
  padding: 10px 15px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  animation: toastIn .2s ease;
  max-width: 340px;
  pointer-events: all;
}
.toast.ok, .toast.success {
  background: rgba(26,158,110,.10);
  border-color: rgba(26,158,110,.25);
  color: #137A52;
}
.toast.err, .toast.error {
  background: rgba(217,64,64,.10);
  border-color: rgba(217,64,64,.25);
  color: #D94040;
}
@keyframes toastIn { from { transform: translateX(50px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 15. GRID LAYOUTS ─────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 767px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 480px) {
  .grid-auto { grid-template-columns: 1fr; }
}

/* ── 16. PIPELINE PAGE SPECIFIC ──────────────────────────────────────── */
/* Pipeline columns horizontal scroll */
.funnel {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
/* CRS/Lead list cards */
.crs-list { display: flex; flex-direction: column; gap: 10px; }
.crs-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 14px;
  padding: 14px 16px;
}

/* ── 17. SECTION VISIBILITY — Dashboard sections ─────────────────────── */
/* All sections rendered, CSS shows/hides based on active class */
.section { display: none; }
.section.active { display: block; }

/* ── 18. SCROLLBAR ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #DDE0EE; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #C8CAD8; }

/* ── 19. GLOBAL BODY PADDING fix — prevent content hidden under mobile bar */
@media (max-width: 767px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
}

/* ── 20. WF PIPELINE — Full width on mobile ──────────────────────────── */
@media (max-width: 767px) {
  .wf-body { padding: 12px 12px 24px !important; }
  .pg-head  { top: 56px; padding: 12px 14px; }
  .tab-bar  { top: auto; position: sticky; }
}

/* ── 21. PROGRESS BARS ────────────────────────────────────────────────── */
.prog-bar  { height: 6px; background: #E8EAF2; border-radius: 99px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #E8A94B, #1A9E6E); transition: width .3s; }

/* ── 22. ATTENDANCE / ADMIN PAGES ────────────────────────────────────── */
.admin-body { padding: 24px 22px !important; }
@media (max-width: 767px) { .admin-body { padding: 16px 14px !important; } }

/* ── 23. VISIBILITY HELPERS ──────────────────────────────────────────── */
.hidden { display: none !important; }
.visible { display: block !important; }
.flex-visible { display: flex !important; }

/* ── 24. TEXT UTILITIES ───────────────────────────────────────────────── */
.text-gold   { color: #E8A94B !important; }
.text-green  { color: #1A9E6E !important; }
.text-red    { color: #D94040 !important; }
.text-muted  { color: #9A9BAD !important; }
.text-strong { font-weight: 700; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 25. DASHBOARD STATS GRID ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}
@media (max-width: 600px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

/* ── 26. GENERAL OVERFLOW FIXES ──────────────────────────────────────── */
img { max-width: 100%; height: auto; }
* { min-width: 0; } /* Prevents flex children from overflowing */
