/**
 * High Velocity Labs Shared Design System (hvl-common)
 * File: /common/components.css
 * 
 * Canonical component classes across High Velocity Labs applications:
 * - highvelocitylabs.dev
 * - finances.highvelocitylabs.dev (HVL Family Office)
 * 
 * INVARIANT: Zero hardcoded hex codes. All styling strictly adheres to design tokens in theme.css.
 */

/* The hidden attribute always hides, even on elements whose class sets a display value (UI toggles use hidden) */
[hidden] {
    display: none !important;
}

/* ==========================================================================
   1. Typography & Prose Layout
   ========================================================================== */
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.micro-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.micro-label-flush {
  margin-bottom: 0;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hvl-container {
  width: 100%;
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 0 var(--shell-padding-x);
}

.hvl-prose-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--shell-padding-x);
}

.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);
}

/* ==========================================================================
   5. Canonical Badges & Semantic Status
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  max-width: 100%;
  box-sizing: border-box;
  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,
.badge-orange {
  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);
}

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

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

/* ==========================================================================
   8. Canonical SVG Icon Styling & Loading Overlays
   ========================================================================== */
.hvl-icon,
.icon {
  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:not([width]),
.icon:not([width]) {
  width: 1.25rem;
}

.hvl-icon:not([height]),
.icon:not([height]) {
  height: 1.25rem;
}

.hvl-icon.icon-xs,
.icon.icon-xs {
  width: 14px;
  height: 14px;
}

.hvl-icon.icon-sm,
.icon.icon-sm {
  width: 16px;
  height: 16px;
}

.hvl-icon.icon-md,
.icon.icon-md {
  width: 20px;
  height: 20px;
}

.hvl-icon.icon-lg,
.icon.icon-lg {
  width: 24px;
  height: 24px;
}

.hvl-icon.icon-xl,
.icon.icon-xl {
  width: 32px;
  height: 32px;
}

.btn-update-pill, .app-update-pill, #app-update-pill {
  background-color: var(--bg-surface);
  background: color-mix(in srgb, var(--accent-blue) 14%, var(--bg-surface));
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-badge);
  font-weight: 600;
  font-size: 0.75rem;
  height: var(--hvl-header-btn-height);
  min-height: var(--hvl-header-btn-height);
  padding: 0 10px;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  z-index: var(--z-popover);
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.btn-update-pill.is-inline, .app-update-pill.is-inline, #app-update-pill.is-inline {
  position: static;
  width: auto;
  margin: 0;
}

.btn-update-pill.is-flow, .app-update-pill.is-flow, #app-update-pill.is-flow {
  position: static;
  width: 100%;
  margin: 0 0 8px 0;
}

.btn-update-pill.is-fixed, .app-update-pill.is-fixed, #app-update-pill.is-fixed {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  margin: 0;
  z-index: var(--z-tooltip);
}

.btn-update-pill-reload {
  text-decoration: underline;
  font-weight: 700;
}

.btn-update-pill svg, .app-update-pill svg, #app-update-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.chart-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-surface);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-sm);
  z-index: 5;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}

.chart-loading-overlay.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  display: none !important;
}

.chart-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--brand-primary-border);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: chart-spin 0.8s linear infinite;
}

@keyframes chart-spin {
  to { transform: rotate(360deg); }
}

.chart-loading-text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Canonical Input & Code Overflow Guardrails
   Guarantees form controls and code elements never overflow cards or modals.
   ========================================================================== */
.hvl-settings-modal-dialog input,
.hvl-settings-modal-dialog textarea,
.hvl-settings-modal-dialog select,
.hvl-settings-modal-dialog code,
.modal-card input,
.modal-card textarea,
.modal-card select,
.modal-card code,
.stat-card input,
.stat-card textarea,
.stat-card select,
.stat-card code,
.hvl-subcard input,
.hvl-subcard textarea,
.hvl-subcard select,
.hvl-subcard code,
.card input,
.card textarea,
.card select,
.card code {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}

.hvl-settings-modal-dialog > *:not(.btn):not(.badge):not(button),
.modal-card > *:not(.btn):not(.badge):not(button),
.stat-card > *:not(.btn):not(.badge):not(button),
.hvl-subcard > *:not(.btn):not(.badge):not(button),
.card > *:not(.btn):not(.badge):not(button),
.hvl-settings-modal-dialog [style*="display: flex"] > *:not(.btn):not(.badge):not(button),
.hvl-settings-modal-dialog [style*="display:flex"] > *:not(.btn):not(.badge):not(button),
.modal-card [style*="display: flex"] > *:not(.btn):not(.badge):not(button),
.modal-card [style*="display:flex"] > *:not(.btn):not(.badge):not(button),
.stat-card [style*="display: flex"] > *:not(.btn):not(.badge):not(button),
.stat-card [style*="display:flex"] > *:not(.btn):not(.badge):not(button),
.hvl-subcard [style*="display: flex"] > *:not(.btn):not(.badge):not(button),
.hvl-subcard [style*="display:flex"] > *:not(.btn):not(.badge):not(button),
.card [style*="display: flex"] > *:not(.btn):not(.badge):not(button),
.card [style*="display:flex"] > *:not(.btn):not(.badge):not(button) {
  min-width: 0;
}

.hvl-endpoint-box {
  display: inline-block;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
#hvl-toast-container,
#fo-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 440px;
  pointer-events: none;
}

.hvl-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-bright);
  border-left: 4px solid var(--brand-primary);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  line-height: 1.45;
  transition: opacity 0.25s ease;
}

.hvl-toast-error {
  border-left-color: var(--status-red);
}

.hvl-toast-success {
  border-left-color: var(--status-green);
}

.hvl-toast.is-dismissing {
  opacity: 0;
}

@keyframes hvl-spin-360 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hvl-toast-spinner {
  animation: hvl-spin-360 0.8s linear infinite;
  transform-origin: center;
  flex-shrink: 0;
  color: var(--brand-primary);
  margin-top: 2px;
}

.hvl-toast-message {
  flex: 1;
  min-width: 0;
}

.hvl-toast-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}


