/* ==========================================================================
   K-Weather Hub Design System & Global Styles
   ========================================================================== */

:root {
  --font-primary: 'Outfit', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Color Palette - Dark Glassmorphic Theme */
  --bg-primary: #0a0d14;
  --bg-secondary: rgba(18, 24, 38, 0.7);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-hover: rgba(255, 255, 255, 0.25);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-purple: #7f00ff;
  --accent-amber: #ffb199;
  --accent-green: #10b981;

  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --modal-backdrop: rgba(3, 7, 18, 0.82);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Dynamic Ambient Background Orbs */
.bg-gradient-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  transition: background 1.5s ease;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.35;
  animation: floatOrb 18s infinite alternate ease-in-out;
}

.orb-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #3b82f6 0%, #1d4ed8 100%);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #8b5cf6 0%, #6d28d9 100%);
  bottom: -150px;
  right: -100px;
  animation-delay: -6s;
}

.orb-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #06b6d4 0%, #0891b2 100%);
  top: 40%;
  left: 30%;
  animation-delay: -12s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 80px) scale(1.15); }
  100% { transform: translate(-40px, 40px) scale(0.9); }
}

/* Main Container Layout */
.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 30px 20px 50px;
}

/* ==========================================================================
   Header Section
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 25px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 25px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #00c6ff, #0072ff);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 198, 255, 0.4);
}

.logo-icon svg {
  width: 28px;
  height: 28px;
  stroke: #ffffff;
}

.app-title {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #a5f3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Live Clock Badge */
.live-clock-badge {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.88rem;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

/* Unit Toggle Switch */
.unit-toggle {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 30px;
  padding: 3px;
  display: flex;
  gap: 2px;
}

.unit-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition-fast);
}

.unit-btn.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

/* Refresh Button */
.refresh-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 8px 18px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  transition: var(--transition-normal);
}

.refresh-btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
  transform: translateY(-1px);
}

.refresh-btn.spinning #refreshIcon {
  animation: spin 0.8s linear infinite;
}

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

.refresh-btn .icon {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Stats Summary Bar
   ========================================================================== */
.stats-summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition-fast);
}

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

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.stat-value.time {
  font-size: 0.95rem;
  color: var(--accent-cyan);
}

/* ==========================================================================
   Search & Filter Controls Section
   ========================================================================== */
.controls-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  padding: 12px 42px 12px 46px;
  border-radius: 30px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: var(--transition-normal);
}

.search-box input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(79, 172, 254, 0.3);
}

.clear-search-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sort-select {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 25px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sort-select:hover, .sort-select:focus {
  border-color: var(--accent-cyan);
}

.sort-select option {
  background: #111827;
  color: #ffffff;
}

/* Status Message / Error Banner */
.status-message {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 25px;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-message.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.status-message.info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.status-message.hidden {
  display: none;
}

/* ==========================================================================
   Weather Cards Grid
   ========================================================================== */
.weather-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

/* Individual Weather Card */
.city-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition-normal);
  box-shadow: var(--card-shadow);
}

.city-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  opacity: 0;
  transition: var(--transition-fast);
}

.city-card:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
}

.city-card:hover::before {
  opacity: 1;
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.city-title-group h3 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.city-en-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.weather-icon-badge {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.weather-icon-badge img {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Main Temperature */
.card-temp-box {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.card-temp {
  font-size: 2.6rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -1px;
}

.card-weather-desc {
  font-size: 0.95rem;
  color: var(--accent-cyan);
  font-weight: 500;
}

.card-sub-temp {
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* Card Metrics Pills */
.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.metric-pill {
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.metric-pill .icon {
  font-size: 0.95rem;
}

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

.metric-pill .val {
  color: #ffffff;
  font-weight: 600;
  margin-left: auto;
}

/* Card Click Prompt Footer */
.card-action-hint {
  margin-top: 14px;
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  transition: var(--transition-fast);
}

.city-card:hover .card-action-hint {
  color: var(--accent-cyan);
}

/* Skeleton Loading State */
.skeleton-card {
  height: 240px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: loadingSkeleton 1.5s infinite;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
}

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

/* ==========================================================================
   Modal Dialog Layout
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--modal-backdrop);
  backdrop-filter: blur(18px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-container {
  background: #111827;
  border: 1px solid var(--glass-border-hover);
  border-radius: 24px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  padding: 32px;
  animation: modalPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.92) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 24px;
}

.modal-title-box h2 {
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-city-en {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.modal-weather-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid var(--glass-border);
}

.modal-weather-badge img {
  width: 40px;
  height: 40px;
}

.modal-weather-badge span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent-cyan);
}

/* Modal Overview Section */
.modal-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 25px;
  margin-bottom: 30px;
}

@media (max-width: 650px) {
  .modal-overview-grid {
    grid-template-columns: 1fr;
  }
}

.modal-main-temp {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.temp-big {
  font-size: 3.8rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
  margin-bottom: 10px;
}

.temp-sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.modal-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
}

.metric-icon {
  font-size: 1.4rem;
}

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.metric-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
}

/* Forecast Sections */
.forecast-section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hourly Forecast Horizontal Scroll */
.hourly-forecast-container {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-behavior: smooth;
}

.hourly-forecast-container::-webkit-scrollbar {
  height: 6px;
}

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

.hourly-item {
  min-width: 85px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

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

.hourly-item img {
  width: 36px;
  height: 36px;
}

.hourly-temp {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.hourly-pop {
  font-size: 0.72rem;
  color: var(--accent-blue);
  font-weight: 500;
}

/* 5-Day Forecast Rows */
.daily-forecast-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.daily-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.daily-date {
  font-weight: 600;
  font-size: 0.92rem;
  min-width: 90px;
}

.daily-condition {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 0 15px;
}

.daily-condition img {
  width: 34px;
  height: 34px;
}

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

.daily-temp-range {
  font-weight: 600;
  font-size: 0.92rem;
  color: #ffffff;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  margin-top: 50px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  border-top: 1px solid var(--glass-border);
  padding-top: 20px;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

.app-footer a:hover {
  color: var(--accent-cyan);
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .app-container {
    padding: 15px 12px 30px;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  .controls-section {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: 100%;
  }
  .modal-container {
    padding: 20px;
  }
}
