/* ─── DotsConnectGo Design System ─── */
/* Aligned with Data On The Spot brand guidelines */

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

:root {
  /* Brand palette */
  --brand-blue: #424A97;
  --brand-blue-hover: #353C85;
  --brand-blue-soft: rgba(66, 74, 151, 0.10);
  --brand-blue-softer: rgba(66, 74, 151, 0.06);
  --brand-blue-ring: rgba(66, 74, 151, 0.25);
  --brand-gray: #BFC2C8;

  /* Neutrals */
  --bg: #FFFFFF;
  --bg-soft: #F4F6FA;
  --text-primary: #262626;
  --text-secondary: #636C71;
  --text-muted: #8E959B;
  --border: #E5E8EE;
  --border-strong: #BFC2C8;

  /* Legacy --vb-* aliases (keep existing components working) */
  --vb-bg: var(--bg-soft);
  --vb-surface: var(--bg);
  --vb-surface-2: #EEF1F7;
  --vb-border: var(--border);
  --vb-text: var(--text-primary);
  --vb-text-dim: var(--text-secondary);
  --vb-text-muted: var(--text-muted);
  --vb-accent: var(--brand-blue);
  --vb-accent-hover: var(--brand-blue-hover);
  --vb-success: #16A34A;
  --vb-danger: #DC2626;
  --vb-warning: #D97706;

  --vb-radius: 12px;
  --vb-radius-sm: 8px;
  --vb-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --vb-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Dotted background pattern */
  --dots-bg:
    radial-gradient(circle, rgba(66, 74, 151, 0.08) 1px, transparent 1.25px);
}

html { font-size: 16px; }

body {
  font-family: var(--vb-font);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  background: var(--bg);
  background-image: var(--dots-bg);
  background-size: 22px 22px;
  background-position: 0 0;
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ─── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: var(--text-primary); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

.text-dim { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--brand-blue); }
.text-success { color: var(--vb-success); }
.text-danger { color: var(--vb-danger); }
.mono { font-family: var(--vb-mono); }

/* ─── Layout ─── */
.vb-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.vb-row { display: flex; gap: 1rem; align-items: center; }
.vb-row-between { display: flex; justify-content: space-between; align-items: center; }
.vb-col { display: flex; flex-direction: column; gap: 0.75rem; }
.vb-gap-sm { gap: 0.5rem; }
.vb-gap-lg { gap: 1.25rem; }

.vb-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ─── Cards / Surfaces ─── */
.vb-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--vb-radius);
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.vb-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.vb-card-header h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

/* ─── Buttons ─── */
.vb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  font-family: var(--vb-font);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--vb-radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.vb-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.vb-btn-primary {
  background: var(--brand-blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(66, 74, 151, 0.15);
}
.vb-btn-primary:hover:not(:disabled) {
  background: var(--brand-blue-hover);
  box-shadow: 0 2px 4px rgba(66, 74, 151, 0.25);
}

.vb-btn-success {
  background: var(--vb-success);
  color: #fff;
}
.vb-btn-success:hover:not(:disabled) { background: #15803D; }

.vb-btn-danger {
  background: var(--vb-danger);
  color: #fff;
}
.vb-btn-danger:hover:not(:disabled) { background: #B91C1C; }

.vb-btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.vb-btn-ghost:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.vb-btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.vb-btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.vb-btn-block { width: 100%; }

/* ─── Inputs ─── */
.vb-input,
.vb-select,
.vb-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: var(--vb-font);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--vb-radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.vb-input:focus,
.vb-select:focus,
.vb-textarea:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-blue-ring);
}

.vb-input::placeholder { color: var(--text-muted); }

.vb-textarea { min-height: 80px; resize: vertical; }

.vb-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23636C71' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2rem;
}

/* ─── Form Groups ─── */
.vb-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.vb-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ─── Toggle / Switch ─── */
.vb-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.vb-toggle input { display: none; }

.vb-toggle-track {
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.vb-toggle input:checked + .vb-toggle-track {
  background: var(--brand-blue);
}

.vb-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}

.vb-toggle input:checked + .vb-toggle-track::after {
  transform: translateX(16px);
}

/* ─── Badges ─── */
.vb-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 6px;
}

.vb-badge-passed { background: rgba(22,163,74,0.10); color: var(--vb-success); }
.vb-badge-failed { background: rgba(220,38,38,0.10); color: var(--vb-danger); }
.vb-badge-elected { background: var(--brand-blue-soft); color: var(--brand-blue); }
.vb-badge-live { background: rgba(220,38,38,0.12); color: var(--vb-danger); }
.vb-badge-pro { background: rgba(217,119,6,0.12); color: var(--vb-warning); }
.vb-badge-business { background: var(--brand-blue-soft); color: var(--brand-blue); }
.vb-badge-enterprise { background: rgba(22,163,74,0.10); color: var(--vb-success); }
.vb-badge-complete { background: var(--brand-blue-soft); color: var(--brand-blue); }
.vb-badge-sm { padding: 0.1rem 0.4rem; font-size: 0.6rem; background: var(--brand-blue-soft); color: var(--brand-blue); }
.vb-queue-tags { display: inline-flex; gap: 0.25rem; margin-left: 0.5rem; }

/* ─── Live Indicator ─── */
.vb-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vb-danger);
  animation: vb-pulse 1.5s infinite;
}

@keyframes vb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Status Bar ─── */
.vb-status-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--vb-radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ─── Tabs ─── */
.vb-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.vb-tab {
  padding: 0.65rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.vb-tab:hover { color: var(--text-primary); }
.vb-tab.active {
  color: var(--brand-blue);
  border-bottom-color: var(--brand-blue);
  font-weight: 600;
}

.vb-tab-panel { display: none; }
.vb-tab-panel.active { display: block; }

/* ─── Queue Item ─── */
.vb-queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--vb-radius-sm);
  cursor: grab;
  transition: all 0.15s;
}

.vb-queue-item:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.vb-queue-item.active {
  border-color: var(--brand-blue);
  background: var(--brand-blue-softer);
  box-shadow: inset 2px 0 0 var(--brand-blue);
}

.vb-queue-item .vb-queue-drag {
  color: var(--text-muted);
  cursor: grab;
  font-size: 1rem;
}

.vb-queue-item .vb-queue-title {
  flex: 1;
  font-weight: 500;
  font-size: 0.875rem;
}

.vb-queue-item .vb-queue-type {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Vertical Bar Chart ─── */
.vb-bars {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  height: 260px;
  padding: 1rem 0;
}

.vb-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.vb-bar-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  min-height: 2.5rem;
}

.vb-bar-count { font-weight: 700; font-size: 1.1rem; color: var(--text-primary); }
.vb-bar-pct { color: var(--text-secondary); font-size: 0.75rem; }

.vb-bar-track {
  flex: 1;
  width: 100%;
  max-width: 80px;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.vb-bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: height 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 2px;
}

.vb-bar-label {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

/* ─── Horizontal Bar Chart ─── */
.vb-hbars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.vb-hbar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.vb-hbar-label {
  width: 100px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.vb-hbar-track {
  flex: 1;
  height: 32px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.vb-hbar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vb-hbar-value {
  width: 80px;
  font-size: 0.8rem;
  text-align: right;
  flex-shrink: 0;
  color: var(--text-primary);
}

.vb-hbar-pct { color: var(--text-secondary); margin-left: 0.3rem; }

/* ─── Threshold Line ─── */
.vb-threshold-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--vb-warning);
  pointer-events: none;
}

.vb-threshold-label {
  position: absolute;
  right: 0;
  top: -18px;
  font-size: 0.7rem;
  color: var(--vb-warning);
  white-space: nowrap;
}

/* ─── Toast Notification ─── */
.vb-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.7rem 1.2rem;
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--vb-radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  font-size: 0.85rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
  pointer-events: none;
}

.vb-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.vb-toast-success { border-color: var(--vb-success); }
.vb-toast-danger { border-color: var(--vb-danger); }

/* ─── Modal ─── */
.vb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 38, 38, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.vb-modal-overlay.active { opacity: 1; }

.vb-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--vb-radius);
  box-shadow: 0 20px 40px rgba(16, 24, 40, 0.18);
  padding: 1.5rem;
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

.vb-modal h2 { margin-bottom: 1rem; }

.vb-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ─── Auth Gate ─── */
.vb-auth-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1.5rem;
  text-align: center;
}

.vb-auth-gate h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.vb-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.5rem;
  background: #fff;
  color: #262626;
  border: 1px solid var(--border);
  border-radius: var(--vb-radius-sm);
  font-family: var(--vb-font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.vb-google-btn:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.08);
}

/* ─── QR Code Container ─── */
.vb-qr-wrap {
  display: inline-flex;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--vb-radius);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
}

/* ─── Color Swatch Input ─── */
.vb-color-input {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  background: none;
}

.vb-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.vb-color-input::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ─── Logo Preview ─── */
.vb-logo-preview {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--vb-radius-sm);
  background: var(--bg);
  padding: 4px;
}

/* ─── Brand Footer ─── */
.vb-brand-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

.vb-brand-footer svg,
.vb-brand-footer img {
  height: 14px;
  width: auto;
  opacity: 0.85;
}

.vb-brand-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.vb-brand-footer a:hover { color: var(--brand-blue); }

/* ─── DotsConnectGo wordmark ─── */
.dcg-wordmark {
  font-family: var(--vb-font);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.dcg-wordmark span { color: var(--brand-blue); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Print Styles ─── */
#vb-print-root { display: none; }

@media print {
  body > *:not(#vb-print-root) { display: none !important; }
  #vb-print-root { display: block !important; }

  .print-page {
    page-break-after: always;
    padding: 2rem;
    text-align: center;
  }

  .print-logos {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
  }

  .print-logo { max-height: 60px; max-width: 150px; }
  .print-org { font-size: 0.9rem; color: #666; margin-bottom: 0.5rem; }
  .print-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
  .print-meta { font-size: 0.85rem; color: #888; margin-bottom: 1.5rem; }

  .print-badge {
    display: inline-block;
    padding: 0.3rem 1rem;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
  }
  .print-badge-passed { background: #dcfce7; color: #166534; }
  .print-badge-failed { background: #fef2f2; color: #991b1b; }
  .print-badge-elected { background: #eef1ff; color: #353C85; }

  .print-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2rem;
    height: 250px;
    margin-top: 1rem;
  }

  .print-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 60px;
  }

  .print-bar-value { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.3rem; }
  .print-bar-track { flex: 1; width: 50px; display: flex; align-items: flex-end; }
  .print-bar-fill { width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; }
  .print-bar-label { margin-top: 0.5rem; font-size: 0.8rem; font-weight: 500; }
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .vb-container { padding: 1rem; }
  .vb-grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  .vb-bars { height: 200px; gap: 0.5rem; }
}
