/* =========================================================
   Focus Timer & Daily Tasks — clean dark theme
   ========================================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0d1017;
  --card: #151a23;
  --surface: #10141c;
  --border: #232b3a;
  --text: #eef1f6;
  --muted: #8f98ab;
  --accent: #6d8dff;
  --accent-hover: #85a0ff;
  --accent-soft: rgba(109, 141, 255, 0.15);
  --success: #4fd18b;
  --danger: #ff6b7a;
  --btn-bg: #1d2432;
  --btn-bg-hover: #242d3f;
  --radius: 14px;
}

html {
  color-scheme: dark;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 48px 16px 64px;
}

.app {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Header ---------- */

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.app-header .subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

/* ---------- Timer ---------- */

.timer-card {
  text-align: center;
}

.timer-display {
  position: relative; /* sits on top of the ring SVG */
  z-index: 1;
  font-size: clamp(2.5rem, 14vw, 3.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums; /* keeps digit widths stable */
  transition: color 0.3s ease;
}

.timer-card.running .timer-display {
  animation: pulse 2s ease-in-out infinite;
}

.timer-card.done .timer-display {
  color: var(--success);
}

.timer-status {
  margin-top: 8px;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.9rem;
}

.timer-progress {
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  margin-top: 16px;
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.timer-card.running .timer-progress-bar {
  transition: transform 0.25s ease;
}

.timer-ring {
  position: relative;
  width: min(300px, 100%);
  aspect-ratio: 1; /* keeps the ring a perfect circle */
  margin: 0 auto 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.timer-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.timer-ring-progress {
  transition: stroke-dashoffset 0.3s ease;
  stroke-linecap: round;
}

.timer-card.running .timer-ring-progress {
  transition: stroke-dashoffset 0.25s ease;
}

.timer-card.done .timer-ring-progress {
  stroke: var(--success);
}

/* ---------- Break Timer Button ---------- */

.btn-break {
  width: 100%;
  margin-top: 16px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}

/* Highlighted state once the main timer has completed and the break is unlocked */
.btn-break.ready {
  background: rgba(79, 209, 139, 0.12);
  border-color: var(--success);
  color: var(--success);
}

.btn-break.ready:hover:not(:disabled) {
  background: rgba(79, 209, 139, 0.22);
  border-color: var(--success);
}

/* Timer display/ring appearance while the 5-minute break is counting down */

.timer-card.break-running .timer-display {
  color: var(--success);
}

.timer-card.break-running .timer-ring-progress {
  stroke: var(--success);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.timer-controls {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ---------- Timer Settings (below the timer) ---------- */

.timer-settings-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timer-settings-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:hover:not(:disabled) {
  background: var(--btn-bg-hover);
  border-color: #2e3950;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:focus-visible,
#task-input:focus-visible,
.task-item input[type="checkbox"]:focus-visible,
.delete-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Tasks ---------- */

.tasks-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tasks-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.task-count {
  color: var(--muted);
  font-size: 0.85rem;
}

#task-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

#task-input {
  flex: 1;
  font: inherit;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#task-input::placeholder {
  color: var(--muted);
}

#task-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: fade-in 0.2s ease;
}

.task-text {
  flex: 1;
  cursor: pointer;
  word-break: break-word;
}

.task-item.done .task-text {
  color: var(--muted);
  text-decoration: line-through;
}

/* Custom checkbox (with SVG tick when checked) */
.task-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 2px solid var(--muted);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.task-item input[type="checkbox"]:hover {
  border-color: var(--accent);
}

.task-item input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}

.delete-btn {
  font-size: 1.15rem;
  line-height: 1;
  padding: 6px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.delete-btn:hover {
  color: var(--danger);
  background: rgba(255, 107, 122, 0.12);
}

.empty-msg {
  padding: 12px 0 4px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Reset buttons ---------- */

.tasks-footer {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-danger {
  background: rgba(255, 107, 122, 0.1);
  border-color: rgba(255, 107, 122, 0.4);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 122, 0.2);
  border-color: var(--danger);
}

/* ---------- Settings & Stats Card ---------- */

.settings-card {
  margin-top: 24px;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-item {
  background: var(--surface);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.settings-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.settings-reset {
  display: flex;
  justify-content: flex-end;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-item label {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 120px;
}

.setting-item select,
.setting-item input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.setting-item select:focus,
.setting-item input[type="text"]:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Toast Notifications ---------- */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  animation: slide-in-right 0.3s ease;
  pointer-events: auto;
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast-warning {
  border-left: 3px solid var(--danger);
}

@keyframes slide-in-right {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slide-out-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ---------- Theme Toggle ---------- */

#toggle-theme-btn {
  background: var(--surface);
  border: 1px solid var(--border);
}

#toggle-theme-btn:hover {
  background: var(--border);
}

/* ---------- Responsive ---------- */

@media (max-width: 420px) {
  .card {
    padding: 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .setting-item label {
    min-width: auto;
    margin-bottom: 4px;
  }
}