/* --- Premium Design System for LUCKY LOTTO --- */

:root {
  /* Color Tokens */
  --bg-primary: #0a0e1a;
  --bg-secondary: #131b31;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --primary-accent: #6366f1; /* Indigo */
  --primary-accent-glow: rgba(99, 102, 241, 0.5);
  --secondary-accent: #ec4899; /* Pink */
  
  /* Glassmorphism Configuration */
  --glass-bg: rgba(15, 23, 42, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.15);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  /* Lotto Ball Colors (Korean Lottery Colors) */
  /* 1-10: Yellow */
  --lotto-yellow-color: #f59e0b;
  --lotto-yellow-highlight: #fef08a;
  --lotto-yellow-shadow: #b45309;
  
  /* 11-20: Blue */
  --lotto-blue-color: #3b82f6;
  --lotto-blue-highlight: #bfdbfe;
  --lotto-blue-shadow: #1d4ed8;

  /* 21-30: Red */
  --lotto-red-color: #ef4444;
  --lotto-red-highlight: #fecaca;
  --lotto-red-shadow: #b91c1c;

  /* 31-40: Gray */
  --lotto-gray-color: #6b7280;
  --lotto-gray-highlight: #e5e7eb;
  --lotto-gray-shadow: #374151;

  /* 41-45: Green */
  --lotto-green-color: #10b981;
  --lotto-green-highlight: #a7f3d0;
  --lotto-green-shadow: #047857;
  
  /* System Font Families */
  --font-display: 'Outfit', 'Noto Sans KR', sans-serif;
  --font-sans: 'Noto Sans KR', sans-serif;
}

/* Global Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background Glowing Orbs Decor */
.background-decor {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

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

.orb-1 {
  top: -10%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary-accent) 0%, transparent 80%);
  animation: orbFloat 25s infinite ease-in-out alternate;
}

.orb-2 {
  bottom: -10%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--secondary-accent) 0%, transparent 80%);
  animation: orbFloat 30s infinite ease-in-out alternate-reverse;
}

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

/* App Container Layout */
.app-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: calc(100vh - 60px);
}

/* Header Styling */
.app-header {
  text-align: center;
  margin-bottom: 1rem;
}

.logo-area {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4));
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #ffffff 40%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  gap: 0.3rem;
}

.logo-text .highlight {
  background: linear-gradient(135deg, var(--primary-accent) 0%, var(--secondary-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 10px rgba(99, 102, 241, 0.3));
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: -0.01em;
}

/* Card Common Style (Glassmorphism) */
.generator-card, .history-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
  padding: 2.5rem 2rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

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

/* Ball Display Area */
.display-container {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 18px;
  padding: 2.5rem 1rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.03);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.balls-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.placeholder-text {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: -0.01em;
  animation: pulseText 2s infinite ease-in-out;
}

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

/* The 3D Lotto Ball */
.lotto-ball {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  position: relative;
  box-shadow: 
    inset -4px -4px 12px rgba(0, 0, 0, 0.4),
    inset 4px 4px 12px rgba(255, 255, 255, 0.4),
    0 10px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: scale(0) rotate(-180deg);
}

.lotto-ball.animate {
  animation: ballBounceIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: var(--delay);
}

/* Korea Lotto Ball Color Styles */
.ball-yellow {
  background: radial-gradient(circle at 35% 35%, var(--lotto-yellow-highlight) 0%, var(--lotto-yellow-color) 60%, var(--lotto-yellow-shadow) 100%);
}
.ball-blue {
  background: radial-gradient(circle at 35% 35%, var(--lotto-blue-highlight) 0%, var(--lotto-blue-color) 60%, var(--lotto-blue-shadow) 100%);
}
.ball-red {
  background: radial-gradient(circle at 35% 35%, var(--lotto-red-highlight) 0%, var(--lotto-red-color) 60%, var(--lotto-red-shadow) 100%);
}
.ball-gray {
  background: radial-gradient(circle at 35% 35%, var(--lotto-gray-highlight) 0%, var(--lotto-gray-color) 60%, var(--lotto-gray-shadow) 100%);
}
.ball-green {
  background: radial-gradient(circle at 35% 35%, var(--lotto-green-highlight) 0%, var(--lotto-green-color) 60%, var(--lotto-green-shadow) 100%);
}

@keyframes ballBounceIn {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(-180deg) translateY(40px);
  }
  60% {
    opacity: 1;
    transform: scale(1.15) rotate(15deg) translateY(-8px);
  }
  85% {
    transform: scale(0.95) rotate(-5deg) translateY(3px);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg) translateY(0);
  }
}

/* Control Panel & Buttons */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.btn-generate {
  position: relative;
  width: 100%;
  padding: 1.25rem;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary-accent) 0%, var(--secondary-accent) 100%);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s ease;
}

.btn-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 50%,
    transparent 100%
  );
  transition: none;
}

.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn-generate:hover .btn-glow {
  animation: shine 1.5s infinite;
}

.btn-generate:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

.btn-generate:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.icon-spin {
  display: none;
}

/* Loading State for Button */
.btn-generate.loading {
  background: linear-gradient(135deg, #312e81 0%, #4c1d95 100%);
  cursor: wait;
  pointer-events: none;
}

.btn-generate.loading .icon-spin {
  display: block;
  animation: spin 1s linear infinite;
}

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

@keyframes shine {
  100% { left: 100%; }
}

/* Copy Button */
.btn-copy {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  padding: 0.85rem;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.btn-copy:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-copy:active:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.08);
}

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

/* History Section */
.history-section {
  padding: 2rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 1rem;
}

.section-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #ffffff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-clear:hover:not(:disabled) {
  color: var(--secondary-accent);
}

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

.history-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Custom Scrollbar for History Container */
.history-container::-webkit-scrollbar {
  width: 5px;
}

.history-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}

.history-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.history-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.empty-history {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 0;
  font-weight: 300;
}

/* History Item Card */
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 0.85rem 1.25rem;
  border-radius: 14px;
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: background-color 0.2s;
}

.history-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

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

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.history-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-display);
}

.history-balls {
  display: flex;
  gap: 6px;
}

/* Small ball inside history rows */
.lotto-ball-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.8rem;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: 
    inset -2px -2px 6px rgba(0, 0, 0, 0.4),
    inset 2px 2px 6px rgba(255, 255, 255, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Toast Styling */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(16, 185, 129, 0.9); /* Emerald Green */
  color: #ffffff;
  padding: 0.85rem 1.75rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
}

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

/* Footer Styling */
.app-footer {
  text-align: center;
  padding: 2rem 0;
  color: rgba(255, 255, 255, 0.15);
  font-size: 0.8rem;
  margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .app-container {
    padding-top: 2rem;
    gap: 1.5rem;
  }
  
  .logo-text {
    font-size: 2.1rem;
  }
  
  .generator-card {
    padding: 1.5rem 1.25rem;
  }
  
  .display-container {
    padding: 2rem 0.5rem;
  }
  
  .balls-wrapper {
    gap: 8px;
  }
  
  .lotto-ball {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }
  
  .history-section {
    padding: 1.5rem 1.25rem;
  }
  
  .history-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .history-meta {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
  }
}
