/*****************************
 * HeavyBroker Intake Form Styles
 * Dark theme with glassmorphism effects
 *****************************/

:root {
  /* Color Palette */
  --bg: #0b0f17;
  --bg-secondary: #0f1419;
  --panel: rgba(255, 255, 255, 0.06);
  --panel2: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.92);
  --text-secondary: rgba(255, 255, 255, 0.8);
  --muted: rgba(255, 255, 255, 0.65);
  --line: rgba(255, 255, 255, 0.12);
  --line-hover: rgba(255, 255, 255, 0.2);
  
  /* Accent Colors */
  --accent: #7c5cff;
  --accent-light: #9a7fff;
  --accent2: #2ee6a6;
  --accent2-dark: #25c48a;
  --danger: #ff4d6d;
  --danger-light: #ff6b85;
  --ok: #2ee6a6;
  --warning: #ffb347;
  
  /* Effects */
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 20px rgba(0, 0, 0, 0.3);
  --glow-accent: 0 0 20px rgba(124, 92, 255, 0.3);
  --glow-ok: 0 0 20px rgba(46, 230, 166, 0.3);
  
  /* Layout */
  --radius: 18px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --sidebar-width: 320px;
  --header-height: 70px;
  
  /* Typography */
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

html,
body {
  min-height: 100vh;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, 0.35), transparent 60%),
    radial-gradient(900px 500px at 100% 10%, rgba(46, 230, 166, 0.25), transparent 55%),
    radial-gradient(800px 600px at 40% 120%, rgba(124, 92, 255, 0.18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout Container */
.hb-wrap {
  width: min(1180px, 92vw);
  margin: 0 auto;
}

/* Header */
.hb-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  background: rgba(11, 15, 23, 0.85);
  border-bottom: 1px solid var(--line);
}

.hb-header .hb-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: var(--bg);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm), var(--glow-accent);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.2px;
  color: var(--text);
}

.brand-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Hero Section */
.hero {
  padding: 28px 0 20px;
}

.hero-card {
  padding: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card h1 {
  margin: 0 0 12px;
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 700;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}

.meta-row {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.meta-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  transition: var(--transition-fast);
}

.meta-pill:hover {
  border-color: var(--line-hover);
  background: rgba(255, 255, 255, 0.08);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 0 3px rgba(46, 230, 166, 0.2);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Main Content Layout */
.content {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 20px;
  padding: 16px 0 40px;
  align-items: start;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar .card {
  position: sticky;
  top: calc(var(--header-height) + 20px);
}

/* Cards */
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

.card:hover {
  border-color: var(--line-hover);
}

.card.subtle {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

.card.subtle:hover {
  border-color: var(--line);
}

/* Progress Bar */
.progress-only {
  padding: 16px;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

#progressPct {
  color: var(--accent2);
  font-weight: 700;
}

/* Table of Contents */
.toc {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc a {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  transition: var(--transition-fast);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toc a::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  transition: var(--transition-fast);
}

.toc a:hover {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
  padding-left: 16px;
}

.toc a:hover::before {
  background: var(--accent);
  transform: scale(1.5);
}

.toc a.active {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.4);
  background: rgba(124, 92, 255, 0.12);
  font-weight: 600;
}

.toc a.active::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Tips List */
.tips {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tips li {
  position: relative;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tips li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent2);
  font-weight: 700;
}

/* Form Area */
.form-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section {
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.section-head {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

/* Form Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field.full {
  grid-column: 1 / -1;
}

/* Labels */
label {
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.req {
  color: var(--accent2);
  font-weight: 700;
}

/* Form Controls */
input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15), var(--glow-accent);
  background: rgba(0, 0, 0, 0.35);
}

/* Select dropdown styling */
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

select option {
  background: var(--bg-secondary);
  color: var(--text);
  padding: 8px;
}

/* Textarea */
textarea {
  resize: vertical;
  min-height: 100px;
  max-height: 400px;
  line-height: 1.5;
}

/* Choices (Radio/Checkbox groups) */
.choices {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  transition: var(--transition-fast);
}

.choices:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.choices.multi {
  gap: 10px;
}

.choices.multi.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  user-select: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  transition: var(--transition-fast);
  border: 1px solid transparent;
}

.choice:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.choice input[type="radio"],
.choice input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.choice:has(input:checked) {
  color: var(--text);
  background: rgba(124, 92, 255, 0.1);
  border-color: rgba(124, 92, 255, 0.3);
}

/* Hidden fields */
.hidden {
  display: none !important;
}

/* Error messages */
.error {
  color: var(--danger);
  font-size: 12px;
  min-height: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.error::before {
  content: '⚠';
  font-size: 11px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  font-weight: 600;
  font-size: 13.5px;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.btn-primary {
  border-color: rgba(124, 92, 255, 0.5);
  background: linear-gradient(135deg, var(--accent) 0%, rgba(46, 230, 166, 0.6) 100%);
  color: var(--bg);
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(124, 92, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 25px rgba(124, 92, 255, 0.4);
  transform: translateY(-2px);
}

/* Submit Card */
.submit-card {
  padding: 20px;
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.08) 0%, var(--panel) 100%);
  border-color: rgba(124, 92, 255, 0.2);
}

.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.submit-row h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}

.submit-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  font-size: 13.5px;
}

/* Toast Notifications */
.toast {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(10px);
}

.toast.show {
  display: flex;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.ok {
  border-color: rgba(46, 230, 166, 0.4);
  background: rgba(46, 230, 166, 0.1);
  color: var(--accent2);
}

.toast.ok::before {
  content: '✓';
  font-weight: 700;
}

.toast.bad {
  border-color: rgba(255, 77, 109, 0.4);
  background: rgba(255, 77, 109, 0.1);
  color: var(--danger-light);
}

.toast.bad::before {
  content: '✕';
  font-weight: 700;
}

/* Preview Box */
.preview {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-secondary);
  overflow: auto;
  max-height: 400px;
  font-size: 12.5px;
  line-height: 1.6;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.preview.hidden {
  display: none;
}

/* Footer */
.hb-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  color: var(--muted);
  background: rgba(11, 15, 23, 0.6);
  backdrop-filter: blur(10px);
  margin-top: auto;
}

.hb-footer .hb-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

/* Responsive Design */
@media (max-width: 980px) {
  .content {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    order: 2;
  }
  
  .sidebar .card {
    position: relative;
    top: auto;
  }
  
  .toc {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .toc a {
    flex: 1;
    min-width: 140px;
    justify-content: center;
  }
}

@media (max-width: 720px) {
  :root {
    --radius: 14px;
    --radius-sm: 12px;
  }
  
  .hb-header .hb-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  
  .hero-card {
    padding: 20px;
  }
  
  .grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  
  .choices.multi.columns {
    grid-template-columns: 1fr;
  }
  
  .submit-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .submit-actions {
    width: 100%;
  }
  
  .btn {
    flex: 1;
  }
  
  .hb-footer .hb-wrap {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .hb-wrap {
    width: 96vw;
  }
  
  .card {
    padding: 16px;
  }
  
  .choice {
    padding: 10px;
    font-size: 13px;
  }
  
  input,
  select,
  textarea {
    padding: 14px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Print Styles */
@media print {
  .hb-header,
  .sidebar,
  .submit-actions,
  .btn {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .form-section {
    page-break-inside: avoid;
  }
}

/* Focus Visible for Accessibility */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --line: rgba(255, 255, 255, 0.3);
    --muted: rgba(255, 255, 255, 0.8);
  }
  
  .btn {
    border-width: 2px;
  }
}