/* ═══════════════════════════════════════════════════════════════════
   VELTRIX OS — Layout (Sidebar, Topbar, Main)
   ═══════════════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}
/* alternate layout wrappers */
.layout, .app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  width: 100%;
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  transition: background var(--t-base), color var(--t-base);
  -webkit-font-smoothing: antialiased;
}

/* ═══ SIDEBAR ═══ */
.sb {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 10;
  transition: background var(--t-base), border-color var(--t-base);
}

.sb-logo {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sb-logo-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.sb-logo-text { line-height: 1.2; min-width: 0; }

.sb-logo-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--brand-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-logo-sub {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 1px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Scrollable nav area ── */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Collapsible group ── */
.sb-group { }

.sb-group-hd {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 5px;
  cursor: pointer;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  user-select: none;
  transition: color var(--t-fast);
  margin-top: 4px;
}
.sb-group-hd:hover { color: var(--text-1); }
.sb-group.open > .sb-group-hd { color: var(--brand-primary); }
.sb-group.no-toggle > .sb-group-hd { cursor: default; }

.sb-group-icon { font-size: 12px; width: 16px; text-align: center; flex-shrink: 0; }
.sb-group-label { flex: 1; }

.sb-arrow {
  font-size: 11px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.22s ease;
  opacity: .6;
}
.sb-group.open > .sb-group-hd .sb-arrow { transform: rotate(90deg); opacity: 1; }

/* ── Group body (collapsible) ── */
.sb-group-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
  padding: 0 8px;
}
.sb-group.open > .sb-group-body,
.sb-group.no-toggle > .sb-group-body {
  max-height: 1800px;
}

/* ── Nav items ── */
.sb-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 400;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: all var(--t-fast);
  margin-bottom: 1px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item.active,
.sb-item.on {
  background: var(--acc-bg);
  color: var(--brand-primary);
  font-weight: 600;
}

.sb-icon {
  font-size: 13px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: .75;
}
.sb-item.active .sb-icon,
.sb-item.on .sb-icon { opacity: 1; }

.sb-badge {
  margin-left: auto;
  background: var(--brand-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

/* ── Old section/label (backward compat) ── */
.sb-section { padding: 8px 8px 2px; }
.sb-label { font-size: 10px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: var(--text-3); padding: 0 8px; margin-bottom: 3px; }

.sb-foot {
  flex-shrink: 0;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

/* ═══ MAIN CONTENT ═══ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ═══ PAGE CONTENT AREA ═══ */
.page-content,
.page-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

/* ═══ TOPBAR ═══ */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
  transition: background var(--t-base), border-color var(--t-base);
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast);
}

.topbar-search input:focus { border-color: var(--brand-primary); }

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* ═══ LANGUAGE SELECTOR ═══ */
.lang-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition: all var(--t-fast);
}

.lang-select:hover { border-color: var(--brand-primary); color: var(--text); }

/* ═══ THEME TOGGLE ═══ */
.theme-toggle {
  width: 36px;
  height: 20px;
  border-radius: 20px;
  background: var(--border-2);
  position: relative;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  transition: background var(--t-base);
}

.theme-toggle.on { background: var(--brand-primary); }

.theme-toggle::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform var(--t-base);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.theme-toggle.on::after { transform: translateX(16px); }

/* ═══ AVATAR ═══ */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font-display);
}

/* ═══ CONTENT AREA ═══ */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* CF1-MOBILE - Mobile Responsive */

/* Hamburger button */
.sb-hamburger {
  display: none;
  background: none;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text);
  line-height: 1;
}

/* Sidebar overlay backdrop */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 98;
}
.sb-overlay.open { display: block; }

/* Mobile sidebar as drawer */
@media (max-width: 768px) {

  /* Show hamburger */
  .sb-hamburger { display: flex; align-items: center; }

  /* Body overflow — allow touch scrolling on mobile */
  body {
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh !important;
  }

  /* Sidebar hidden by default — slides in from left */
  .sb {
    position: fixed !important;
    left: -260px !important;
    top: 0 !important;
    width: 240px !important;
    height: 100vh !important;
    z-index: 99 !important;
    transition: left 0.3s ease !important;
    overflow-y: auto !important;
    box-shadow: none !important;
  }
  .sb.open {
    left: 0 !important;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15) !important;
  }

  /* Main content full width */
  .main {
    margin-left: 0 !important;
    width: 100% !important;
    min-height: 100vh !important;
  }

  /* Topbar mobile layout */
  .topbar {
    padding: 10px 14px !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
  }
  .topbar-search {
    flex: 1 !important;
    min-width: 0 !important;
  }
  .topbar-search input {
    width: 100% !important;
    font-size: 13px !important;
  }
  .topbar-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
  }

  /* Hide lang switcher on mobile — show compact version */
  .lang-switcher {
    display: none !important;
  }
  .lang-switcher-mobile {
    display: flex !important;
  }

  /* Content padding reduce */
  .content {
    padding: 14px !important;
  }

  /* Stat cards — 2 columns on mobile */
  .stats-grid,
  .stat-grid,
  [class*="stats-grid"],
  [class*="stat-grid"] {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
  }

  /* Pipeline funnel — scroll horizontal */
  .pipeline-funnel,
  [class*="pipeline"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Cards full width */
  .card, .portal-card, .settings-card {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Tables — horizontal scroll */
  table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
  }

  /* Modal full screen on mobile */
  .modal {
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 90vh !important;
  }
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* Form rows — single column */
  .form-row,
  .field-row,
  .field-row-3 {
    grid-template-columns: 1fr !important;
  }

  /* Persona grid — 2 col */
  .persona-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Settings tabs — horizontal scroll */
  .settings-tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 2px !important;
  }
  .tab-btn {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* Quick actions — 2 col */
  .quick-actions,
  [class*="quick-action"] {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
  }

  /* Hide desktop-only elements */
  .desktop-only { display: none !important; }

  /* Show mobile-only elements */
  .mobile-only { display: block !important; }

  /* Touch targets minimum 44px */
  .btn, button, a.sb-item {
    min-height: 36px !important;
  }

  /* Kanban horizontal scroll */
  .kanban-board,
  [class*="kanban"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    gap: 10px !important;
  }

  /* Charts responsive */
  canvas {
    max-width: 100% !important;
  }

  /* Page header stack on mobile */
  .page-hd {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .page-hd .btn { width: 100% !important; }

  /* Force hide sidebar on mobile by default */
  .sb {
    left: -260px !important;
    width: 240px !important;
  }

  /* Hide sidebar text labels when closed */
  .sb:not(.open) .sb-group-label,
  .sb:not(.open) .sb-logo-text,
  .sb:not(.open) .sb-group-hd span:not(.sb-group-icon) {
    display: none !important;
  }

  /* Topbar mobile compact */
  .topbar {
    padding: 8px 12px !important;
  }

  /* Hide lang switcher on mobile */
  .topbar .lang-switcher {
    display: none !important;
  }

  /* Reduce topbar action gaps */
  .topbar-actions {
    gap: 4px !important;
  }

  /* Avatar smaller on mobile */
  .avatar {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
  }

  /* Theme toggle smaller */
  .theme-toggle {
    width: 30px !important;
    height: 18px !important;
  }

  /* Hamburger always visible and ordered first */
  .sb-hamburger {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    order: -1 !important;
  }

}

/* Tablet — 768px to 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
  .sb { width: 220px !important; }
  .main { margin-left: 220px !important; }
  .content { padding: 16px !important; }
  .lang-switcher button:nth-child(n+3) { display: none !important; }
}

/* Lang switcher mobile — compact select */
.lang-switcher-mobile {
  display: none;
}
.lang-mobile-select {
  padding: 4px 8px;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

/* Print — always hide sidebar */
@media print {
  .sb, .topbar, .sb-hamburger, .sb-overlay,
  .no-print, button, .btn { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
}

/* END CF1-MOBILE */

/* CF-MOBILE-900 - Final Mobile Sidebar Fix */
@media (max-width: 900px) {
  .sb {
    position: fixed !important;
    left: -280px !important;
    top: 0 !important;
    width: 260px !important;
    height: 100% !important;
    height: 100dvh !important;
    z-index: 999 !important;
    transition: left 0.3s ease !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-shadow: none !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .sb.open {
    left: 0 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18) !important;
  }
  .main {
    margin-left: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 !important;
  }
  body {
    display: block !important;
    overflow-x: hidden !important;
  }
  .layout, .app-layout, [class*="layout"] {
    display: block !important;
  }
  .sb-hamburger {
    display: flex !important;
  }
  .topbar-actions .lang-switcher {
    display: none !important;
  }
  .topbar-actions {
    gap: 6px !important;
  }
  .content {
    padding: 12px !important;
  }
}
/* END CF-MOBILE-900 */

/* ═══════════════════════════════════════════════════════════════════
   VELTRIX OS 2035 — Futuristic Micro-Animations & Polish
   ═══════════════════════════════════════════════════════════════════ */

/* Page fade-in on load */
@keyframes vxPageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main {
  animation: vxPageIn 0.28s ease forwards;
}

/* Card hover lift */
.card {
  transition: box-shadow var(--t-base), transform var(--t-fast), border-color var(--t-fast);
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}

/* Sidebar item smooth active indicator */
.sb-item {
  position: relative;
  overflow: hidden;
}
.sb-item::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 0;
  background: var(--brand-primary);
  border-radius: 0 3px 3px 0;
  transition: height var(--t-base);
}
.sb-item.active::before,
.sb-item[class*="active"]::before {
  height: 60%;
}

/* Button press micro-animation */
button:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* Input focus glow */
input:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px rgba(200, 98, 48, 0.12);
}

/* Topbar command palette button entrance */
#vx-cp-btn {
  animation: vxPageIn 0.4s ease 0.2s both;
}
#vx-notif-btn {
  animation: vxPageIn 0.4s ease 0.25s both;
}

/* Hero section shimmer effect */
.mod-hero,
.exp-hero,
.ig-hero,
.wa-hero,
.st-hero,
.task-hero {
  position: relative;
  overflow: hidden;
}
.mod-hero::after,
.exp-hero::after,
.ig-hero::after,
.wa-hero::after {
  content: '';
  position: absolute;
  top: -50%; left: -75%;
  width: 50%; height: 200%;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.06) 50%, transparent 60%);
  animation: vxHeroShimmer 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes vxHeroShimmer {
  0%   { left: -75%; }
  100% { left: 125%; }
}

/* Skeleton loader pulse for async content */
@keyframes vxSkeleton {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.vx-skeleton {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  animation: vxSkeleton 1.4s ease infinite;
  color: transparent !important;
  user-select: none;
}

/* Stat number count-up visual (use with JS) */
@keyframes vxStatPop {
  0%   { transform: scale(0.85); opacity: 0; }
  70%  { transform: scale(1.04); }
  100% { transform: scale(1);    opacity: 1; }
}
.vx-stat-val {
  animation: vxStatPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Badge pulse for notifications */
@keyframes vxBadgePulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}
#vx-notif-badge {
  animation: vxBadgePulse 2s ease infinite;
}

/* Smooth tab switch */
[class*="-panel"],
[id*="panel-"] {
  animation: vxPageIn 0.2s ease;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* Focus visible outline (accessibility + 2035 design) */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Selection color */
::selection {
  background: var(--acc-bg);
  color: var(--brand-primary);
}

/* Smooth theme transition */
*, *::before, *::after {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease;
}
/* Exclude elements that shouldn't transition */
input, textarea, select,
[class*="anim"], [class*="motion"],
.mod-hero, .exp-hero {
  transition: none;
}
input, textarea, select {
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
/* END VELTRIX OS 2035 */

/* ═══ PART 7 LAYOUT ADDITIONS ═══ */

/* Stats grid — base definition (mobile cols override in CF-MOBILE-900 above) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

/* Page fade-in utility class (reuses vxPageIn keyframe) */
.page-fade-in {
  animation: vxPageIn 0.25s ease forwards;
}

/* Responsive table wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-md);
}

/* Glass card utility */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--r-lg);
}

/* Page header flex row */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.page-header-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Step 8 — Mobile topbar: collapse search on very small screens */
@media (max-width: 480px) {
  .topbar-search {
    display: none !important;
  }
  .topbar-actions {
    margin-left: 0 !important;
    flex: 1 !important;
    justify-content: flex-end !important;
  }
  .topbar {
    padding: 0 10px !important;
    gap: 6px !important;
  }
}

