@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Design Tokens ─── */
:root {
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-900: #18181b;
  --zinc-950: #09090b;
  --red-500: #ef4444;
  --green-500: #22c55e;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --slate-600: #475569;
  --slate-700: #334155;
  --white: #ffffff;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 15px;
  --fs-xl: 22px;
  --fs-2xl: 24px;
  --fs-hero: 72px;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --space-1: 4px;
  --space-1h: 6px;
  --space-2: 8px;
  --space-2h: 10px;
  --space-3: 12px;
  --space-3h: 14px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-10: 40px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-phone: 44px;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-elevated: 0 8px 24px rgba(37,99,235,0.25);
  --shadow-phone: 0 30px 80px rgba(0,0,0,0.25);

  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --easing-default: cubic-bezier(0.4, 0, 0.2, 1);
  --easing-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: var(--font-family);
  background: var(--zinc-100);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  -webkit-font-smoothing: antialiased;
}

/* ─── Device Frame ─── */
.phone {
  width: 390px;
  min-height: 844px;
  background: var(--white);
  border-radius: var(--radius-phone);
  border: 10px solid var(--zinc-900);
  overflow: hidden;
  box-shadow: var(--shadow-phone);
  position: relative;
  display: flex;
  flex-direction: column;
}

.notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 28px;
  background: var(--zinc-900);
  border-radius: 0 0 18px 18px;
  z-index: 10;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px 8px;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--zinc-950);
  flex-shrink: 0;
}

.status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.home-indicator {
  display: flex;
  justify-content: center;
  padding: 8px 0 6px;
  background: var(--white);
  flex-shrink: 0;
}

.indicator-bar {
  width: 120px;
  height: 4px;
  background: var(--zinc-950);
  border-radius: 2px;
}

/* ─── App Header ─── */
.app-header {
  padding: 20px 24px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--zinc-950);
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--blue-600);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: var(--fs-md);
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--zinc-200);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--zinc-600);
  position: relative;
  transition: background var(--duration-fast) var(--easing-default);
}

.icon-btn:hover { background: var(--zinc-100); }
.icon-btn:active { transform: scale(0.95); }

.icon-btn.user-btn {
  background: var(--blue-600);
  color: var(--white);
  border-color: var(--blue-600);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  font-family: var(--font-family);
}

.icon-btn.user-btn:hover {
  background: var(--blue-700);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}

.notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: var(--red-500);
  border-radius: 50%;
}

/* ─── User Dropdown ─── */
.user-dropdown {
  position: absolute;
  top: 44px;
  right: 0;
  background: var(--white);
  border: 1px solid var(--zinc-200);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 140px;
  z-index: 50;
  display: none;
  overflow: hidden;
}

.user-dropdown.open { display: block; }

.user-dropdown-item {
  padding: 10px 14px;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--zinc-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--duration-fast) var(--easing-default);
}

.user-dropdown-item:hover {
  background: var(--zinc-100);
  color: var(--zinc-900);
}

/* ─── Location Bar ─── */
.location-bar {
  padding: 8px 24px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--zinc-600);
}

.location-text {
  font-size: var(--fs-base);
  color: var(--zinc-600);
}

.location-text strong {
  color: var(--zinc-950);
  font-weight: var(--fw-semibold);
}

/* ─── Hero Card ─── */
.hero-card {
  margin: 0 16px;
  background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-800) 100%);
  border-radius: var(--radius-xl);
  padding: 24px;
  color: var(--white);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.hero-card.stale {
  background: linear-gradient(135deg, var(--slate-600) 0%, var(--slate-700) 100%);
  box-shadow: 0 8px 24px rgba(71,85,105,0.25);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  position: relative;
}

.condition-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.condition-badge .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.condition-badge .badge-dot.live { background: var(--green-500); }
.condition-badge .badge-dot.stale { background: var(--amber-500); }

.weather-icon-large {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.temp-display {
  position: relative;
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.temp-value {
  font-size: var(--fs-hero);
  font-weight: var(--fw-bold);
  letter-spacing: -3px;
  line-height: 1;
}

.temp-unit {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  margin-top: 8px;
}

.temp-toggle {
  margin-top: 8px;
  margin-left: 4px;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  font-family: var(--font-family);
  transition: background var(--duration-fast) var(--easing-default);
}

.temp-toggle:hover { background: rgba(255,255,255,0.3); }
.temp-toggle:active { transform: scale(0.95); }

.condition-text {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  opacity: 0.9;
  margin-bottom: 16px;
}

.feels-like {
  font-size: var(--fs-sm);
  opacity: 0.75;
  position: relative;
}

/* ─── Stats Grid ─── */
.stats-section {
  padding: 20px 16px 12px;
}

.section-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--zinc-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding: 0 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--zinc-200);
  border-radius: var(--radius-lg);
  padding: 14px;
  transition: border-color var(--duration-fast) var(--easing-default);
}

.stat-card:hover {
  border-color: var(--zinc-400);
}

.stat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--zinc-500);
  margin-bottom: 8px;
  font-weight: var(--fw-medium);
}

.stat-header svg { color: var(--blue-600); }

.stat-value {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--zinc-950);
  letter-spacing: -0.5px;
}

.stat-sub {
  font-size: var(--fs-xs);
  color: var(--zinc-500);
  margin-top: 2px;
}

/* ─── Refresh Card ─── */
.refresh-section {
  padding: 16px;
  margin-top: 4px;
}

.refresh-card {
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--duration-fast) var(--easing-default);
}

.refresh-card:hover { background: var(--zinc-100); }

.update-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.update-label {
  font-size: var(--fs-xs);
  color: var(--zinc-500);
  font-weight: var(--fw-medium);
}

.update-time {
  font-size: var(--fs-base);
  color: var(--zinc-950);
  font-weight: var(--fw-semibold);
}

.refresh-btn {
  background: var(--blue-600);
  color: var(--white);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-family);
  transition: background var(--duration-fast) var(--easing-default);
}

.refresh-btn:hover { background: var(--blue-700); }
.refresh-btn:active { transform: scale(0.97); }
.refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ─── Tab Bar ─── */
.tab-bar {
  display: flex;
  padding: 12px 16px 24px;
  gap: 4px;
  border-top: 1px solid var(--zinc-100);
  background: var(--white);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  font-size: var(--fs-xs);
  color: var(--zinc-500);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: color var(--duration-fast) var(--easing-default);
}

.tab:hover { opacity: 0.8; }
.tab:active .tab-icon-wrap { transform: scale(0.9); }
.tab.active { color: var(--blue-600); }

.tab-icon-wrap {
  transition: transform var(--duration-fast) var(--easing-default);
}

/* ─── Screen Shell ─── */
.screen-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.screen-content::-webkit-scrollbar { width: 0; }

/* ─── Login Screen ─── */
.login-screen {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 60px 24px 24px;
  background: var(--white);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: var(--blue-600);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.login-logo-text {
  font-size: 24px;
  font-weight: var(--fw-bold);
  color: var(--zinc-950);
}

.login-subtitle {
  font-size: var(--fs-base);
  color: var(--zinc-500);
  text-align: center;
}

.user-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--zinc-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-default);
}

.user-card:hover {
  border-color: var(--zinc-400);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.user-card.selected {
  border-color: var(--blue-600);
  background: rgba(37,99,235,0.04);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  flex-shrink: 0;
}

.user-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-card-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--zinc-900);
}

.user-card-role {
  font-size: var(--fs-sm);
  color: var(--zinc-500);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--blue-600);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  font-family: var(--font-family);
  transition: all var(--duration-fast) var(--easing-default);
}

.login-btn:hover { background: var(--blue-700); }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled {
  background: var(--zinc-200);
  color: var(--zinc-400);
  cursor: not-allowed;
  transform: none;
}

/* ─── Permission Screen ─── */
.permission-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 24px;
  text-align: center;
}

.permission-icon {
  width: 96px;
  height: 96px;
  background: rgba(37,99,235,0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-600);
  margin-bottom: 28px;
  animation: pulse-subtle 2s ease-in-out infinite;
}

.permission-title {
  font-size: 20px;
  font-weight: var(--fw-bold);
  color: var(--zinc-900);
  margin-bottom: 12px;
}

.permission-desc {
  font-size: var(--fs-md);
  color: var(--zinc-500);
  line-height: 1.6;
  margin-bottom: 32px;
  max-width: 280px;
}

.permission-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--blue-600);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  font-family: var(--font-family);
  transition: all var(--duration-fast) var(--easing-default);
}

.btn-primary:hover { background: var(--blue-700); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  width: 100%;
  padding: 14px;
  background: var(--white);
  color: var(--zinc-600);
  border: 1px solid var(--zinc-200);
  border-radius: var(--radius-lg);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  font-family: var(--font-family);
  transition: all var(--duration-fast) var(--easing-default);
}

.btn-secondary:hover {
  background: var(--zinc-100);
  border-color: var(--zinc-400);
}

.btn-secondary:active { transform: scale(0.98); }

/* ─── Error Screen ─── */
.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 24px;
  text-align: center;
}

.error-icon {
  width: 80px;
  height: 80px;
  background: rgba(239,68,68,0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red-500);
  margin-bottom: 24px;
}

.error-icon.warning {
  background: rgba(245,158,11,0.08);
  color: var(--amber-500);
}

.error-title {
  font-size: 20px;
  font-weight: var(--fw-bold);
  color: var(--zinc-900);
  margin-bottom: 8px;
}

.error-message {
  font-size: var(--fs-md);
  color: var(--zinc-500);
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 280px;
}

.error-retry-btn {
  width: 100%;
  max-width: 280px;
  padding: 14px;
  background: var(--blue-600);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  font-family: var(--font-family);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--duration-fast) var(--easing-default);
  margin-bottom: 28px;
}

.error-retry-btn:hover { background: var(--blue-700); }
.error-retry-btn:active { transform: scale(0.98); }
.error-retry-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.troubleshoot-section {
  width: 100%;
  max-width: 280px;
  text-align: left;
}

.troubleshoot-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--zinc-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.troubleshoot-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.troubleshoot-list li {
  font-size: var(--fs-base);
  color: var(--zinc-600);
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.troubleshoot-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--zinc-400);
}

/* ─── Stale Banner ─── */
.stale-banner {
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--amber-600);
  font-weight: var(--fw-medium);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Toast ─── */
.toast-container {
  position: absolute;
  top: 48px;
  left: 16px;
  right: 16px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: slideDown var(--duration-normal) var(--easing-default);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.toast.success { background: var(--green-500); }
.toast.info { background: var(--blue-600); }
.toast.warning { background: var(--amber-500); }
.toast.error { background: var(--red-500); }

.toast.dismissing {
  animation: slideUp var(--duration-fast) var(--easing-default) forwards;
}

/* ─── Skeleton / Loading ─── */
.skeleton {
  background: linear-gradient(90deg, var(--zinc-200) 25%, var(--zinc-100) 50%, var(--zinc-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-hero {
  height: 220px;
  margin: 0 16px;
  border-radius: var(--radius-xl);
}

.skeleton-stat {
  height: 90px;
  border-radius: var(--radius-lg);
}

/* ─── Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

@keyframes pulse-subtle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ─── Animation Utilities ─── */
.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--easing-default);
}

.animate-slide-up {
  animation: slideUpEntry var(--duration-slow) var(--easing-default);
}

.animate-scale-in {
  animation: scaleIn var(--duration-normal) var(--easing-bounce);
}

.stagger-1 { animation-delay: 50ms; animation-fill-mode: both; }
.stagger-2 { animation-delay: 100ms; animation-fill-mode: both; }
.stagger-3 { animation-delay: 150ms; animation-fill-mode: both; }
.stagger-4 { animation-delay: 200ms; animation-fill-mode: both; }

.spin-icon {
  animation: spin 1s linear infinite;
}

.press-scale:active {
  transform: scale(0.97);
}

.hover-lift {
  transition: transform var(--duration-fast) var(--easing-default), box-shadow var(--duration-fast) var(--easing-default);
}

.hover-lift:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* ─── Dropdown ─── */
.dropdown-panel {
  display: none;
}

.dropdown-panel.dropdown-open {
  display: block;
}

/* ─── Utility Classes ─── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none; }
