/* =============================================
   🍅 Pomodoro Timer — Styles
   ============================================= */

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

:root {
  /* Dark theme (default) */
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --accent: #e63946;
  --accent-hover: #ff4d5a;
  --accent-muted: rgba(230, 57, 70, 0.15);
  --success: #2ecc71;
  --warning: #f39c12;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.3);
  --ring-color: #e63946;
  --ring-bg: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --accent: #e63946;
  --accent-hover: #c0392b;
  --accent-muted: rgba(230, 57, 70, 0.08);
  --success: #27ae60;
  --warning: #e67e22;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: rgba(0, 0, 0, 0.1);
  --ring-color: #e63946;
  --ring-bg: rgba(0, 0, 0, 0.06);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
  width: 100%;
  max-width: 600px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 0;
}

.logo {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-text {
  background: linear-gradient(135deg, var(--accent), #e67e22);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Buttons --- */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 12px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.25rem;
  border-radius: 10px;
}

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

.btn-primary {
  background: var(--accent);
  color: white;
  padding: 0.875rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(230, 57, 70, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(230, 57, 70, 0.4);
}

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

.btn-lg {
  padding: 0.875rem 3rem;
  min-width: 180px;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 0.875rem 1.5rem;
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-text {
  background: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 0.5rem;
  border-radius: 8px;
}

.btn-text:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

/* --- Main --- */
.main {
  width: 100%;
  max-width: 520px;
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

/* --- Timer Section --- */
.timer-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* Mode Selector */
.mode-selector {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-secondary);
  padding: 0.375rem;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--text-primary);
  background: var(--accent-muted);
}

.mode-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(230, 57, 70, 0.3);
}

/* Timer Display */
.timer-display {
  position: relative;
  width: 300px;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring__bg {
  fill: none;
  stroke: var(--ring-bg);
  stroke-width: 6;
}

.progress-ring__fill {
  fill: none;
  stroke: var(--ring-color);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.timer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  z-index: 1;
}

.timer-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 4rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  line-height: 1;
  color: var(--text-primary);
  transition: color 0.3s ease;
}

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

/* Pomodoro dots */
.pomodoro-count {
  display: flex;
  gap: 6px;
  margin-top: 0.75rem;
}

.pomodoro-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ring-bg);
  transition: all 0.3s ease;
}

.pomodoro-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(230, 57, 70, 0.5);
}

/* Controls */
.controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* --- Stats Section --- */
.stats-section {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px var(--shadow);
}

.stats-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1rem 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-value {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* --- Footer --- */
.footer {
  width: 100%;
  max-width: 600px;
  padding: 1.5rem;
  text-align: center;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

.timer-display.running .timer-time {
  animation: pulse 2s ease-in-out infinite;
}

.timer-display.completed .timer-time {
  animation: pulse 0.5s ease-in-out infinite;
  color: var(--success);
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .header {
    padding: 1rem 1rem 0;
  }

  .main {
    padding: 1rem;
    gap: 1.5rem;
  }

  .timer-display {
    width: 240px;
    height: 240px;
  }

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

  .controls {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-lg {
    min-width: 200px;
    padding: 0.75rem 2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mode-selector {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 360px) {
  .timer-display {
    width: 200px;
    height: 200px;
  }

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

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles */
.btn:focus-visible,
.mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Selection --- */
::selection {
  background: var(--accent);
  color: white;
}
