/* ============================================
   Pomodoro Timer - Dark Theme
   Built with Web Components
   ============================================ */

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

:root {
  /* Work (warm) */
  --work-primary: #ff6b6b;
  --work-glow: rgba(255, 107, 107, 0.25);
  --work-bg: #1a1215;
  --work-surface: #2a1f22;
  --work-track: #3a2a2e;

  /* Break (cool) */
  --break-primary: #4ecdc4;
  --break-glow: rgba(78, 205, 196, 0.25);
  --break-bg: #121a19;
  --break-surface: #1f2a28;
  --break-track: #2a3a37;

  /* Long break (deep cool) */
  --long-primary: #45b7d1;
  --long-glow: rgba(69, 183, 209, 0.25);
  --long-bg: #111a1e;
  --long-surface: #1d2a30;
  --long-track: #283a42;

  /* Neutral */
  --text-primary: #f0ece8;
  --text-secondary: #9a928a;
  --text-muted: #5a544e;
  --surface-border: rgba(255, 255, 255, 0.06);

  /* Active theme (defaults to work) */
  --primary: var(--work-primary);
  --glow: var(--work-glow);
  --bg: var(--work-bg);
  --surface: var(--work-surface);
  --track: var(--work-track);

  --radius: 14px;
  --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  transition: background var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* Theme states applied via JS */
body.mode-work {
  --primary: var(--work-primary);
  --glow: var(--work-glow);
  --bg: var(--work-bg);
  --surface: var(--work-surface);
  --track: var(--work-track);
}

body.mode-break {
  --primary: var(--break-primary);
  --glow: var(--break-glow);
  --bg: var(--break-bg);
  --surface: var(--break-surface);
  --track: var(--break-track);
}

body.mode-longBreak {
  --primary: var(--long-primary);
  --glow: var(--long-glow);
  --bg: var(--long-bg);
  --surface: var(--long-surface);
  --track: var(--long-track);
}

/* ---- Layout ---- */
.app {
  max-width: 420px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Header ---- */
.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ---- Mode Tabs ---- */
.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.mode-tab {
  padding: 8px 20px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.mode-tab:hover {
  color: var(--text-primary);
}

.mode-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 12px var(--glow);
}

/* ---- Task Input ---- */
.task-input-wrapper {
  width: 100%;
  margin-bottom: 24px;
}

.task-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.task-input::placeholder {
  color: var(--text-muted);
}

.task-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--glow);
}

/* ---- Timer ---- */
.timer-container {
  position: relative;
  width: 240px;
  height: 240px;
  margin-bottom: 32px;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 20px var(--glow));
  transition: filter var(--transition);
}

.timer-track {
  fill: none;
  stroke: var(--track);
  stroke-width: 8;
  transition: stroke var(--transition);
}

.timer-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 722.57;
  stroke-dashoffset: 0;
  transition: stroke var(--transition), stroke-dashoffset 0.5s linear;
}

.timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timer-time {
  font-size: 3.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timer-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---- Controls ---- */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.control-btn {
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.control-btn.primary {
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 20px var(--glow);
}

.control-btn.primary:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px var(--glow);
}

.control-btn.primary:active {
  transform: scale(0.97);
}

.control-btn.secondary {
  width: 44px;
  height: 44px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
}

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

/* ---- Session Dots ---- */
.session-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.session-dots {
  display: flex;
  gap: 8px;
}

.session-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--track);
  transition: background 0.3s, box-shadow 0.3s;
}

.session-dot.completed {
  background: var(--primary);
  box-shadow: 0 0 8px var(--glow);
}

.session-dot.active {
  background: var(--primary);
  opacity: 0.5;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

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

.session-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 24px;
  width: 100%;
  border: 1px solid var(--surface-border);
  transition: background var(--transition), border-color var(--transition);
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  transition: color var(--transition);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--surface-border);
}

/* ---- Settings Panel ---- */
.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.3s, visibility 0.3s;
}

.settings-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.settings-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  transform: translateY(0);
  transition: transform 0.3s ease, background var(--transition);
}

.settings-panel.hidden .settings-content {
  transform: translateY(100%);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.settings-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.setting-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.adj-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  background: transparent;
  color: var(--text-primary);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.adj-btn:hover {
  border-color: var(--primary);
  background: var(--glow);
}

.setting-value {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}

.setting-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 24px;
}

/* Toggle */
.toggle-control {
  gap: 0;
}

.toggle {
  width: 48px;
  height: 28px;
  border-radius: 14px;
  background: var(--track);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.25s;
}

.toggle.active {
  background: var(--primary);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s;
}

.toggle.active .toggle-knob {
  transform: translateX(20px);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .app {
    padding: 16px 16px 32px;
  }

  .timer-container {
    width: 200px;
    height: 200px;
  }

  .timer-time {
    font-size: 2.75rem;
  }

  .mode-tab {
    padding: 7px 14px;
    font-size: 0.8rem;
  }

  .stats-bar {
    padding: 14px 16px;
  }
}

@media (min-width: 481px) and (min-height: 800px) {
  .app {
    justify-content: center;
    padding-top: 0;
    padding-bottom: 0;
  }
}

/* ---- Animations ---- */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.app > * {
  animation: fade-in 0.5s ease both;
}

.app > *:nth-child(2) { animation-delay: 0.05s; }
.app > *:nth-child(3) { animation-delay: 0.1s; }
.app > *:nth-child(4) { animation-delay: 0.15s; }
.app > *:nth-child(5) { animation-delay: 0.2s; }
.app > *:nth-child(6) { animation-delay: 0.25s; }
.app > *:nth-child(7) { animation-delay: 0.3s; }
.app > *:nth-child(8) { animation-delay: 0.35s; }
