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

html {
  font-size: 120%;
}

:root {
  /* Deep Pool Dark Theme (Default) */
  --bg-gradient: radial-gradient(circle at 50% 50%, #0b1c3a 0%, #030814 100%);
  --panel-bg: rgba(13, 30, 61, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-color: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.4);
  
  /* Clock Colors */
  --clock-bg: #071124;
  --clock-bezel: #1e293b;
  --clock-ring: #0891b2;
  --clock-tick-major: #ffffff;
  --clock-tick-minor: #475569;
  --clock-num-classic: #ffffff;
  --clock-num-accent: #ef4444; /* Red 60 and 30 */

  /* Hand Colors */
  --hand-red: #ef4444;
  --hand-green: #22c55e;
  --hand-yellow: #eab308;
  --hand-blue: #3b82f6;
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  /* Solar Bright Light Theme */
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(0, 0, 0, 0.08);
  --panel-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.25);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-color: #0891b2;
  --accent-glow: rgba(8, 145, 178, 0.2);

  /* Clock Colors */
  --clock-bg: #ffffff;
  --clock-bezel: #cbd5e1;
  --clock-ring: #0891b2;
  --clock-tick-major: #0f172a;
  --clock-tick-minor: #94a3b8;
  --clock-num-classic: #0f172a;
  --clock-num-accent: #dc2626;

  /* Hand Colors - slightly higher contrast for bright backgrounds */
  --hand-red: #dc2626;
  --hand-green: #15803d;
  --hand-yellow: #ca8a04;
  --hand-blue: #1d4ed8;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

header {
  padding: 1.5rem 2rem 0.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, var(--text-primary), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand span {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--panel-border);
  transition: all 0.3s ease;
}

.brand span.mode-standalone {
  background: var(--accent-glow);
  color: var(--accent-color);
  border-color: rgba(6, 182, 212, 0.3);
}

.brand span.mode-viewer {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.3);
}

.brand span.mode-admin {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}


.main-container {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(400px, 1.3fr) minmax(300px, 0.7fr);
  gap: 3rem;
  padding: 1.5rem 2rem 2rem 2rem;
  align-items: start;
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
    gap: 2rem;
    align-items: start;
  }
}

/* Clock Wrapper & SVG Styling */
.clock-container {
  display: flex;
  justify-content: center;
  align-items: start;
  width: 100%;
  min-height: 400px;
}

.clock-card {
  width: 100%;
  max-width: 780px;
  aspect-ratio: 1 / 1;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  border-radius: 50%;
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: transform 0.3s ease;
}

.clock-card::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-color), transparent 60%);
  z-index: -1;
  opacity: 0.3;
  pointer-events: none;
}

.pace-clock-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

/* SVG Parts */
.svg-clock-bg {
  fill: var(--clock-bg);
  transition: fill 0.3s ease;
}

.svg-clock-bezel {
  fill: none;
  stroke: var(--clock-bezel);
  stroke-width: 8;
  transition: stroke 0.3s ease;
}

.svg-clock-ring {
  fill: none;
  stroke: var(--clock-ring);
  stroke-width: 1.5;
  opacity: 0.6;
  transition: stroke 0.3s ease;
}

.tick-major {
  stroke: var(--clock-tick-major);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke 0.3s ease;
}

.tick-minor {
  stroke: var(--clock-tick-minor);
  stroke-width: 1.5;
  stroke-linecap: round;
  transition: stroke 0.3s ease;
}

.clock-text {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 26px;
  fill: var(--clock-num-classic);
  user-select: none;
  transition: fill 0.3s ease;
}

.clock-text-accent {
  fill: var(--clock-num-accent);
}

.clock-brand-text {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 11px;
  fill: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  user-select: none;
  transition: opacity 0.5s ease-in-out, fill 0.3s ease;
}

.clock-brand-text.fade-out {
  opacity: 0;
}

/* Hand Styles */
.clock-hand {
  stroke-linecap: round;
  transition: transform 0.05s linear; /* Smooth micro-transitions if ticking */
}

.clock-hand.smooth {
  transition: none; /* No transition for smooth animation frame updates */
}

#hand-red-g {
  --hand-color: var(--hand-red);
}
#hand-green-g {
  --hand-color: var(--hand-green);
}
#hand-yellow-g {
  --hand-color: var(--hand-yellow);
}
#hand-blue-g {
  --hand-color: var(--hand-blue);
}

.hand-line {
  stroke: var(--hand-color);
  stroke-width: 7;
}

.hand-cap {
  fill: var(--hand-color);
}

.hand-pointer {
  fill: var(--hand-color);
}

.hand-tail {
  stroke: var(--hand-color);
  stroke-width: 4.5;
}

.hand-counterweight {
  fill: var(--hand-color);
}

/* Colorblind Mode Accessibility Overrides */
:root.colorblind-mode {
  --hand-red: #D55E00 !important;
  --hand-green: #009E73 !important;
  --hand-yellow: #F0E442 !important;
  --hand-blue: #0072B2 !important;
}

.hand-pointer-cb {
  display: none;
  fill: var(--hand-color);
  stroke: var(--hand-color);
}

:root.colorblind-mode .hand-pointer-default {
  display: none;
}

:root.colorblind-mode .hand-pointer-cb {
  display: block;
}

.center-hub-outer {
  fill: var(--clock-bezel);
  stroke: var(--text-muted);
  stroke-width: 1;
  transition: fill 0.3s ease;
}

.center-hub-inner {
  fill: var(--text-primary);
  transition: fill 0.3s ease;
}

/* Sidebar & Dashboard Widgets */
.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.widget {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.widget::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: transparent;
}

.widget.widget-accent::before {
  background: var(--accent-color);
}

.widget-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Time & Timezone Widget */
.time-widget {
  padding: 1.5rem;
}

.digital-time-display {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
  margin-top: 0.25rem;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.digital-time-display span.millis {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.date-timezone-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.timezone-selector-container select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}

/* Next Departure Alert Widget */
.departure-widget {
  background: linear-gradient(135deg, rgba(13, 30, 61, 0.45) 0%, rgba(20, 10, 40, 0.2) 100%);
}

.departure-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0;
}

.departure-indicator {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 900;
  font-size: 1.5rem;
  color: #fff;
  transition: background 0.3s ease, transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.departure-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.departure-info .status {
  font-weight: 700;
  font-size: 1.1rem;
}

.departure-info .timer {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.departure-widget.alert-active {
  animation: pulse-border 1.5s infinite alternate;
}

.departure-widget.alert-active .departure-indicator {
  transform: scale(1.1);
  animation: pulse-glow 1s infinite alternate;
}

@keyframes pulse-border {
  from {
    border-color: var(--panel-border);
    box-shadow: var(--panel-shadow);
  }
  to {
    border-color: var(--alert-color, var(--accent-color));
    box-shadow: 0 0 15px var(--alert-glow, var(--accent-glow));
  }
}

@keyframes pulse-glow {
  from {
    box-shadow: 0 0 5px var(--alert-glow);
  }
  to {
    box-shadow: 0 0 20px var(--alert-glow);
  }
}

/* Set Planner Widget */
.planner-widget {
  gap: 0.5rem;
}

.planner-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.planner-input-group {
  display: flex;
  flex: 1;
  gap: 0.5rem;
}

.planner-input-field {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.25rem;
}

.planner-input-field label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.planner-input-field input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
}

.planner-input-field input:focus {
  border-color: var(--accent-color);
}

.btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  user-select: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--text-secondary);
}

.btn-primary {
  background: var(--accent-color);
  color: #071124;
  border-color: transparent;
}

.btn-primary:hover {
  background: #22d3ee;
  color: #071124;
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
}

.workout-display-panel {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 20px var(--accent-glow);
  margin-top: 0.5rem;
  text-align: center;
  position: relative;
}

.workout-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.workout-stats .set-info {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.workout-time-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1.25rem;
  margin: 0.25rem 0;
}

.workout-rep-number {
  font-family: var(--font-mono);
  font-size: 4rem;
  font-weight: 900;
  color: var(--accent-color);
  text-shadow: 0 0 20px var(--accent-glow);
}

.workout-timer-display {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 30px var(--accent-glow);
}

.workout-timer-display.rest {
  color: var(--hand-green);
  text-shadow: 0 0 30px rgba(34, 197, 94, 0.4);
}

/* Pool Parameters Widget */
.pool-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.pool-info-item {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  position: relative;
}

.pool-info-item label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pool-info-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pool-info-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Control Panel */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.controls-grid .btn {
  padding: 0.6rem 0.5rem;
  font-size: 0.75rem;
  flex-direction: column;
  gap: 0.25rem;
}

.controls-grid .btn svg {
  width: 18px;
  height: 18px;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 9, 20, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--clock-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transform: scale(0.95);
  transition: transform 0.3s ease;
  color: var(--text-primary);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

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

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-row-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.hand-toggle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.hand-toggle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}

.hand-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.color-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255,255,255,0.1);
  border: 1px solid var(--panel-border);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #071124;
}

.hand-color-pickers {
  display: flex;
  gap: 0.5rem;
}

.color-picker-wrapper {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  cursor: pointer;
}

.color-picker-input {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border: none;
  background: none;
}

/* Fullscreen mode layouts overrides */
body:fullscreen {
  background: var(--bg-gradient);
  padding: 0;
}

body:fullscreen header {
  display: none;
}

body:fullscreen .main-container {
  max-width: 100vw;
  height: 100vh;
  padding: 2rem;
  grid-template-columns: minmax(500px, 1.3fr) minmax(300px, 0.7fr);
  gap: 3rem;
}

body:fullscreen .clock-container {
  height: 100%;
  align-items: center;
}

body:fullscreen .clock-card {
  max-width: 85vh; /* Scale with screen height in fullscreen */
}

/* Footer style */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--panel-border);
  margin-top: auto;
  z-index: 10;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent-color);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.coffee-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary) !important;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  font-family: inherit;
}

.coffee-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.coffee-icon {
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .header-credits {
    display: none;
  }
}

@media (max-width: 480px) {
  header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
  }
  .header-right {
    width: 100%;
    justify-content: center;
    gap: 0.5rem;
  }
}

