/* ==========================================================================
   KWEATHER Design System & Core Styles
   Aesthetic: Premium Glassmorphism, Rich Dark Mode, Vibrant Micro-interactions
   ========================================================================== */

:root {
  --font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  
  /* Color Tokens */
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #090d16 100%);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.12);
  --card-hover-bg: rgba(255, 255, 255, 0.09);
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #38bdf8;
  --accent-blue: #6366f1;
  --accent-purple: #a855f7;
  --accent-amber: #fbbf24;
  --accent-rose: #f43f5e;
  --accent-emerald: #10b981;

  --glass-effect: backdrop-filter: blur(16px) saturate(180%);
  --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);
}

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

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

/* Dynamic Weather Background Canvas/FX */
.weather-bg-fx {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15), transparent 40%),
              radial-gradient(circle at 80% 80%, rgba(56, 189, 248, 0.12), transparent 40%);
}

.app-container {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding: 20px 28px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.4);
}

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

.app-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(to right, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

/* Live Status & Last Updated */
.last-updated {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.825rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Temperature Unit Switch */
.unit-switch {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  padding: 4px;
  border-radius: 20px;
}

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

.unit-btn.active {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

/* Main Screen Home Button */
.btn-home {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.25));
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: 18px;
  text-decoration: none;
  transition: var(--transition-fast);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-home:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.45), rgba(168, 85, 247, 0.45));
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.btn-home svg {
  width: 18px;
  height: 18px;
  color: var(--accent-cyan);
}

/* Refresh Button */
.btn-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: 18px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--accent-cyan);
}

.btn-refresh svg {
  width: 18px;
  height: 18px;
  transition: transform 0.5s ease;
}

.btn-refresh:hover svg {
  transform: rotate(180deg);
}

/* Controls & Search */
.controls-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

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

.search-box input {
  width: 100%;
  padding: 14px 44px 14px 48px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

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

.clear-btn:hover {
  color: var(--text-primary);
}

/* Summary Pills */
.summary-pills {
  display: flex;
  gap: 12px;
}

.pill {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

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

.pill-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Notice Banner */
.notice-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: #e0f2fe;
}

.notice-banner .info-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

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

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

.weather-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  transition: transform 0.5s ease;
}

.weather-card:hover {
  transform: translateY(-6px);
  background: var(--card-hover-bg);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 20px rgba(56, 189, 248, 0.15);
}

.weather-card:hover::before {
  transform: scale(1.5);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.city-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.city-name-eng {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.weather-icon-wrapper {
  width: 54px;
  height: 54px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
  transition: transform 0.3s ease;
}

.weather-card:hover .weather-icon-wrapper {
  transform: scale(1.15) rotate(5deg);
}

.weather-icon-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-main-temp {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  margin: 16px 0 6px;
  background: linear-gradient(180deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.weather-desc {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-cyan);
  margin-bottom: 16px;
}

.card-footer-metrics {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.metric-inline {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Skeleton Loading */
.skeleton-card {
  height: 230px;
  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: skeleton-loading 1.5s infinite;
  pointer-events: none;
}

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

/* No Results */
.no-results {
  text-align: center;
  padding: 60px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
}

.no-results-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.no-results h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.no-results p {
  color: var(--text-secondary);
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Detail Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  padding: 32px;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-backdrop.active .modal-card {
  transform: scale(1);
}

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

.modal-close:hover {
  background: rgba(244, 63, 94, 0.3);
  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);
}

.modal-badge {
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.modal-title-box h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 4px;
}

.modal-title-box p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.modal-temp-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-weather-icon {
  width: 64px;
  height: 64px;
}

.modal-temp {
  font-size: 2.75rem;
  font-weight: 800;
  color: #ffffff;
}

.modal-weather-desc {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin: 20px 0;
  text-align: center;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

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

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

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

.metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Forecast Section */
.forecast-section {
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.forecast-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.forecast-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.forecast-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.forecast-day {
  font-weight: 600;
  width: 90px;
}

.forecast-desc {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  flex: 1;
}

.forecast-desc img {
  width: 32px;
  height: 32px;
}

.forecast-temps {
  font-weight: 700;
}

.forecast-max {
  color: var(--accent-amber);
}

.forecast-min {
  color: var(--accent-cyan);
  margin-left: 6px;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .header-actions {
    justify-content: space-between;
  }
  
  .controls-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  .summary-pills {
    justify-content: space-between;
  }
  
  .pill {
    flex: 1;
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
