/* ==========================================================================
   HisaZangu — Component Library
   Reusable UI components: cards, buttons, badges, nav, forms, tables, etc.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-lg);
  padding: var(--space-6);
  transition:
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.card-interactive:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-6);
  transition:
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out);
}

.card-glass:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

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

.card-body {
  flex: 1;
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-default);
}

/* Gold accent border top */
.card-gold {
  border-top: 2px solid var(--gold);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition:
    background var(--duration) var(--ease-out),
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    color var(--duration) var(--ease-out);
  user-select: none;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Gold Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-hover) 100%);
  color: #0B0F1A;
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  box-shadow:
    var(--shadow-gold),
    0 0 30px rgba(245, 158, 11, 0.2);
  color: #0B0F1A;
}

.btn-primary:focus-visible {
  box-shadow:
    var(--shadow-gold),
    0 0 0 3px rgba(245, 158, 11, 0.3);
}

/* CTA with pulsing glow */
.btn-cta {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-hover) 100%);
  color: #0B0F1A;
  border-color: var(--gold);
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--border-radius-lg);
  animation: pulse-glow 2.5s ease-in-out infinite;
}

.btn-cta:hover {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  color: #0B0F1A;
  animation: none;
  box-shadow:
    0 0 20px rgba(245, 158, 11, 0.5),
    0 0 50px rgba(245, 158, 11, 0.2);
}

/* Gold (Nav & compact) */
.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-hover) 100%);
  color: #0B0F1A;
  border-color: var(--gold);
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  box-shadow: var(--shadow-gold);
  color: #0B0F1A;
}

/* Flash alerts */
.flash-alert {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  min-width: 320px;
  max-width: 600px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
}

.flash-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green);
}

.flash-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.flash-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  line-height: 1;
}

.flash-close:hover {
  opacity: 1;
}

/* Ghost / Secondary */
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

/* Outline Gold */
.btn-outline-gold {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold);
}

.btn-outline-gold:hover {
  background: rgba(245, 158, 11, 0.1);
  color: var(--gold-light);
  border-color: var(--gold-light);
}

/* Blue link-style button */
.btn-link {
  background: transparent;
  color: var(--blue);
  border: none;
  padding: var(--space-2) var(--space-3);
}

.btn-link:hover {
  color: var(--blue-light);
  text-decoration: underline;
}

/* Danger */
.btn-danger {
  background: var(--red);
  color: var(--text-primary);
  border-color: var(--red);
}

.btn-danger:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

/* Success */
.btn-success {
  background: var(--green);
  color: #0B0F1A;
  border-color: var(--green);
}

.btn-success:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

/* Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  border-radius: var(--border-radius-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
  border-radius: var(--border-radius-lg);
}

/* Icon-only button */
.btn-icon {
  padding: var(--space-3);
  border-radius: var(--border-radius);
  width: 40px;
  height: 40px;
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
  padding: var(--space-2);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--border-radius-full);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge-up,
.badge-profit,
.badge-green {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-down,
.badge-loss,
.badge-red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-neutral {
  background: rgba(156, 163, 175, 0.12);
  color: var(--text-secondary);
  border: 1px solid rgba(156, 163, 175, 0.2);
}

.badge-gold {
  background: rgba(245, 158, 11, 0.12);
  color: var(--gold);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-blue {
  background: rgba(59, 130, 246, 0.12);
  color: var(--blue);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* With arrow indicator */
.badge-up::before {
  content: '\25B2'; /* up triangle */
  font-size: 0.6em;
  margin-right: 2px;
}

.badge-down::before {
  content: '\25BC'; /* down triangle */
  font-size: 0.6em;
  margin-right: 2px;
}

/* --------------------------------------------------------------------------
   Navigation Bar — Visual overrides for Bootstrap 5 .navbar
   Layout is handled by Bootstrap (navbar-expand-lg, collapse, etc.)
   -------------------------------------------------------------------------- */
.navbar {
  z-index: var(--z-fixed);
  transition:
    background var(--duration-slow) var(--ease-out),
    backdrop-filter var(--duration-slow) var(--ease-out),
    box-shadow var(--duration-slow) var(--ease-out),
    border-color var(--duration-slow) var(--ease-out);
}

.nav-shell {
  min-height: 68px;
  display: flex;
  align-items: center;
}

.nav-spacer {
  height: 68px;
}

.navbar.nav-scrolled {
  background: rgba(11, 15, 26, 0.85) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-bottom: 1px solid var(--border-default) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.navbar-brand {
  text-decoration: none !important;
  color: var(--text-primary) !important;
}

.brand-wordmark {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.navbar-brand:hover,
.navbar-brand:focus {
  color: var(--text-primary) !important;
  text-decoration: none !important;
  opacity: 0.9;
}

.desktop-nav-wrap {
  min-height: 44px;
}

.desktop-nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-1);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-full);
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(10px);
}

.desktop-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 0 var(--space-4);
  border-radius: var(--border-radius-full);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition:
    color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.desktop-nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.desktop-nav-link.active {
  color: var(--gold);
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 4px var(--space-3) 4px 4px;
  border-radius: var(--border-radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  text-decoration: none;
}

.profile-chip:hover,
.profile-chip:focus {
  color: var(--text-primary);
}

.profile-chip img,
.profile-avatar-fallback {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.profile-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 158, 11, 0.2);
  color: var(--gold);
  font-weight: 700;
  font-size: var(--text-xs);
}

.profile-chip-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  font-weight: 600;
}

.navbar-dark .navbar-toggler {
  border: none;
  padding: var(--space-2);
}

.navbar-dark .navbar-toggler:focus {
  box-shadow: none;
}

/* Nav links styling */
.navbar-nav .nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--border-radius);
  transition:
    color var(--duration) var(--ease-out),
    background var(--duration) var(--ease-out);
  text-decoration: none;
}

.navbar-nav .nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.navbar-nav .nav-link.active {
  color: var(--gold);
}

/* Mobile offcanvas navigation */
@media (max-width: 991.98px) {
  .nav-shell {
    min-height: 62px;
  }

  .nav-spacer {
    height: 62px;
  }
}

.mobile-nav-panel {
  width: min(86vw, 360px) !important;
  background: rgba(11, 15, 26, 0.97) !important;
  border-left: 1px solid var(--border-default) !important;
}

.mobile-nav-panel .offcanvas-header {
  border-bottom: 1px solid var(--border-default);
  padding: var(--space-5);
}

.mobile-nav-panel .offcanvas-title {
  font-size: var(--text-base);
  font-weight: 700;
}

.mobile-user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
}

.mobile-nav-links {
  margin-top: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
}

.mobile-nav-link:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.mobile-nav-link.active {
  color: var(--gold);
  border-color: var(--border-active);
  background: rgba(245, 158, 11, 0.08);
}

/* Dropdown styling */
.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}

/* --------------------------------------------------------------------------
   Stock Row
   -------------------------------------------------------------------------- */
.stock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--border-radius);
  transition:
    background var(--duration) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.stock-row:hover {
  background: var(--bg-hover);
}

.stock-row:active {
  transform: scale(0.995);
}

.stock-row + .stock-row {
  border-top: 1px solid var(--border-default);
}

.stock-row-symbol {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-primary);
  min-width: 80px;
}

.stock-row-name {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-row-price {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-base);
  color: var(--text-primary);
  min-width: 100px;
  text-align: right;
}

.stock-row-change {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  min-width: 80px;
  text-align: right;
}

.stock-row-change.up   { color: var(--green); }
.stock-row-change.down { color: var(--red); }
.stock-row-change.flat { color: var(--text-tertiary); }

/* Mini chart area in stock row */
.stock-row-chart {
  width: 80px;
  height: 32px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Stat Card
   -------------------------------------------------------------------------- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition:
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out);
}

.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

.stat-card-icon.gold  { background: rgba(245, 158, 11, 0.12); color: var(--gold); }
.stat-card-icon.green { background: rgba(16, 185, 129, 0.12); color: var(--green); }
.stat-card-icon.red   { background: rgba(239, 68, 68, 0.12);  color: var(--red); }
.stat-card-icon.blue  { background: rgba(59, 130, 246, 0.12);  color: var(--blue); }

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-card-change {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-card-change.up   { color: var(--green); }
.stat-card-change.down { color: var(--red); }

/* --------------------------------------------------------------------------
   Form Inputs
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: 1.5;
  transition:
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    background var(--duration) var(--ease-out);
  appearance: none;
  -webkit-appearance: none;
}

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

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-hover);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
  background: var(--bg-card);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-helper {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--red);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: var(--space-10);
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Search Input
   -------------------------------------------------------------------------- */
.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: var(--text-base);
  width: 18px;
  height: 18px;
}

.search-input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-12);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-full);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition:
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    width var(--duration-slow) var(--ease-out);
}

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

.search-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.search-results-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  display: none;
  max-height: 340px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
}

.search-result-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-default);
}

.search-result-row:last-child {
  border-bottom: 0;
}

.search-result-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-2) 0;
  color: var(--text-primary);
}

.search-result-link:hover {
  color: var(--text-primary);
}

/* Keyboard shortcut hint */
.search-input-wrapper .search-shortcut {
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-default);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-default);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table thead {
  background: var(--bg-hover);
}

.table thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-default);
}

.table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

/* Striped rows */
.table-striped tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.table-striped tbody tr:nth-child(even):hover {
  background: var(--bg-hover);
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

/* Sortable column header */
.table th.sortable {
  cursor: pointer;
  user-select: none;
}

.table th.sortable:hover {
  color: var(--gold);
}

.table th.sortable::after {
  content: '\2195'; /* up-down arrow */
  margin-left: var(--space-2);
  font-size: 0.8em;
  opacity: 0.4;
}

.table th.sortable.sort-asc::after {
  content: '\25B2';
  opacity: 1;
  color: var(--gold);
}

.table th.sortable.sort-desc::after {
  content: '\25BC';
  opacity: 1;
  color: var(--gold);
}

/* Right-align numeric columns */
.table .text-right {
  text-align: right;
}

/* --------------------------------------------------------------------------
   Dropdown Menu
   -------------------------------------------------------------------------- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  padding: var(--space-2);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition:
    opacity var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out),
    visibility var(--duration);
}

.dropdown.open .dropdown-menu,
.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition:
    background var(--duration-fast),
    color var(--duration-fast);
  text-decoration: none;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item.active {
  color: var(--gold);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-2) 0;
}

/* --------------------------------------------------------------------------
   Alerts & Toasts
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--border-radius);
  border: 1px solid;
  font-size: var(--text-sm);
}

.alert-icon {
  flex-shrink: 0;
  font-size: var(--text-lg);
  line-height: 1;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.alert-dismiss {
  flex-shrink: 0;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity var(--duration-fast);
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font-size: var(--text-lg);
}

.alert-dismiss:hover {
  opacity: 1;
}

.alert-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
  color: var(--green);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--red);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.2);
  color: var(--gold);
}

.alert-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
  color: var(--blue);
}

/* Toast (slides in from top-right) */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 300px;
  max-width: 420px;
  animation: slideInRight 0.4s var(--ease-spring) both;
  font-size: var(--text-sm);
}

.toast-success { border-left: 3px solid var(--green); }
.toast-danger  { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--gold); }
.toast-info    { border-left: 3px solid var(--blue); }

.toast-close {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.5;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--text-lg);
  padding: 0;
  line-height: 1;
  transition: opacity var(--duration-fast);
}

.toast-close:hover {
  opacity: 1;
}

@media (max-width: 480px) {
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    top: var(--space-4);
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }
}

/* --------------------------------------------------------------------------
   Loading Spinner
   -------------------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-default);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* Full-page loader */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  background: var(--bg-primary);
}

.page-loader .spinner {
  width: 48px;
  height: 48px;
  border-width: 3px;
}

.page-loader-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Dot loading */
.loading-dots {
  display: inline-flex;
  gap: var(--space-2);
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: dot-pulse 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* --------------------------------------------------------------------------
   Avatar Circle
   -------------------------------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-weight: 600;
  flex-shrink: 0;
  border: 2px solid var(--border-default);
  transition: border-color var(--duration) var(--ease-out);
}

.avatar:hover {
  border-color: var(--gold);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-md { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar-xl { width: 72px; height: 72px; font-size: var(--text-xl); }

/* Avatar group (overlapping) */
.avatar-group {
  display: flex;
}

.avatar-group .avatar {
  margin-left: -8px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}

/* Status indicator on avatar */
.avatar-status {
  position: relative;
}

.avatar-status::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  background: var(--green);
}

.avatar-status.offline::after {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Mobile Bottom Tab Bar
   -------------------------------------------------------------------------- */
.bottom-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-fixed);
  background: rgba(11, 15, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-default);
  padding: var(--space-2) 0;
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
}

.bottom-tab-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.bottom-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--border-radius);
  transition:
    color var(--duration-fast),
    background var(--duration-fast);
  min-width: 56px;
  position: relative;
}

.bottom-tab-item .tab-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-tab-item:hover {
  color: var(--text-secondary);
}

.bottom-tab-item.active {
  color: var(--gold);
}

.bottom-tab-item.active::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--gold);
  border-radius: 0 0 2px 2px;
}

/* Notification dot on tab item */
.bottom-tab-item .tab-badge {
  position: absolute;
  top: 2px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}

.bottom-nav-indicator {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  background: rgba(11, 15, 26, 0.92);
}

.bottom-nav-indicator.htmx-request,
.htmx-request .bottom-nav-indicator {
  display: inline-flex;
}

@media (max-width: 768px) {
  .bottom-tab-bar {
    display: block;
  }

  /* Add padding to body so content doesn't hide behind tab bar */
  body.has-bottom-tabs {
    padding-bottom: 70px;
  }
}

/* --------------------------------------------------------------------------
   Divider
   -------------------------------------------------------------------------- */
.divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-4) 0;
}

.divider-gold {
  background: linear-gradient(
    90deg,
    transparent,
    var(--gold),
    transparent
  );
  height: 1px;
}

/* --------------------------------------------------------------------------
   Tooltip
   -------------------------------------------------------------------------- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-sm);
  font-size: var(--text-xs);
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: var(--z-tooltip);
  transition:
    opacity var(--duration-fast),
    transform var(--duration-fast);
  box-shadow: var(--shadow);
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.empty-state-icon {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 320px;
  margin-bottom: var(--space-6);
}

.watchlist-search-results {
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  max-height: 300px;
  overflow-y: auto;
}

.watch-toggle-btn {
  min-height: 34px;
}

.watch-toggle-btn .htmx-indicator {
  display: none;
  margin-right: var(--space-1);
}

.watch-toggle-btn.htmx-request .htmx-indicator,
.watch-toggle-btn.htmx-request.htmx-indicator {
  display: inline-flex;
  align-items: center;
}

.watch-toggle-btn.htmx-request .watch-toggle-label {
  display: none;
}

.watch-toggle-btn.htmx-request .htmx-indicator {
  margin-right: 0;
}

.tx-delete-btn .htmx-indicator {
  display: none;
}

.tx-delete-btn.htmx-request .htmx-indicator {
  display: inline-flex;
}

.tx-delete-btn.htmx-request .tx-delete-icon {
  display: none;
}

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-3);
}

.watchlist-item-card {
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  background: var(--bg-hover);
}

.watchlist-item-link {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}

.watchlist-item-link:hover {
  color: var(--text-primary);
}

.mobile-stock-row {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
}

.mobile-stock-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

@media (max-width: 768px) {
  .watchlist-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Chip / Tag
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: default;
  transition: all var(--duration-fast);
}

.chip-interactive {
  cursor: pointer;
}

.chip-interactive:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(245, 158, 11, 0.08);
}

.chip-active {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--gold);
  color: var(--gold);
}

/* --------------------------------------------------------------------------
   Progress Bar
   -------------------------------------------------------------------------- */
.progress {
  width: 100%;
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--border-radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--border-radius-full);
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transition: width var(--duration-slow) var(--ease-out);
}

.progress-bar.green {
  background: linear-gradient(90deg, var(--green-dark), var(--green));
}

.progress-bar.red {
  background: linear-gradient(90deg, var(--red-dark), var(--red));
}
