/**
 * BB Tracker - Main Styles
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  --color-bg: #0a0a0a;
  --color-surface: #171717;
  --color-surface-2: #262626;
  --color-border: #404040;
  --color-text: #e5e5e5;
  --color-text-muted: #a3a3a3;
  --color-text-dim: #737373;
  --color-primary: #10b981;
  --color-primary-light: #34d399;
  --color-warning: #f59e0b;
  --color-warning-light: #fbbf24;
  --color-danger: #ef4444;
  --color-danger-light: #f87171;
  --color-info: #3b82f6;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-surface-2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-border);
}

/* Selection */
::selection {
  background-color: var(--color-surface-2);
  color: white;
}

/* ============================================
   GLASS PANEL
   ============================================ */
.glass-panel {
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(38, 38, 38, 0.5);
}

/* ============================================
   FORMS
   ============================================ */
.form-input {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-surface-2);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  color: var(--color-text);
  font-size: 1rem;
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

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

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: white;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-surface-2);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
}

.btn-success {
  background: var(--color-primary);
  color: white;
}

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-surface-2);
  border-radius: 1rem;
  padding: 1.5rem;
}

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

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
}

/* ============================================
   STATUS BADGES
   ============================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-healthy {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-primary-light);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-moderate {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning-light);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-risk {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ============================================
   XP BADGES
   ============================================ */
.xp-badge {
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid transparent;
}

.xp-10 {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.3);
}

.xp-30 {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.3);
}

.xp-50 {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.3);
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
  overflow-x: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--color-surface-2);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background: var(--color-surface);
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-dim);
  border-bottom: 1px solid var(--color-surface-2);
}

.table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-surface-2);
}

.table tr:hover {
  background: rgba(38, 38, 38, 0.3);
}

.table tr:last-child td {
  border-bottom: none;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(4px);
  transition: opacity 0.3s;
}

.modal-content {
  width: 100%;
  max-width: 24rem;
  background: var(--color-surface);
  border: 1px solid var(--color-surface-2);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  padding: 1.5rem;
  transform: scale(0.95);
  transition: transform 0.3s;
}

.modal-overlay:not(.hidden) .modal-content {
  transform: scale(1);
}

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-surface-2);
  border-radius: 1.5rem;
  padding: 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.auth-logo-icon {
  font-size: 2.5rem;
  color: var(--color-warning-light);
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
}

.auth-logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
}

.auth-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}

.auth-link {
  color: var(--color-primary-light);
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-primary-light);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning-light);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ============================================
   CALENDAR
   ============================================ */
.calendar-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.375rem;
  transition: all 0.2s;
  overflow: hidden;
}

.calendar-cell-active {
  background: rgba(23, 23, 23, 0.3);
  border: 1px solid rgba(38, 38, 38, 0.5);
  cursor: pointer;
}

.calendar-cell-active:hover {
  background: var(--color-surface-2);
}

.calendar-cell-today {
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.calendar-cell-weekend {
  background: rgba(10, 10, 10, 0.3);
  border: 1px solid var(--color-surface);
  opacity: 0.6;
}

.calendar-cell-future {
  background: rgba(10, 10, 10, 0.2);
  border: 1px solid rgba(38, 38, 38, 0.3);
  opacity: 0.7;
}

.calendar-day {
  font-size: 10px;
  font-weight: 600;
}

.calendar-pnl {
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  align-self: flex-end;
  margin-top: auto;
}

.calendar-pnl-positive {
  color: var(--color-primary-light);
}

.calendar-pnl-negative {
  color: var(--color-danger-light);
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
  display: none !important;
}

.text-primary {
  color: var(--color-primary-light);
}

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

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

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

.text-dim {
  color: var(--color-text-dim);
}

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

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

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .auth-card {
    padding: 1.5rem;
  }

  .card {
    padding: 1rem;
  }
}

/* ============================================
   EVENT TYPE BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-fomc {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.badge-cpi {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.2);
}

.badge-nfp {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.2);
}

.badge-other {
  background: rgba(107, 114, 128, 0.1);
  color: #9ca3af;
  border-color: rgba(107, 114, 128, 0.2);
}

/* ============================================
   IMPACT LEVEL BADGES
   ============================================ */
.badge-impact-high {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.badge-impact-medium {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.2);
}

.badge-impact-low {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.2);
}

/* ============================================
   ICON UTILITIES
   ============================================ */
.icon-xs {
  font-size: 0.75rem;
}

.icon-sm {
  font-size: 0.875rem;
}

.icon-md {
  font-size: 1rem;
}

.icon-lg {
  font-size: 1.5rem;
}

.icon-xl {
  font-size: 2rem;
}

.icon-spaced {
  margin-right: 0.5rem;
}

.icon-spaced-sm {
  margin-right: 0.25rem;
}

/* ============================================
   FLEX UTILITIES
   ============================================ */
.flex-1 {
  flex: 1;
}

.font-bold {
  font-weight: 700;
}

/* ============================================
   LOADING OVERLAY & SPINNER
   ============================================ */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

/* Button loading state */
.btn.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-top: -8px;
  margin-left: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn.loading > * {
  visibility: hidden;
}

/* Table loading skeleton */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-1) 25%,
    var(--color-surface-2) 50%,
    var(--color-surface-1) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Inline loading indicator */
.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-dim);
}

.loading-inline::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-surface-2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   GOLDEN CLOVER & SPARKLE ANIMATION
   ============================================ */
.clover-container {
  position: relative;
  display: inline-block;
}

.gold-clover {
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
}

.sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: sparkle-anim 2s infinite ease-in-out;
}

.sparkle:nth-child(2) {
  top: 0;
  right: 0;
  animation-delay: 0.5s;
  width: 3px;
  height: 3px;
}

.sparkle:nth-child(3) {
  bottom: 10%;
  left: 10%;
  animation-delay: 1.2s;
  width: 2px;
  height: 2px;
}

@keyframes sparkle-anim {
  0%, 100% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.5); opacity: 0.8; box-shadow: 0 0 4px #fff; }
}

/* ============================================
   SIMULATOR INPUT STYLES
   ============================================ */
.sim-input {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0 4px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #e5e5e5;
  transition: all 0.2s;
}

.sim-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.1);
}

/* Remove number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ============================================
   MINIMAL SELECT DROPDOWN
   ============================================ */
.minimal-select {
  background: transparent;
  color: #d4d4d4;
  font-weight: 600;
  font-size: 0.75rem;
  border: none;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.5rem;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.minimal-select option {
  background: #171717;
  color: #d4d4d4;
  font-size: 0.875rem;
  padding: 8px;
}

/* ============================================
   PORTFOLIO DROPDOWN (Styled)
   ============================================ */
.portfolio-dropdown-wrapper {
  position: relative;
  width: 100%;
}

.portfolio-dropdown {
  width: 100%;
  background: linear-gradient(135deg, rgba(23, 23, 23, 0.9), rgba(38, 38, 38, 0.6));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 0.75rem;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.portfolio-dropdown:hover {
  border-color: rgba(139, 92, 246, 0.6);
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(45, 45, 45, 0.6));
}

.portfolio-dropdown:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.portfolio-dropdown option {
  background: #171717;
  color: #d4d4d4;
  font-size: 0.875rem;
  padding: 12px;
}

.portfolio-dropdown-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #a78bfa;
  font-size: 1.25rem;
  pointer-events: none;
  transition: color 0.2s ease;
}

.portfolio-dropdown:hover + .portfolio-dropdown-icon {
  color: #c4b5fd;
}

/* ============================================
   SETUP BUTTONS (for v8 Lot Selector)
   ============================================ */
.setup-btn {
  transition: all 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.setup-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.setup-btn.active {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.setup-btn.active-warn {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.setup-btn.active-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* ============================================
   BREATHING RED ANIMATION
   ============================================ */
@keyframes breathe-red {
  0% { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2); }
  50% { border-color: rgba(239, 68, 68, 1); box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.5); }
  100% { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2); }
}

.animate-breathe-red {
  animation: breathe-red 2s infinite ease-in-out;
  border-width: 1px;
  border-style: solid;
}

/* ============================================
   STATUS PENDING
   ============================================ */
.status-pending {
  background: rgba(115, 115, 115, 0.1);
  border-color: rgba(115, 115, 115, 0.2);
}

/* ============================================
   PROFIT FLOATING ANIMATION
   ============================================ */
@keyframes float-up-bounce {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  40% { transform: translate(-50%, -150%) scale(1.2); opacity: 1; }
  60% { transform: translate(-50%, -150%) scale(1.1); }
  80% { transform: translate(-50%, -150%) scale(1.15); }
  100% { transform: translate(-50%, -350%) scale(1); opacity: 0; }
}

@keyframes spin-y {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

.profit-float-anim {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 100;
  animation: float-up-bounce 2.5s ease-out forwards;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.animate-spin-coin {
  animation: spin-y 1.5s linear infinite;
  display: inline-block;
  filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.5));
}

.profit-text-gradient {
  background: linear-gradient(to bottom, #fbbf24, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
  font-size: 3rem;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
