/* --- GLOBAL STATION COMMAND CENTER: PURPLE THEME --- */
:root {
  --bg-color: #050508;
  --card-bg: #11111a;
  --nav-bg: rgba(10, 10, 15, 0.95);
  --accent-color: #a855f7;
  --accent-glow: rgba(168, 85, 247, 0.5);
  --text-main: #ffffff;
  --text-dim: #6b7280;
  --border-color: #1f1f2e;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* Clean mobile taps */
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Stops horizontal scroll */
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* --- NAVIGATION BAR --- */
.main-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(12px);
  width: 100%;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 5px;
}

.tab-link {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 10px 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  position: relative;
  white-space: nowrap;
}

@media (min-width: 600px) {
  .tab-link {
    font-size: 0.85rem;
    padding: 10px 25px;
  }
}

.tab-link.active {
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-glow);
}

.tab-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 3px;
  background: var(--accent-color);
  box-shadow: 0 0 15px var(--accent-color);
  border-radius: 10px;
}

/* --- CLOCK GRID (TAB 1) --- */
.clock-grid {
  display: grid;
  /* Changed auto-fit to auto-fill to prevent stretching on the last row */
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  width: 95%;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 40px;
  justify-content: center; /* Centers the grid if there is extra space */
}

.clock-card {
  background: var(--card-bg);
  padding: 25px 15px;
  border-radius: 20px;
  text-align: center;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s;
  /* Added max-width to keep cards uniform */
  max-width: 380px;
  width: 100%;
  margin: 0 auto;
}

.clock-card canvas {
  width: 100% !important; /* Scale to card width */
  height: auto !important;
  max-width: 280px; /* Prevent over-stretching */
  aspect-ratio: 1/1;
}

.loading-text {
  color: var(--accent-color);
  font-size: 0.7rem;
  margin-top: 15px;
  font-weight: 700;
  letter-spacing: 2px;
}

/* --- PRECISION TIMER UI (TAB 2) --- */
.timer-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 30px 20px;
  width: 92%;
  max-width: 450px;
  margin: 0 auto;
  text-align: center;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.analog-timer-ui {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  margin: 0 auto 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#timerCanvas {
  width: 100%;
  height: 100%;
}

.timer-overlay {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#digitalTimer {
  font-family: "Monaco", "Consolas", monospace;
  font-size: clamp(2.2rem, 12vw, 3.2rem);
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
}

/* --- DIAL SELECTOR --- */
.dial-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 25px;
  background: #000;
  padding: 15px;
  border-radius: 12px;
}

.dial-col input {
  background: #0a0a0f;
  border: 1px solid #333;
  color: white;
  font-size: 1.1rem;
  padding: 10px;
  width: 55px;
  text-align: center;
  border-radius: 8px;
}

/* --- BUTTONS --- */
.button-group {
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
}
.btn-secondary {
  background: #27272a;
  color: #a1a1aa;
}

/* --- GLOBAL HEADINGS --- */
h1 {
  font-weight: 200;
  letter-spacing: 4px;
  color: #888;
  margin: 40px 0;
  text-align: center;
  font-size: 1.4rem;
}

.tab-pane {
  display: none;
  animation: slideUp 0.3s ease-out;
}

.tab-pane.active {
  display: block;
}

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