/* ============================================================
   Vector Velocity — Layout
   Page-level structural rules: reset, app shell, auth layout,
   header, sidebar, content area, and grid utilities.
   ============================================================ */


/* ----------------------------------------------------------
   RESET & BASE
   ---------------------------------------------------------- */

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--surface-page);
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}


/* ----------------------------------------------------------
   AUTH LAYOUT
   Centered card — used on index.html (login) and any
   unauthenticated pages.
   ---------------------------------------------------------- */

.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: linear-gradient(135deg, var(--brand-primary-bg) 0%, var(--color-grey-50) 60%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10) var(--space-8);
}

.auth-card__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.auth-card__logo-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--brand-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.auth-card__logo img {
  height: 44px;
  width: auto;
}

.auth-card__logo-text {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.auth-card__subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
}

.auth-card__signup {
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}

.auth-card__signup a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-card__signup a:hover { text-decoration: underline; }

.auth-card__notice {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.auth-card__footer {
  margin-top: var(--space-6);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
}

.auth-card__footer a {
  color: var(--text-secondary);
}


/* ----------------------------------------------------------
   SPLIT LOGIN PAGE
   Left: brand panel. Right: login card.
   Collapses to single column on mobile.
   ---------------------------------------------------------- */

.auth-split-page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 380px 1fr;
}

.auth-brand {
  background:
    radial-gradient(ellipse at top right, var(--brand-primary-light) 0%, transparent 55%),
    linear-gradient(165deg, var(--brand-primary-dark) 0%, var(--brand-primary) 100%);
  color: var(--color-white);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-12) var(--space-10);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  bottom: -80px;
  right: -90px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.auth-brand::after {
  content: '';
  position: absolute;
  top: -60px;
  left: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.auth-brand__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
  flex: 1;
  justify-content: center;
  position: relative;
}

.auth-brand__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.auth-brand__mark {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.18);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.auth-brand__logo-text {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: white;
  line-height: var(--leading-tight);
}

.auth-brand__logo-sub {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

.auth-brand__headline {
  font-size: clamp(var(--text-xl), 2vw, var(--text-3xl));
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: white;
  letter-spacing: -0.4px;
  margin: 0;
}

.auth-brand__desc {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.72);
  line-height: var(--leading-relaxed);
  margin: 0;
}

.auth-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.auth-feature-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.88);
}

.auth-feature-list li::before {
  content: '✓';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-size: 11px;
  font-weight: var(--weight-bold);
  flex-shrink: 0;
  line-height: 1;
}

.auth-brand__pricing {
  font-size: var(--text-base);
  color: rgba(255, 255, 255, 0.7);
}

.auth-brand__pricing strong {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: white;
}

.auth-brand__vbs-link {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  transition: color var(--transition-fast);
  position: relative;
}

.auth-brand__vbs-link:hover {
  color: rgba(255, 255, 255, 0.75);
}

.auth-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  background: var(--surface-page);
  min-height: 100dvh;
}

@media (max-width: 800px) {
  .auth-split-page {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    display: none;
  }
}


/* ----------------------------------------------------------
   ONBOARDING PAGE
   Public wizard: business details → module picker → payment.
   No auth required — uses VBS default brand colours.
   ---------------------------------------------------------- */

.onboarding-page {
  background: var(--color-grey-50);
  min-height: 100dvh;
}

.ob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-8);
  background: var(--color-white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.ob-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ob-header__name {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
}

.ob-header__sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.ob-header__login {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.ob-header__login:hover {
  color: var(--text-primary);
}

.ob-main {
  display: flex;
  justify-content: center;
  padding: var(--space-10) var(--space-4) var(--space-16);
}

.ob-wrap {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Step indicator */
.ob-steps {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ob-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ob-step__num {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  background: var(--color-grey-200);
  color: var(--color-grey-500);
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.ob-step--active .ob-step__num {
  background: var(--brand-primary);
  color: var(--color-white);
}

.ob-step--done .ob-step__num {
  background: var(--brand-accent);
  color: var(--color-white);
}

.ob-step__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-grey-400);
  white-space: nowrap;
}

.ob-step--active .ob-step__label,
.ob-step--done .ob-step__label {
  color: var(--text-primary);
}

.ob-step__line {
  flex: 1;
  height: 1px;
  background: var(--border-color);
  margin: 0 var(--space-1);
}

/* Wizard card */
.ob-card {
  background: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.ob-card__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.3px;
  margin-bottom: var(--space-2);
}

.ob-card__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

.ob-card__footer {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-6);
}

/* Footer link row */
.ob-footer {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-bottom: var(--space-4);
}

@media (max-width: 640px) {
  .ob-header {
    padding: var(--space-3) var(--space-4);
  }

  .ob-header__login {
    display: none;
  }

  .ob-card {
    padding: var(--space-5);
  }
}


/* ----------------------------------------------------------
   APP SHELL
   Fixed sidebar + fixed header + scrollable main content.
   Used on all authenticated app pages.
   ---------------------------------------------------------- */

.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

body.has-global-announcement .sidebar {
  top: var(--announcement-bar-height, 0px);
  height: calc(100dvh - var(--announcement-bar-height, 0px));
}

body.has-global-announcement .app-header {
  top: var(--announcement-bar-height, 0px);
}


/* ----------------------------------------------------------
   SIDEBAR
   ---------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  background: var(--surface-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-sticky);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar__logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.sidebar__logo img {
  height: 32px;
  width: auto;
}

.sidebar__logo-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
}

.sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-grey-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-4) var(--space-5) var(--space-2);
}

.sidebar__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar__version {
  font-size: var(--text-xs);
  color: var(--color-grey-600);
}


/* ----------------------------------------------------------
   HEADER
   ---------------------------------------------------------- */

.app-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: var(--surface-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: var(--z-sticky);
}

.app-header__left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.app-header__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.app-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  flex-shrink: 0;
}


/* ----------------------------------------------------------
   MAIN CONTENT
   ---------------------------------------------------------- */

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-content {
  flex: 1;
  margin-top: var(--header-height);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-6);
  -webkit-overflow-scrolling: touch;
}

body.has-global-announcement .main-content {
  margin-top: calc(var(--header-height) + var(--announcement-bar-height, 0px));
}

/* iOS safe area support */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .main-content {
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
  }
}


/* ----------------------------------------------------------
   PAGE SECTIONS
   Used inside .main-content to separate views.
   ---------------------------------------------------------- */

.page-view {
  display: none;
}

.page-view.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.page-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.page-header__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}


/* ----------------------------------------------------------
   GRID UTILITIES
   ---------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.grid--stats {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.flex {
  display: flex;
}

.flex--center {
  align-items: center;
  justify-content: center;
}

.flex--between {
  align-items: center;
  justify-content: space-between;
}

.flex--gap-2 { gap: var(--space-2); }
.flex--gap-3 { gap: var(--space-3); }
.flex--gap-4 { gap: var(--space-4); }


/* ----------------------------------------------------------
   SPLIT LAYOUT  (list panel + detail panel)
   ---------------------------------------------------------- */

.split-layout {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
}

.split-layout__list {
  flex: 1;
  min-width: 0;
}

.split-layout__panel {
  width: var(--panel-width);
  flex-shrink: 0;
}


/* ----------------------------------------------------------
   RESPONSIVE BREAKPOINTS
   ---------------------------------------------------------- */

@media (max-width: 1024px) {
  .split-layout {
    flex-direction: column;
  }

  .split-layout__panel {
    width: 100%;
  }

  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }

  .sidebar.open {
    transform: translateX(0);
    width: 240px;
  }

  .app-header {
    left: 0;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
  }
}
