/**
 * Involio Trading Dashboard - Component Library
 * Modern, clean, professional UI components
 */

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-sm);
  font-weight: 500;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

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

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

/* Primary button */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border: none;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

/* Secondary button */
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

/* Ghost button */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--accent-primary);
}

/* Success button */
.btn-success {
  background: var(--success);
  color: white;
  border: none;
}

.btn-success:hover:not(:disabled) {
  background: #0d9668;
  box-shadow: 0 4px 12px var(--success-glow);
}

/* Danger button */
.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 4px 12px var(--danger-glow);
}

/* Size variants */
.btn-xs {
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-xs);
  border-radius: var(--radius-sm);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-lg);
}

/* Icon button */
.btn-icon, .icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover, .icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* =============================================================================
   CARDS
   ============================================================================= */

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

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

.card-body {
  padding: var(--space-5);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
}

/* Glass card */
.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);
}

/* Stat card */
.stat-card {
  padding: var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.stat-label {
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-1);
}

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

/* =============================================================================
   INPUTS
   ============================================================================= */

.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-md);
  font-family: inherit;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  outline: none;
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

.input-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

/* Select */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a1a1aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* =============================================================================
   BADGES
   ============================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.badge-default {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--accent-light);
  color: var(--accent-primary);
}

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

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

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

/* Trading badges */
.badge-long {
  background: var(--long-bg);
  color: var(--long);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-short {
  background: var(--short-bg);
  color: var(--short);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* =============================================================================
   NAVIGATION
   ============================================================================= */

.nav-menu {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  background: transparent;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.nav-menu::-webkit-scrollbar {
  display: none;
}

.nav-menu a {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}

.nav-menu a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-menu a.active {
  color: white;
  background: var(--accent-primary);
}

/* =============================================================================
   TOPBAR
   ============================================================================= */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* =============================================================================
   STATUS INDICATORS
   ============================================================================= */

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--danger);
  flex-shrink: 0;
  position: relative;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}

.status-dot.connecting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

/* =============================================================================
   THEME TOGGLE
   ============================================================================= */

.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
}

.theme-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.notification-toast {
  position: fixed;
  z-index: 10000;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight var(--duration-normal) var(--ease-out);
  font-weight: 500;
}

.notification-toast.success {
  border-left: 3px solid var(--success);
}

.notification-toast.error {
  border-left: 3px solid var(--danger);
}

.notification-toast.warning {
  border-left: 3px solid var(--warning);
}

/* =============================================================================
   LOADING STATES
   ============================================================================= */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

/* Skeleton */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    var(--bg-elevated) 50%,
    var(--bg-tertiary) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}

.skeleton-line:last-child {
  width: 60%;
}

/* =============================================================================
   TABLES
   ============================================================================= */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-sm);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-tertiary);
}

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

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

/* =============================================================================
   AVATARS
   ============================================================================= */

.avatar, .trade-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-sm);
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  flex-shrink: 0;
  overflow: hidden;
}

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

.avatar-sm, .trade-user-avatar {
  width: 32px;
  height: 32px;
  font-size: var(--font-xs);
}

/* =============================================================================
   EMPTY STATES
   ============================================================================= */

.empty-state, .empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
  text-align: center;
  color: var(--text-tertiary);
}

/* =============================================================================
   DIVIDERS
   ============================================================================= */

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}
/* =============================================================================
   AI ANALYSIS COMPONENTS
   ============================================================================= */

.ai-insights-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
  transition: all 0.3s ease;
}

.ai-collapsed {
  max-height: 48px;
}

.ai-insights-header {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.ai-insights-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--text-primary);
}

.ai-insights-badge {
  font-size: 10px;
  background: var(--accent-light);
  color: var(--accent-primary);
  padding: 1px 6px;
  border-radius: 4px;
}

.ai-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
}

.ai-stat-card {
  text-align: center;
  padding: var(--space-2);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.ai-stat-value {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.ai-stat-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.ai-stat-allow .ai-stat-value { color: var(--success); }
.ai-stat-caution .ai-stat-value { color: var(--warning); }
.ai-stat-block .ai-stat-value { color: var(--danger); }

.ai-quality-metrics {
  padding: 0 var(--space-4) var(--space-4);
}

.ai-metric {
  margin-bottom: var(--space-2);
}

.ai-metric-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.ai-metric-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.ai-metric-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.ai-metric-fill-danger { background: var(--danger); }
.ai-metric-fill-warning { background: var(--warning); }

/* AI Badges on Notifications */
.ai-badge-wrapper {
  margin-right: var(--space-2);
  display: inline-flex;
}

.ai-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  transition: transform 0.2s;
}

.ai-score-badge:hover {
  transform: scale(1.05);
}

.ai-badge-allow {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.ai-badge-caution {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.ai-badge-block {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.ai-badge-pending {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
}
