/* Base styles */
:root {
  --primary: #4a6fa5;
  --primary-light: #6b8cbc;
  --secondary: #6c757d;
  --success: #28a745;
  --background: #f8f9fa;
  --surface: #ffffff;
  --text: #212529;
  --text-secondary: #6c757d;
  --border: #dee2e6;
  --shadow: rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

[data-theme="dark"] {
  --primary: #6b8cbc;
  --background: #121212;
  --surface: #1e1e1e;
  --text: #f8f9fa;
  --text-secondary: #adb5bd;
  --border: #343a40;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: "Inter", sans-serif;
  background-color: var(--background);
  color: var(--text);
  transition: var(--transition);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

.container {
  width: 100%;
  max-width: 800px;
  background-color: var(--surface);
  border-radius: 16px;
  box-shadow: 0 10px 30px var(--shadow);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}

/* Theme toggle in corner */
.theme-toggle-corner {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 10;
}

.theme-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 5px var(--shadow);
  font-size: 1.1rem;
}

.theme-btn:hover {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
}

[data-theme="dark"] .theme-btn i:before {
  content: "\f185"; /* Sun icon for dark mode */
}

[data-theme="light"] .theme-btn i:before {
  content: "\f186"; /* Moon icon for light mode */
}

header {
  text-align: center;
  padding: 20px 15px 15px;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}

.subtitle {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  color: var(--text-secondary);
  font-weight: 300;
}

main {
  padding: 15px;
}

/* Breathing display */
.breathing-display {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.breathing-circle {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 20px rgba(74, 111, 165, 0.3);
  transition: var(--transition);
  position: relative;
  z-index: 2;
}

.phase-indicator {
  text-align: center;
  color: white;
  padding: 10px;
}

#phase-text {
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.progress-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.progress-ring {
  width: 100%;
  height: 100%;
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.3s linear;
}

.progress-ring-circle-filled {
  stroke-dasharray: 628.32;
  stroke-dashoffset: 628.32;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.1s linear;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 25px 0;
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.timer-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 30px;
  cursor: pointer;
  transition: var(--transition);
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
}

.timer-btn.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.main-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-weight: 500;
  min-width: 100px;
  justify-content: center;
}

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

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

.control-btn:hover:not(:disabled) {
  background-color: var(--primary-light);
  color: white;
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

/* Settings */
.settings {
  background-color: rgba(74, 111, 165, 0.05);
  border-radius: 12px;
  padding: 15px;
  margin-top: 15px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group label {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

#phase-duration {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

#phase-duration::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#duration-value {
  font-weight: 600;
  min-width: 30px;
  text-align: center;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

/* Footer */
footer {
  text-align: center;
  padding: 15px;
  color: var(--text-secondary);
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  border-top: 1px solid var(--border);
}

/* Animations */
@keyframes breathe-in {
  0% {
    transform: scale(0.7);
  }
  100% {
    transform: scale(1.3);
  }
}

@keyframes breathe-out {
  0% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(0.7);
  }
}

@keyframes hold {
  0%,
  100% {
    transform: scale(1);
  }
}

.breathe-in {
  animation: breathe-in 4s linear forwards;
}

.breathe-out {
  animation: breathe-out 4s linear forwards;
}

.hold {
  animation: hold 4s linear forwards;
}

/* Responsive design */
@media (max-width: 480px) {
  .container {
    border-radius: 12px;
  }

  .theme-toggle-corner {
    top: 12px;
    right: 12px;
  }

  .theme-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .breathing-display {
    margin: 15px 0;
  }

  .timer-controls {
    gap: 6px;
  }

  .timer-btn {
    padding: 5px 10px;
  }

  .main-controls {
    gap: 8px;
  }

  .control-btn {
    padding: 8px 16px;
    min-width: 90px;
  }

  .settings {
    padding: 12px;
    gap: 12px;
  }

  .setting-group {
    gap: 6px;
  }
}

@media (max-width: 360px) {
  .theme-btn {
    width: 32px;
    height: 32px;
  }

  .timer-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .control-btn {
    padding: 6px 12px;
    min-width: 80px;
    font-size: 0.85rem;
  }
}
