/* ============================================
   POMODORO — Style System
   Dark, Minimal, Elegant
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* ---- TOKENS ---- */
:root {
  --bg:          #0a0a0f;
  --bg-card:     #111118;
  --bg-glass:    rgba(17, 17, 24, 0.7);
  --border:      rgba(255,255,255,0.06);
  --border-glow: rgba(192, 132, 252, 0.25);

  --text:        #f1f0f5;
  --text-muted:  #6b6880;
  --text-subtle: #3d3a4e;

  --accent:      #c084fc;       /* lavanda */
  --accent-dim:  rgba(192, 132, 252, 0.15);
  --accent2:     #818cf8;       /* índigo */
  --accent2-dim: rgba(129, 140, 248, 0.12);

  --work-color:  #c084fc;
  --break-color: #34d399;
  --long-color:  #60a5fa;

  --radius-sm:   8px;
  --radius-md:   16px;
  --radius-lg:   24px;
  --radius-xl:   40px;

  --shadow-glow: 0 0 40px rgba(192, 132, 252, 0.12);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);

  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  user-select: none;
}

/* ---- BACKGROUND AMBIANCE ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(192,132,252,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(129,140,248,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ---- MAIN LAYOUT ---- */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

/* ---- MODE TABS ---- */
#mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 4px;
}

.mode-tab {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-xl);
  padding: 7px 16px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--border-glow);
}
.mode-tab.break-active {
  background: rgba(52, 211, 153, 0.12);
  color: var(--break-color);
  border-color: rgba(52,211,153,0.25);
}
.mode-tab.long-active {
  background: rgba(96,165,250,0.12);
  color: var(--long-color);
  border-color: rgba(96,165,250,0.25);
}

/* ---- TIMER RING ---- */
#timer-container {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#timer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

#ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}

#ring-progress {
  fill: none;
  stroke: var(--work-color);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
  filter: drop-shadow(0 0 8px currentColor);
}

#timer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 1;
}

#timer-display {
  font-family: 'Space Mono', monospace;
  font-size: 62px;
  font-weight: 700;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1;
  transition: color var(--transition);
}

#timer-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#session-dots {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

.session-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-subtle);
  transition: var(--transition);
}
.session-dot.done { background: var(--accent); }

/* Timer ring glow pulse when running */
#timer-container.running #ring-progress {
  animation: ring-pulse 2s ease-in-out infinite;
}
@keyframes ring-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px currentColor); }
  50% { filter: drop-shadow(0 0 16px currentColor); }
}

/* ---- CONTROLS ---- */
#controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
}
.ctrl-btn:hover {
  border-color: var(--border-glow);
  color: var(--text);
  transform: scale(1.05);
}
.ctrl-btn:active { transform: scale(0.97); }

#btn-play-pause {
  width: 64px;
  height: 64px;
  background: var(--accent-dim);
  border-color: var(--border-glow);
  color: var(--accent);
  font-size: 22px;
}
#btn-play-pause:hover {
  background: rgba(192,132,252,0.25);
  box-shadow: 0 0 24px rgba(192,132,252,0.2);
}

#btn-reset, #btn-skip {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

/* ---- TASK STRIP ---- */
#task-strip {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
}

#task-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
}
#task-strip-header:hover { background: rgba(255,255,255,0.02); }

#task-strip-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
#task-notion-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-subtle);
  transition: var(--transition);
}
#task-notion-status.connected { background: var(--break-color); }
#task-notion-status.error { background: #f87171; }

#task-strip-chevron {
  font-size: 12px;
  color: var(--text-subtle);
  transition: transform var(--transition);
}
#task-strip.open #task-strip-chevron { transform: rotate(180deg); }

#task-list-wrap {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1);
}
#task-strip.open #task-list-wrap { max-height: 300px; }

#task-list {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}
.task-item:hover { border-color: var(--border-glow); background: var(--accent-dim); }
.task-item.active-task { border-color: var(--border-glow); background: var(--accent-dim); color: var(--accent); }
.task-item.done-task { text-decoration: line-through; color: var(--text-subtle); }
.task-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.task-item.done-task .task-dot { background: var(--text-subtle); }

#task-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

/* ---- BOTTOM BAR (spotify + settings) ---- */
#bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
}

/* Spotify mini */
#spotify-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#spotify-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
  transition: var(--transition);
}
#spotify-dot.playing {
  background: #1ed760;
  box-shadow: 0 0 8px #1ed760;
  animation: spotify-pulse 1.5s ease-in-out infinite;
}
#spotify-dot.paused { background: var(--text-muted); }
@keyframes spotify-pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.4); }
}

#spotify-track {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  cursor: pointer;
}
#spotify-track:hover { color: var(--text); }
#spotify-track.not-connected { color: var(--text-subtle); cursor: pointer; }
#spotify-track.not-connected:hover { color: var(--accent); }

#btn-settings {
  width: 38px;
  height: 38px;
  font-size: 16px;
  flex-shrink: 0;
}

/* ---- SETTINGS PANEL ---- */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
#settings-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#settings-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border-glow);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 101;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  overflow-y: auto;
  padding: 0 24px 40px;
}
#settings-panel.open {
  transform: translateX(-50%) translateY(0);
}

#settings-drag {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 24px;
}

#settings-panel h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.settings-section {
  margin-bottom: 28px;
}
.settings-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.setting-row-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Number input */
.time-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.time-input-wrap button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  transition: color var(--transition);
}
.time-input-wrap button:hover { color: var(--accent); }
.time-val {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  color: var(--text);
  min-width: 28px;
  text-align: center;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider {
  background: var(--accent-dim);
  border-color: var(--border-glow);
}
.toggle input:checked + .toggle-slider::before {
  left: calc(100% - 19px);
  background: var(--accent);
}

/* Connect buttons */
.connect-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.connect-btn:hover { border-color: var(--border-glow); color: var(--text); }
.connect-btn.connected {
  background: rgba(52,211,153,0.08);
  border-color: rgba(52,211,153,0.3);
  color: var(--break-color);
}
.connect-btn.spotify-btn { border-color: rgba(30,215,96,0.3); }
.connect-btn.spotify-btn:hover { background: rgba(30,215,96,0.08); color: #1ed760; }

/* Text inputs */
.setting-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  margin-top: 8px;
  transition: border-color var(--transition);
  outline: none;
}
.setting-input:focus { border-color: var(--border-glow); }
.setting-input::placeholder { color: var(--text-subtle); }

.save-btn {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: var(--accent-dim);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.save-btn:hover { background: rgba(192,132,252,0.25); }

/* ---- PiP button ---- */
#btn-pip {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  font-size: 14px;
  z-index: 10;
  opacity: 0.4;
  transition: opacity var(--transition);
}
#btn-pip:hover { opacity: 1; }

/* ---- LOADING / STATES ---- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- BREAK MODE ---- */
body.break-mode #ring-progress { stroke: var(--break-color); }
body.break-mode #btn-play-pause {
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.3);
  color: var(--break-color);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- RESPONSIVE ---- */
@media (max-height: 700px) {
  #timer-container { width: 220px; height: 220px; }
  #timer-display { font-size: 48px; }
  #app { gap: 20px; }
}

/* ---- FOCUS MODE (hide everything but timer) ---- */
body.focus-mode #mode-tabs,
body.focus-mode #task-strip,
body.focus-mode #bottom-bar,
body.focus-mode #btn-pip {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}
body.focus-mode #app { gap: 20px; }
