/* ==========================================================================
   대한민국 로또6/45 종합 정보·분석 플랫폼 - 컴포넌트 스타일
   헤더, 푸터, Ball UI, 카드, 그리드, 폼, 테이블, 차트, 모달, 광고 컨테이너
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 헤더 & 내비게이션
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  transition: background-color 0.2s ease, border-color 0.2s ease;
  font-family: var(--font-family);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 0.75rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-family);
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  font-weight: 900;
  font-size: 0.95rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.65rem;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.92rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 38px;
}

.nav-link:hover {
  color: var(--primary);
  background-color: var(--bg-surface-hover);
  text-decoration: none;
}

.nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.mobile-menu-btn {
  display: none;
}

/* 모바일 드로어 */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-surface);
  z-index: 45;
  padding: 1.5rem;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  border-top: 1px solid var(--border-color);
}

.mobile-drawer.open {
  display: flex;
}

.mobile-drawer .nav-link {
  font-size: 1.1rem;
  padding: 0.85rem 1rem;
  min-height: 48px;
}

/* --------------------------------------------------------------------------
   2. 로또 볼 (Ball UI)
   -------------------------------------------------------------------------- */
.ball-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ball-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 24px;
  text-align: center;
}

.lotto-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  user-select: none;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

/* 크기 변형 */
.lotto-ball.ball-sm {
  width: 32px;
  height: 32px;
  font-size: 0.82rem;
}

.lotto-ball.ball-md {
  width: 42px;
  height: 42px;
  font-size: 1rem;
}

.lotto-ball.ball-lg {
  width: 50px;
  height: 50px;
  font-size: 1.2rem;
}

.lotto-ball.ball-xl {
  width: 60px;
  height: 60px;
  font-size: 1.4rem;
}

/* 볼 공식 색상 클래스 */
.ball-range-1 {
  background: var(--ball-1-10);
  color: var(--ball-1-10-text);
  box-shadow: 0 4px 10px var(--ball-1-10-shadow);
}

.ball-range-2 {
  background: var(--ball-11-20);
  color: var(--ball-11-20-text);
  box-shadow: 0 4px 10px var(--ball-11-20-shadow);
}

.ball-range-3 {
  background: var(--ball-21-30);
  color: var(--ball-21-30-text);
  box-shadow: 0 4px 10px var(--ball-21-30-shadow);
}

.ball-range-4 {
  background: var(--ball-31-40);
  color: var(--ball-31-40-text);
  box-shadow: 0 4px 10px var(--ball-31-40-shadow);
}

.ball-range-5 {
  background: var(--ball-41-45);
  color: var(--ball-41-45-text);
  box-shadow: 0 4px 10px var(--ball-41-45-shadow);
}

.ball-bonus-type {
  background: var(--ball-bonus);
  color: var(--ball-bonus-text);
  box-shadow: 0 4px 10px var(--ball-bonus-shadow);
  position: relative;
}

/* --------------------------------------------------------------------------
   3. 카드 컴포넌트 & 그리드
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.card-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.card-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* --------------------------------------------------------------------------
   4. 버튼 & 폼 컨트롤
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  min-height: 44px;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--border-color);
  text-decoration: none;
}

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

.btn-outline:hover:not(:disabled) {
  background-color: var(--primary-light);
  text-decoration: none;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  min-height: 36px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1.1rem;
  min-height: 52px;
  border-radius: var(--radius-md);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  min-height: 44px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

/* --------------------------------------------------------------------------
   5. 1~45 숫자 선택기 그리드
   -------------------------------------------------------------------------- */
.num-grid-45 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.num-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 44px;
  min-width: 44px;
}

.num-cell:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--primary);
}

.num-cell.selected {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 4px 10px var(--primary-glow);
}

/* --------------------------------------------------------------------------
   6. 뱃지 & 알림 & 결과 카드
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background-color: var(--bg-surface-hover);
  color: var(--text-secondary);
}

.badge-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-success { background-color: var(--accent-light); color: var(--accent); }
.badge-warning { background-color: #fef3c7; color: #b45309; }

.disclaimer-box {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 1.5rem 0;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.disclaimer-icon {
  color: var(--warning);
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* --------------------------------------------------------------------------
   7. 반응형 테이블
   -------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.table th, .table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  white-space: nowrap;
}

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

.table tr:hover td {
  background-color: var(--bg-surface-hover);
}

/* --------------------------------------------------------------------------
   8. Breadcrumb
   -------------------------------------------------------------------------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

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

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb-separator {
  color: var(--border-color);
}

/* --------------------------------------------------------------------------
   9. AdSense 광고 슬롯 컨테이너
   -------------------------------------------------------------------------- */
.ad-slot-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 2rem 0;
  padding: 1rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  border: 1px dashed var(--border-color);
  min-height: 100px;
  position: relative;
  overflow: hidden;
}

.ad-slot-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

/* --------------------------------------------------------------------------
   10. 모달 및 토스트
   -------------------------------------------------------------------------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #1e293b;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 110;
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
  opacity: 0;
  pointer-events: none;
}

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

/* --------------------------------------------------------------------------
   11. 푸터
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 3rem 0 2rem;
  margin-top: auto;
  color: var(--text-secondary);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.footer-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: var(--primary);
  text-decoration: none;
}

.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   12. 모바일 미디어 쿼리 최적화
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 960px) {
  .main-nav {
    display: none;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
}

@media (max-width: 768px) {
  .header-container {
    height: 56px;
  }
  .lotto-ball {
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
  }
  .ball-group {
    gap: 0.35rem;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* --------------------------------------------------------------------------
   13. 알림 박스 (Alert) & 로딩 스피너
   -------------------------------------------------------------------------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 0.92rem;
  line-height: 1.6;
}

.alert-success {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

[data-theme="dark"] .alert-success {
  background-color: rgba(6, 95, 70, 0.25);
  border-color: #059669;
  color: #6ee7b7;
}

.alert-danger {
  background-color: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

[data-theme="dark"] .alert-danger {
  background-color: rgba(153, 27, 27, 0.25);
  border-color: #dc2626;
  color: #fca5a5;
}

.alert-info {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

[data-theme="dark"] .alert-info {
  background-color: rgba(30, 64, 175, 0.25);
  border-color: #2563eb;
  color: #93c5fd;
}
