/* ═══════════════════════════════════════════════════════════════════════════
   NEST WAKE-UP — Warm Dawn Dark Theme
   A thermostat scheduler that warms you before you wake
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Core palette - warm charcoal with amber accents */
  --bg-deep: #0d0d0f;
  --bg-primary: #141416;
  --bg-card: #1a1a1e;
  --bg-elevated: #222226;
  --bg-input: #28282e;

  /* Warm accent gradient - sunrise/heat colors */
  --accent-warm: #f59e0b;
  --accent-hot: #ef4444;
  --accent-glow: #fbbf24;
  --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(239, 68, 68, 0.08) 100%);

  /* Text hierarchy */
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Functional colors */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --warning-border: rgba(245, 158, 11, 0.3);

  /* Shadows & glows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-button: 0 4px 16px rgba(245, 158, 11, 0.25);
  --glow-warm: 0 0 60px rgba(245, 158, 11, 0.15);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
}

/* ─────────────────────────────────────────────────────────────────────────────
   BASE STYLES
   ───────────────────────────────────────────────────────────────────────────── */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Ambient glow orb - creates warm atmosphere */
.glow-orb {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin: 0 auto;
  padding: var(--space-lg);
  padding-bottom: 48px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   TYPOGRAPHY
   ───────────────────────────────────────────────────────────────────────────── */

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

code {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-glow);
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   SCREEN TRANSITIONS
   ───────────────────────────────────────────────────────────────────────────── */

.screen {
  animation: fadeSlideIn 0.4s var(--ease-out);
}

.hidden {
  display: none !important;
}

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

/* Staggered card animations */
.screen .card:nth-child(1) { animation-delay: 0ms; }
.screen .card:nth-child(2) { animation-delay: 50ms; }
.screen .card:nth-child(3) { animation-delay: 100ms; }
.screen .card:nth-child(4) { animation-delay: 150ms; }
.screen .card:nth-child(5) { animation-delay: 200ms; }

/* ─────────────────────────────────────────────────────────────────────────────
   ONBOARDING SCREEN
   ───────────────────────────────────────────────────────────────────────────── */

#onboarding {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

.logo {
  margin-bottom: var(--space-xl);
}

.logo-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  padding: 16px;
  background: var(--gradient-warm);
  border-radius: 50%;
  box-shadow: var(--glow-warm);
}

.logo-icon svg {
  width: 100%;
  height: 100%;
  color: white;
}

.logo h1 {
  font-size: 1.75rem;
  margin-bottom: var(--space-xs);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.onboarding-card {
  width: 100%;
  max-width: 320px;
}

.onboarding-card label {
  display: block;
  text-align: left;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: var(--space-lg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   DASHBOARD HEADER
   ───────────────────────────────────────────────────────────────────────────── */

header {
  margin-bottom: var(--space-lg);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.status-indicator .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

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

.status-indicator.inactive .dot {
  background: var(--text-muted);
  animation: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CARDS
   ───────────────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-card);
  animation: fadeSlideIn 0.4s var(--ease-out) backwards;
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--accent-warm);
}

.card-icon svg {
  width: 20px;
  height: 20px;
}

.card-icon.sun-icon {
  color: var(--accent-glow);
}

.card-icon.apple-icon {
  color: var(--text-secondary);
}

/* Status card special styling */
.status-card {
  background: var(--gradient-subtle);
  border-color: var(--border-accent);
}

.schedule-display {
  font-size: 0.9375rem;
  line-height: 1.8;
}

.schedule-display .loading-text {
  color: var(--text-muted);
}

.schedule-display strong {
  color: var(--accent-glow);
}

/* ─────────────────────────────────────────────────────────────────────────────
   FORMS & INPUTS
   ───────────────────────────────────────────────────────────────────────────── */

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--duration-fast) ease;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent-warm);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select {
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  transition: all var(--duration-fast) ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

select:focus {
  border-color: var(--accent-warm);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* ─────────────────────────────────────────────────────────────────────────────
   TIME PICKER WHEEL (iOS-style)
   ───────────────────────────────────────────────────────────────────────────── */

.time-picker-wheel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  position: relative;
  height: 180px;
}

.wheel-column {
  height: 180px;
  width: 64px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,0,0,0.4) 20%,
    black 40%,
    black 60%,
    rgba(0,0,0,0.4) 80%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,0,0,0.4) 20%,
    black 40%,
    black 60%,
    rgba(0,0,0,0.4) 80%,
    transparent 100%
  );
}

.wheel-column::-webkit-scrollbar {
  display: none;
}

.wheel-list {
  padding: 72px 0;
}

.wheel-item {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-primary);
  scroll-snap-align: center;
  cursor: pointer;
  transition: opacity 0.15s ease;
  user-select: none;
}

.wheel-item:hover {
  opacity: 0.8;
}

.wheel-separator {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
  z-index: 2;
}

.wheel-highlight {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 16px);
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  pointer-events: none;
  z-index: -1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────────────────────────────────── */

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #0d0d0f;
  background: var(--gradient-warm);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-button);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-glow {
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.2);
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.btn-secondary:hover {
  background: var(--bg-input);
  border-color: var(--accent-warm);
}

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

.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

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

.btn-ghost.btn-danger:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.btn-ghost svg {
  width: 16px;
  height: 16px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 0;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.btn-icon:hover {
  color: var(--accent-warm);
  border-color: var(--accent-warm);
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   SETTINGS
   ───────────────────────────────────────────────────────────────────────────── */

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-md);
}

.setting-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.setting-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.setting-icon svg {
  width: 18px;
  height: 18px;
}

.setting-icon.heat {
  color: var(--accent-hot);
}

.setting-icon.time {
  color: var(--accent-warm);
}

.setting-input {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.setting-input input[type="number"] {
  width: 64px;
  padding: 8px 10px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  background: var(--bg-card);
  border-color: var(--border-subtle);
}

.setting-input .unit {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 28px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   IOS SHORTCUT SECTION
   ───────────────────────────────────────────────────────────────────────────── */

.shortcut-section {
  cursor: pointer;
}

.shortcut-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}

.shortcut-section summary::-webkit-details-marker {
  display: none;
}

.shortcut-section summary .card-header {
  margin-bottom: 0;
}

.shortcut-section .chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform var(--duration-normal) var(--ease-out);
}

.shortcut-section[open] .chevron {
  transform: rotate(180deg);
}

.shortcut-content {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.shortcut-intro {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.instruction-block {
  margin-bottom: var(--space-lg);
}

.instruction-block:last-child {
  margin-bottom: 0;
}

.instruction-block ol {
  list-style: none;
  padding: 0;
  margin-top: var(--space-sm);
}

.instruction-block li {
  position: relative;
  padding-left: 24px;
  margin-bottom: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.instruction-block li::before {
  content: counter(list-item);
  counter-increment: list-item;
  position: absolute;
  left: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-warm);
}

.instruction-block ol {
  counter-reset: list-item;
}

/* ─────────────────────────────────────────────────────────────────────────────
   FOOTER
   ───────────────────────────────────────────────────────────────────────────── */

.app-footer {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.api-key-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.footer-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.api-key-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.api-key-display code {
  flex: 1;
  font-size: 0.75rem;
  background: transparent;
  padding: 0;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ─────────────────────────────────────────────────────────────────────────────
   WARNING BANNER
   ───────────────────────────────────────────────────────────────────────────── */

.warning-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--accent-warm);
  animation: fadeSlideIn 0.4s var(--ease-out);
}

.warning-banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.warning-banner span {
  flex: 1;
}

.warning-banner a {
  color: var(--accent-glow);
  font-weight: 600;
  text-decoration: none;
}

.warning-banner a:hover {
  text-decoration: underline;
}

/* ─────────────────────────────────────────────────────────────────────────────
   LINKS
   ───────────────────────────────────────────────────────────────────────────── */

a {
  color: var(--accent-warm);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}

a:hover {
  color: var(--accent-glow);
  text-decoration: underline;
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 420px) {
  .container {
    padding: var(--space-md);
  }

  .time-picker {
    gap: var(--space-sm);
  }

  .time-input-group input[type="number"] {
    width: 48px;
    font-size: 1.125rem;
  }

  select {
    padding: 12px 32px 12px 12px;
    font-size: 0.9375rem;
  }
}
