/* ==========================================================================
   Lotto 6/45 Generator Design System & Styles
   ========================================================================== */

:root {
  /* Color Palette - Dark Mode (Default) */
  --bg-color: #0b0f19;
  --bg-gradient: radial-gradient(circle at 50% 0%, #1a233a 0%, #0b0f19 75%);
  --card-bg: rgba(22, 31, 54, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.4);
  
  /* Lotto Ball Standard Colors */
  --ball-yellow-start: #ffeb3b;
  --ball-yellow-end: #f57f17;
  --ball-blue-start: #42a5f5;
  --ball-blue-end: #1565c0;
  --ball-red-start: #ef5350;
  --ball-red-end: #c62828;
  --ball-purple-start: #ab47bc;
  --ball-purple-end: #6a1b9a;
  --ball-green-start: #66bb6a;
  --ball-green-end: #2e7d32;

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-color: #f8fafc;
  --bg-gradient: radial-gradient(circle at 50% 0%, #e0e7ff 0%, #f8fafc 80%);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Pretendard', 'Outfit', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
}

/* Background Glow Effects */
.app-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: #6366f1;
  top: -100px;
  left: 20%;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: #ec4899;
  bottom: -150px;
  right: 10%;
}

.orb-3 {
  width: 350px;
  height: 350px;
  background: #f59e0b;
  top: 40%;
  left: -100px;
}

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 1080px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Glassmorphism Card */
.card-glass {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-ball {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--ball-yellow-start), var(--ball-yellow-end));
  color: #000;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.logo-text h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-text h1 span {
  color: var(--accent);
}

.logo-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 10px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* Main Layout Grid */
.main-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
}

@media (max-width: 868px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Panel Titles */
.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.panel-title i {
  color: var(--primary);
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-main);
}

/* Segmented Control (Game Count) */
.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

.seg-btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.seg-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-glow {
  position: relative;
  overflow: hidden;
  margin-top: 12px;
  padding: 16px;
  font-size: 1.05rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-main);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.badge {
  background: var(--accent);
  color: #000;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 4px;
}

/* Toggle Switches */
.filter-toggle-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
  padding: 14px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #475569;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Right Panel: Interactive 3D Stage */
.stage-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ball-machine {
  position: relative;
  width: 100%;
  height: 220px;
  background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--card-border);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.machine-sphere {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.02) 70%);
  box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.1), 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.glass-reflection {
  position: absolute;
  top: 10px;
  left: 20px;
  width: 50px;
  height: 25px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.4), transparent);
  border-radius: 50%;
  transform: rotate(-30deg);
  pointer-events: none;
}

.inner-balls {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Individual Floating Balls inside Machine */
.mini-ball {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.4);
  animation: floatBall 3s infinite ease-in-out alternate;
}

@keyframes floatBall {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(25px, -20px) scale(1.1); }
  100% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Extract Chute */
.extraction-chute {
  position: absolute;
  bottom: 10px;
  display: flex;
  justify-content: center;
}

.extracted-ball-spot {
  min-width: 48px;
  min-height: 48px;
}

/* Results Section */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.results-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 160px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  gap: 12px;
  text-align: center;
}

.empty-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}

/* Game Result Card */
.game-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.4s ease-out forwards;
}

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

.game-label {
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
  min-width: 60px;
}

.ball-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Lotto Ball 3D Styling */
.lotto-ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: inset -3px -3px 8px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.3);
  position: relative;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lotto-ball:hover {
  transform: scale(1.15) translateY(-2px);
}

/* Color Categories (Official Korean Lotto 6/45) */
.lotto-ball.b-yellow { background: radial-gradient(circle at 35% 35%, var(--ball-yellow-start), var(--ball-yellow-end)); color: #000; text-shadow: none; }
.lotto-ball.b-blue   { background: radial-gradient(circle at 35% 35%, var(--ball-blue-start), var(--ball-blue-end)); }
.lotto-ball.b-red    { background: radial-gradient(circle at 35% 35%, var(--ball-red-start), var(--ball-red-end)); }
.lotto-ball.b-purple { background: radial-gradient(circle at 35% 35%, var(--ball-purple-start), var(--ball-purple-end)); }
.lotto-ball.b-green  { background: radial-gradient(circle at 35% 35%, var(--ball-green-start), var(--ball-green-end)); }

.game-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Bottom Tabs Section */
.bottom-section {
  padding: 20px;
}

.tabs-header {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 12px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Stats Bars */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.stat-card {
  background: rgba(0,0,0,0.2);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .range {
  font-weight: 700;
  font-size: 0.85rem;
}

.stat-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.6s ease;
  border-radius: 4px;
}

.color-yellow .bar-fill { background: var(--ball-yellow-start); }
.color-blue .bar-fill   { background: var(--ball-blue-start); }
.color-red .bar-fill    { background: var(--ball-red-start); }
.color-purple .bar-fill { background: var(--ball-purple-start); }
.color-green .bar-fill  { background: var(--ball-green-start); }

.stat-card .count {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

/* Modal Overlay & Grid Picker */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mode-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.picker-ball {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.picker-ball:hover {
  transform: scale(1.1);
}

.picker-ball.selected-include {
  background: var(--ball-green-end);
  color: #fff;
  box-shadow: 0 0 10px rgba(67, 160, 71, 0.6);
  border-color: #a5d6a7;
}

.picker-ball.selected-exclude {
  background: var(--ball-red-end);
  color: #fff;
  box-shadow: 0 0 10px rgba(229, 57, 53, 0.6);
  border-color: #ef9a9a;
}

.selected-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.sum-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.text-success { color: #43a047; font-weight: 700; }
.text-danger  { color: #e53935; font-weight: 700; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 12px 0;
}
