/* Audio Timers - Main Stylesheet */

/* CSS Variables */
:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a22;
  --bg-tertiary: #252530;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

html, body {
  height: 100%;
}

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

/* App Layout */
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.tab-btn.active {
  background: var(--accent);
  color: white;
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Sound Toggle */
.sound-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all 0.2s;
}

.sound-toggle:hover {
  background: var(--bg-secondary);
}

.sound-toggle.enabled {
  color: var(--accent-light);
}

.sound-toggle svg {
  width: 18px;
  height: 18px;
}

/* Timer Display Container */
.timer-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  margin-bottom: 24px;
}

/* Timer Presets */
.presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.preset-btn {
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.preset-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.preset-btn.active {
  background: var(--accent);
  color: white;
}

.preset-btn .preset-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.preset-btn.active .preset-label {
  color: rgba(255, 255, 255, 0.8);
}

/* Time Picker (Long Timers) */
.time-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.time-group {
  text-align: center;
}

.time-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.time-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-btn {
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.time-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.time-btn:active {
  transform: scale(0.95);
}

.time-value {
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  color: var(--text-primary);
}

.time-separator {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-top: 24px;
}

/* Interval Picker */
.interval-picker {
  margin-bottom: 24px;
}

.interval-picker > label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-align: center;
}

.interval-options {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.interval-btn {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.interval-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.interval-btn-min {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.interval-btn-min:hover {
  border-color: var(--accent);
}

.interval-btn-min.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.mode-btn {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.mode-btn.active {
  background: var(--accent);
  color: white;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.control-btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.control-btn svg {
  width: 20px;
  height: 20px;
}

.control-btn.primary {
  background: var(--accent);
  color: white;
}

.control-btn.primary:hover {
  background: var(--accent-dark);
}

.control-btn.primary:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

.control-btn.secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.control-btn.secondary:hover {
  background: var(--bg-tertiary);
}

/* Style Selector */
.style-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px 0;
  border-top: 1px solid var(--bg-tertiary);
}

.style-btn {
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

.style-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.app-footer {
  margin: 24px auto 16px;
  max-width: 960px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
}

@media (max-width: 640px) {
  .app-footer {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===== TIMER VISUALIZER STYLES ===== */

/* Circle Timer */
.timer-circle {
  position: relative;
  width: 280px;
  height: 280px;
}

.timer-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-circle-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}

.timer-circle-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-circle-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-circle .timer-number {
  font-size: 5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* Digits Timer */
.timer-digits {
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-digits .timer-number {
  font-size: 10rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-shadow: 0 0 60px rgba(99, 102, 241, 0.3);
}

/* Bar Timer */
.timer-bar {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

.timer-bar-track {
  width: 100%;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 12px;
  transition: width 0.1s linear;
}

.timer-bar-text {
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-bar .timer-number {
  font-size: 6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* Arc Timer */
.timer-arc {
  position: relative;
  width: 280px;
  height: 180px;
}

.timer-arc svg {
  width: 100%;
  height: 100%;
}

.timer-arc-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 10;
  stroke-linecap: round;
}

.timer-arc-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-arc-text {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.timer-arc .timer-number {
  font-size: 5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* Flip Timer */
.timer-flip {
  perspective: 400px;
}

.timer-flip-card {
  position: relative;
  width: 180px;
  height: 220px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.timer-flip-top,
.timer-flip-bottom {
  position: absolute;
  width: 100%;
  height: 50%;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.timer-flip-top {
  top: 0;
  background: var(--bg-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid var(--bg-primary);
  align-items: flex-end;
}

.timer-flip-bottom {
  bottom: 0;
  background: var(--bg-tertiary);
  border-radius: 0 0 var(--radius) var(--radius);
  align-items: flex-start;
}

.timer-flip .timer-number {
  font-size: 7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
}

.timer-flip-top .timer-number {
  transform: translateY(50%);
}

.timer-flip-bottom .timer-number {
  transform: translateY(-50%);
}

.timer-flip-card.flip {
  animation: flipCard 0.3s ease-out;
}

@keyframes flipCard {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(-10deg); }
  100% { transform: rotateX(0); }
}

/* Responsive */
@media (max-width: 400px) {
  .app {
    padding: 12px;
  }

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

  .timer-circle .timer-number {
    font-size: 4rem;
  }

  .timer-digits .timer-number {
    font-size: 7rem;
  }

  .timer-bar .timer-number {
    font-size: 5rem;
  }

  .timer-arc {
    width: 240px;
    height: 160px;
  }

  .timer-arc .timer-number {
    font-size: 4rem;
  }

  .timer-flip-card {
    width: 140px;
    height: 170px;
  }

  .timer-flip .timer-number {
    font-size: 5rem;
  }

  .presets {
    grid-template-columns: 1fr 1fr;
  }
}

/* Dark mode is default, but add light mode option */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f8fafc;
    --bg-secondary: #e2e8f0;
    --bg-tertiary: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
  }
}

/* Force dark mode class */
.dark-mode {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a22;
  --bg-tertiary: #252530;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
}
