:root {
  --bg-dark: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --accent-blue: #38bdf8;
  --accent-work: #ef4444;
  --accent-rest: #22c55e;
  --accent-prepare: #f59e0b;
  --accent-set-rest: #a855f7;
  --accent-cooldown: #14b8a6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: #f8fafc;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* Changed for natural scrolling with tabs */
  min-height: 100vh;
  padding: 16px;
  transition: background-color 0.5s ease;
}

/* Background Dynamic Themes - High Contrast */
body.theme-idle { background-color: #0f172a; }
body.theme-prepare { background-color: #d97706; }
body.theme-work { background-color: #dc2626; }
body.theme-rest { background-color: #16a34a; }
body.theme-set-rest { background-color: #7e22ce; }
body.theme-cooldown { background-color: #0d9488; }

.app-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 85px; /* Creates space for the fixed bottom nav */
}

header h1 {
  text-align: center;
  font-size: 1.2rem;
  letter-spacing: 4px;
  color: #ffffff;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.timer-display {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 32px 20px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

#phase-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent-blue);
  margin-bottom: 8px;
  transition: color 0.3s;
}

.time {
  font-size: 5.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 16px 0 24px 0;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.stats {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-box .label {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 1px;
}

.stat-box .value {
  font-size: 1.25rem;
  font-weight: 800;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
}

button {
  flex: 1;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

button:active { transform: scale(0.97); }

.primary-btn { background: var(--accent-blue); color: #0f172a; }
.warning-btn { background: #f59e0b; color: #0f172a; }
.secondary-btn { background: #334155; color: #f8fafc; }

.hidden { display: none !important; }

/* Settings Card */
.settings {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
}

.settings h3 {
  font-size: 1rem;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.full-width {
  grid-column: span 2;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
}

.input-field input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #0f172a;
  color: #f8fafc;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

/* --- Audio Controls Group --- */
.audio-controls-group {
  display: flex;
  flex-direction: column;
  gap: 12px; 
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #cbd5e1;
}

/* Toggle Switch Styling */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--accent-blue); }
input:checked + .slider:before { transform: translateX(20px); }

/* --- Info Box Accordion --- */
.info-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
}

details {
  color: #cbd5e1;
}

summary {
  font-weight: 700;
  cursor: pointer;
  outline: none;
  list-style: none; /* Hides default triangle in Firefox */
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

summary::-webkit-details-marker {
  display: none; /* Hides default triangle in Chrome/Safari */
}

/* Custom Plus/Minus Icon */
summary::after {
  content: '+';
  font-size: 1.5rem;
  color: var(--accent-blue);
  line-height: 1;
}

details[open] summary::after {
  content: '−';
}

.info-content {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-content strong {
  color: #f8fafc;
  font-weight: 600;
}

/* --- Support Accordion --- */
.support-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
}

.support-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.support-link {
  display: block;
  width: 100%;
  padding: 14px;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
  border-radius: 12px;
  transition: opacity 0.2s, transform 0.1s;
}

.support-link:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.btn-saweria { background-color: #eab308; color: #0f172a; } 
.btn-bmc { background-color: #FFDD00; color: #0f172a; } 
.btn-paypal { background-color: #0079C1; color: #ffffff; }

/* --- Presets Dropdown --- */
.preset-container {
  margin-bottom: 20px;
}

select {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #0f172a;
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
}

/* --- Upgraded Preset Controls --- */
.preset-controls {
  display: flex;
  gap: 10px;
}

.preset-controls select {
  flex: 1;
}

.danger-btn {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0 15px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: transform 0.1s;
}
.danger-btn:active { transform: scale(0.9); }

/* --- Fix Save & Share Row Layout --- */
.save-preset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.save-preset-row input {
  flex: 1 1 0%; 
  min-width: 0;  
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.85rem;
  box-sizing: border-box;
}

.save-preset-row button {
  flex: 0 0 auto;
  padding: 10px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}

#btn-share-preset {
  padding: 10px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #334155 !important;
  color: #ffffff !important; 
  border: none;
}

/* --- Stats Accordion & Grid --- */
.stats-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
}

.stats-grid {
  display: flex;
  justify-content: space-around;
  text-align: center;
  padding: 10px 0;
}

/* --- Footer Links --- */
.footer-links {
  text-align: center;
  margin-top: 10px;
  padding-bottom: 10px;
}

.privacy-link {
  color: #FFF; 
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 0.2s;
}

.privacy-link:hover, .privacy-link:active {
  color: var(--accent-blue);
  text-decoration: underline;
}

/* --- Stepper Controls (Sweaty Hands) --- */
.stepper {
  display: flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.stepper input {
  flex: 1;
  width: 100%;
  border: none !important;
  border-radius: 0 !important;
  padding: 12px 5px !important;
  text-align: center;
  background: transparent !important;
  -moz-appearance: textfield; 
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 100%;
  background: #1e293b;
  color: #94a3b8;
  border-radius: 0 !important;
  font-size: 1.2rem;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.step-btn:active {
  background: #334155;
  color: #ffffff;
  transform: scale(1) !important;
}

/* --- Visual Sub-Grouping --- */
.grid-divider {
  border: 0;
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* --- Tabs & Navigation --- */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.2s ease-out;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  z-index: 1000;
}

.nav-item {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 6px 12px;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.nav-item.active-nav {
  color: var(--accent-blue);
}

/* --- UPDATED ICON SIZING & ANIMATION --- */
.nav-icon {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
  transition: transform 0.2s;
}

.nav-item:active .nav-icon {
  transform: scale(0.9);
}
/* --------------------------------------- */

.nav-label {
  font-weight: 700;
}

/* --- Zen Mode (Hides bottom nav when timer is active) --- */
body.timer-active .bottom-nav {
  display: none !important;
}
