/* ═══════════════════════════════════════════════════════════════
   WinGo Predictor Pro - Modern Dark Theme
   Palette: Volcanic Glass (#1A1A1A, #333333, #FF6B2B, #FFB088)
   Fonts: Orbitron (display) + Rajdhani (body)
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Core Colors */
  --bg-primary: #0D0D0D;
  --bg-secondary: #1A1A1A;
  --bg-tertiary: #252525;
  --bg-card: #1E1E1E;
  
  /* Accent Colors */
  --accent-primary: #FF6B2B;
  --accent-secondary: #FFB088;
  --accent-glow: rgba(255, 107, 43, 0.4);
  
  /* Semantic Colors */
  --big-color: #FF6B2B;
  --big-glow: rgba(255, 107, 43, 0.5);
  --small-color: #00D4AA;
  --small-glow: rgba(0, 212, 170, 0.5);
  --win-color: #00D4AA;
  --loss-color: #FF4757;
  
  /* Text Colors */
  --text-primary: #FFFFFF;
  --text-secondary: #B0B0B0;
  --text-muted: #707070;
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════
   BACKGROUND EFFECTS
   ═══════════════════════════════════════════════════════════════ */

.app-container {
  position: relative;
  min-height: 100vh;
  padding: var(--space-lg);
}

.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(255, 107, 43, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 107, 43, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 107, 43, 0.08) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 0;
  animation: glowPulse 8s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */

.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-xl);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 107, 43, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.logo-icon svg {
  width: 28px;
  height: 28px;
  color: var(--bg-primary);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-main {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.logo-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: -4px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: var(--transition-normal);
}

.status-dot.connected {
  background: var(--win-color);
  box-shadow: 0 0 10px var(--win-color);
}

.status-dot.connected::after {
  border-color: var(--win-color);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.error {
  background: var(--loss-color);
  box-shadow: 0 0 10px var(--loss-color);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
}

.status-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════ */

.main-content {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* ═══════════════════════════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════════════════════════ */

.section-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: var(--space-md);
}

/* ═══════════════════════════════════════════════════════════════
   MODE SELECTOR
   ═══════════════════════════════════════════════════════════════ */

.mode-section {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.mode-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  opacity: 0;
  transition: var(--transition-normal);
}

.mode-btn:hover {
  border-color: rgba(255, 107, 43, 0.3);
  transform: translateY(-2px);
}

.mode-btn.active {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(255, 107, 43, 0.15) 0%, rgba(255, 176, 136, 0.05) 100%);
}

.mode-btn.active::before {
  opacity: 0.1;
}

.mode-icon {
  font-size: 1.5rem;
  z-index: 1;
}

.mode-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 1;
}

.mode-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   PREDICTION CARD
   ═══════════════════════════════════════════════════════════════ */

.prediction-section {
  display: flex;
  justify-content: center;
}

.prediction-card {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 107, 43, 0.2);
  padding: var(--space-xl);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(255, 107, 43, 0.1);
  position: relative;
  overflow: hidden;
}

.prediction-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
}

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

.card-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.level-indicator {
  display: flex;
  gap: var(--space-xs);
}

.level-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: var(--transition-normal);
}

.level-dot.active {
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

.level-dot.active[data-level="2"] {
  background: #FFD700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.level-dot.active[data-level="3"] {
  background: #FF4757;
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.5);
}

/* ═══════════════════════════════════════════════════════════════
   PREDICTION DISPLAY
   ═══════════════════════════════════════════════════════════════ */

.prediction-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl) 0;
  position: relative;
}

.prediction-icon {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.prediction-icon svg {
  width: 100%;
  height: 100%;
  color: var(--text-muted);
}

.loading-ring {
  animation: rotate 2s linear infinite;
  transform-origin: center;
}

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

.prediction-icon.big-result {
  color: var(--big-color);
  filter: drop-shadow(0 0 30px var(--big-glow));
  animation: bigPulse 1s ease-in-out;
}

.prediction-icon.small-result {
  color: var(--small-color);
  filter: drop-shadow(0 0 30px var(--small-glow));
  animation: smallPulse 1s ease-in-out;
}

@keyframes bigPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes smallPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.prediction-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 4px;
}

.prediction-value.big-text {
  color: var(--big-color);
  text-shadow: 0 0 40px var(--big-glow);
}

.prediction-value.small-text {
  color: var(--small-color);
  text-shadow: 0 0 40px var(--small-glow);
}

.prediction-number {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ═══════════════════════════════════════════════════════════════
   CONFIDENCE BAR
   ═══════════════════════════════════════════════════════════════ */

.confidence-bar {
  margin-top: var(--space-lg);
}

.confidence-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.confidence-value {
  font-family: 'Orbitron', sans-serif;
  font-weight: 600;
  color: var(--accent-primary);
}

.confidence-track {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border-radius: var(--radius-xl);
  transition: width 0.5s ease;
  position: relative;
}

.confidence-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ═══════════════════════════════════════════════════════════════
   PREDICTION STATUS
   ═══════════════════════════════════════════════════════════════ */

.prediction-status {
  margin-top: var(--space-md);
  text-align: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-xl);
  font-size: 0.875rem;
  font-weight: 500;
}

.status-badge.waiting {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.status-badge.analyzing {
  background: rgba(255, 107, 43, 0.15);
  color: var(--accent-primary);
  animation: analyzingPulse 1.5s ease-in-out infinite;
}

@keyframes analyzingPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   STATISTICS
   ═══════════════════════════════════════════════════════════════ */

.stats-section {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--bg-tertiary);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition-normal);
}

.stat-card:hover {
  border-color: rgba(255, 107, 43, 0.2);
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   HISTORY TABLE
   ═══════════════════════════════════════════════════════════════ */

.history-section {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.history-table th {
  background: var(--bg-secondary);
  padding: var(--space-md);
  text-align: left;
  font-family: 'Orbitron', sans-serif;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-table td {
  padding: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

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

.history-table tr:hover {
  background: rgba(255, 107, 43, 0.05);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-big {
  background: rgba(255, 107, 43, 0.2);
  color: var(--big-color);
}

.badge-small {
  background: rgba(0, 212, 170, 0.2);
  color: var(--small-color);
}

.badge-win {
  background: rgba(0, 212, 170, 0.2);
  color: var(--win-color);
}

.badge-loss {
  background: rgba(255, 71, 87, 0.2);
  color: var(--loss-color);
}

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-normal);
  padding: var(--space-lg);
}

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

.modal-content {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 107, 43, 0.3);
  padding: var(--space-xl);
  max-width: 420px;
  width: 100%;
  transform: scale(0.9) translateY(20px);
  transition: var(--transition-normal);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
}

.modal-overlay.show .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.win-icon, .loss-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.modal-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.win-modal .modal-title {
  color: var(--win-color);
}

.loss-modal .modal-title {
  color: var(--loss-color);
}

.modal-body {
  margin-bottom: var(--space-xl);
}

.result-comparison {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.result-item {
  text-align: center;
}

.result-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-xs);
}

.result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 1rem;
}

.result-badge.big {
  background: rgba(255, 107, 43, 0.2);
  color: var(--big-color);
  border: 1px solid var(--big-color);
}

.result-badge.small {
  background: rgba(0, 212, 170, 0.2);
  color: var(--small-color);
  border: 1px solid var(--small-color);
}

.result-vs {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.period-info {
  display: flex;
  justify-content: space-around;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.period-info strong {
  color: var(--text-primary);
  font-family: 'Orbitron', sans-serif;
}

.recovery-message {
  text-align: center;
  padding: var(--space-md);
  background: rgba(255, 71, 87, 0.1);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 71, 87, 0.2);
}

.recovery-message span {
  display: block;
  font-size: 0.875rem;
  color: var(--loss-color);
  margin-bottom: var(--space-sm);
}

.level-progress {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.level-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--loss-color) 0%, #FFD700 100%);
  border-radius: var(--radius-xl);
  transition: width 0.5s ease;
}

.modal-close {
  width: 100%;
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: var(--bg-primary);
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition-normal);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.modal-close.loss-close {
  background: linear-gradient(135deg, var(--loss-color) 0%, #FF6B6B 100%);
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.mode-section, .prediction-section, .stats-section, .history-section {
  animation: fadeIn 0.5s ease forwards;
}

.mode-section { animation-delay: 0.1s; }
.prediction-section { animation-delay: 0.2s; }
.stats-section { animation-delay: 0.3s; }
.history-section { animation-delay: 0.4s; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .app-container {
    padding: var(--space-md);
  }
  
  .logo-main {
    font-size: 1.25rem;
  }
  
  .prediction-value {
    font-size: 2rem;
  }
  
  .prediction-icon {
    width: 100px;
    height: 100px;
  }
  
  .mode-buttons {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */

.hidden {
  display: none !important;
}

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