/* ==========================================================================
   EquiFlow - Component Styles
   Cards, Badges, Buttons, Tables, Tabs, Inputs, Modals, Search Results
   ========================================================================== */

/* Search Autocomplete Dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 420px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  display: none;
}

.search-dropdown.active {
  display: block;
}

.search-dropdown-header {
  padding: 0.5rem 0.875rem;
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--transition-fast);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover, .search-result-item.highlighted {
  background-color: var(--bg-surface-hover);
}

.search-result-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--brand-primary);
  font-size: var(--text-base);
}

.search-result-name {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-left: 0.5rem;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.2;
}

.badge-primary {
  background-color: var(--brand-glow);
  color: var(--brand-primary);
}

.badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-danger {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-neutral {
  background-color: var(--bg-surface-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-reported {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-size: var(--text-2xs);
  padding: 0.1rem 0.35rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
}

.badge-calculated {
  background-color: rgba(168, 85, 247, 0.1);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.2);
  font-size: var(--text-2xs);
  padding: 0.1rem 0.35rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  box-shadow: 0 4px 12px var(--brand-glow);
}

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

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

.btn-outline {
  background-color: transparent;
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-outline:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: var(--text-xs);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

/* Cards */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

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

/* Metric Display Cards */
.metric-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-card-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.2;
}

.metric-card-subtext {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Financial Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
}

.financial-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  white-space: nowrap;
}

.financial-table th {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: right;
  padding: 0.65rem 1rem;
  border-bottom: 2px solid var(--border-default);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 2;
}

.financial-table th:first-child,
.financial-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background-color: var(--table-sticky-bg);
  z-index: 3;
  box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.1);
  font-weight: 500;
}

.financial-table th:first-child {
  z-index: 4;
}

.financial-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.financial-table tr:hover td {
  background-color: var(--table-hover);
}

.financial-table tr:nth-child(even) td {
  background-color: var(--table-stripe);
}

.financial-table tr:nth-child(even) td:first-child {
  background-color: var(--table-sticky-bg);
}

.table-row-clickable {
  cursor: pointer;
  user-select: none;
  transition: background-color var(--transition-fast);
}

.table-row-clickable:hover td,
.table-row-clickable:hover td:first-child {
  background-color: var(--table-hover) !important;
}

.table-row-clickable:active td,
.table-row-clickable:active td:first-child {
  background-color: var(--border-subtle) !important;
}

.row-highlight {
  font-weight: 700 !important;
  background-color: var(--bg-surface-muted) !important;
}

.row-highlight td {
  font-weight: 700 !important;
}

.unavailable-cell {
  color: var(--text-faint);
  font-style: italic;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
}

/* Tabs */
.tabs-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 1px;
}

.tab-btn {
  padding: 0.625rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.15s ease-in-out;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(10px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-dialog {
  transform: translateY(0);
}

.modal-dialog-large {
  max-width: 960px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-xs);
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-surface-subtle);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  animation: slideInRight 0.2s ease;
  min-width: 260px;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-success { border-left: 4px solid var(--color-success); }
.toast-error { border-left: 4px solid var(--color-danger); }
.toast-info { border-left: 4px solid var(--brand-primary); }
