/**
 * High Velocity Labs Shared Design System (hvl-common)
 * File: /common/components.css
 * 
 * Canonical component classes across all High Velocity Labs applications:
 * - highvelocitylabs.dev (Main Apex / Studio / Legal)
 * - admin.highvelocitylabs.dev (Operations Portal)
 * - finances.highvelocitylabs.dev (AI Family Office)
 * - ff.highvelocitylabs.dev (Fantasy Assistant)
 * 
 * INVARIANT: Zero hardcoded hex codes. All styling strictly adheres to design tokens in theme.css.
 */

/* ==========================================================================
   1. Typography & Prose Layout
   ========================================================================== */
.hvl-prose-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.legal-section {
  margin-bottom: 2.5rem;
}

.legal-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.legal-section p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
  line-height: 1.65;
}

.legal-section ul {
  margin-left: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.65;
}

.legal-section li {
  margin-bottom: 0.4rem;
}

.legal-section strong {
  color: var(--text-primary);
}

.legal-section code {
  font-family: var(--font-mono);
  background: var(--bg-surface-elevated);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-badge);
  font-size: 0.85em;
  color: var(--brand-primary);
}

/* ==========================================================================
   2. Structural Layout & Shell
   ========================================================================== */
.hvl-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

.hvl-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}

.hvl-logo-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.hvl-logo-lockup:hover {
  color: var(--brand-primary);
}

.hvl-footer {
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0;
  margin-top: auto;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ==========================================================================
   3. Buttons & Action Triggers
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.25;
  user-select: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: var(--text-on-brand, white);
  border-color: var(--brand-primary);
  box-shadow: 0 1px 3px var(--brand-primary-glow);
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  color: var(--text-on-brand, white);
}

.btn-primary:active {
  background-color: var(--brand-primary-active);
  border-color: var(--brand-primary-active);
}

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-bright);
  color: var(--text-primary);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: calc(var(--radius-sm) - 2px);
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  aspect-ratio: 1 / 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   4. Surface Cards & KPI Tiles
   ========================================================================== */
.hvl-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.hvl-card:hover {
  border-color: var(--border-bright);
}

.card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.card-body {
  padding: 20px;
}

.kpi-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kpi-tile:hover {
  border-color: var(--border-bright);
}

.kpi-val {
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-lbl {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   5. Canonical Badges & Semantic Status
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-badge);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}

.badge-green {
  background-color: var(--status-green-bg);
  color: var(--status-green);
  border: 1px solid var(--status-green-border);
}

.badge-amber {
  background-color: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid var(--accent-amber-border);
}

.badge-blue {
  background-color: var(--brand-primary-bg);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
}

.badge-red {
  background-color: var(--status-red-bg);
  color: var(--status-red);
  border: 1px solid var(--status-red-border);
}

/* ==========================================================================
   6. Form & Input Controls
   ========================================================================== */
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-control,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px var(--brand-primary-border);
}

.form-control::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-control-sm {
  padding: 5px 10px;
  font-size: 0.8125rem;
  border-radius: calc(var(--radius-sm) - 2px);
}

/* Segmented Control Pill Group */
.segmented {
  display: inline-flex;
  padding: 3px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  gap: 2px;
}

.segment-btn {
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  background-color: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segment-btn:hover {
  color: var(--text-primary);
}

.segment-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   7. Modals & Dialog Overlays
   ========================================================================== */
.modal-overlay,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.25rem;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   8. Canonical SVG Icon Styling
   ========================================================================== */
.hvl-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.hvl-icon-xs { width: 0.75rem; height: 0.75rem; }
.hvl-icon-sm { width: 1rem; height: 1rem; }
.hvl-icon-md { width: 1.25rem; height: 1.25rem; }
.hvl-icon-lg { width: 1.5rem; height: 1.5rem; }
.hvl-icon-xl { width: 2rem; height: 2rem; }
