:root {
  --bg-primary: #FAF9F6;
  --bg-secondary: #F3F1ED;
  --text-primary: #1A1A19;
  --text-secondary: #6B6A66;
  --text-muted: #9E9D98;
  --accent-orange: #FF6B35;
  --accent-orange-hover: #E0531F;
  --accent-orange-light: rgba(255, 107, 53, 0.08);
  --primary-gradient: linear-gradient(135deg, #FF6B35 0%, #FFA07A 100%);
  --border-color: #E6E4E0;
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition-speed: 0.2s;
  --max-width: 1400px;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.5rem 0.75rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Unified Header & Controls Dashboard */
.app-header-controls {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.01);
}

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

.brand-logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  text-transform: uppercase;
  cursor: pointer;
  line-height: 1;
}

.brand-logo:hover {
  opacity: 0.8;
}

.gradient-text {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  border-left: 1px solid var(--border-color);
  padding-left: 0.4rem;
  line-height: 1;
}

.nav-section {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
}

.date-range-display {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  padding: 0 0.15rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  transition: all var(--transition-speed);
  white-space: nowrap;
  flex-shrink: 0;
}

.text-btn:hover {
  color: var(--accent-orange);
}


/* Loading and Error States */
.loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-secondary);
  margin-bottom: 1rem;
}

.spinner {
  width: 1.8rem;
  height: 1.8rem;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.75rem;
}

.retry-btn {
  background: none;
  border: 1px solid var(--accent-orange);
  color: var(--accent-orange);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-weight: 500;
  transition: all var(--transition-speed);
}

.retry-btn:hover {
  background-color: var(--accent-orange);
  color: white;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

.schedule-display-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Columns Grid View (Default Mobile Stack) */
.schedule-columns-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.day-header {
  border-top: 2px solid var(--border-color);
  padding: 0.25rem 0.4rem;
  margin-top: 0.5rem;
  background-color: var(--bg-secondary);
  border-radius: 4px;
}

.day-header.is-today {
  border-top-color: var(--accent-orange);
  background-color: var(--accent-orange-light);
}

.day-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.day-header.is-today .day-name {
  color: var(--accent-orange);
}

.day-date {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 0.02rem;
  color: var(--text-primary);
}

.no-classes-msg {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border-color);
}

.slot-placeholder {
  display: none;
}


/* Desktop aligned 4-column Week View */
@media (min-width: 1024px) {
  .app-container {
    height: 100vh;
  }

  .schedule-columns-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: auto;
    grid-auto-rows: 1fr;
    column-gap: 0.4rem;
    row-gap: 0.2rem; /* tight gap between class cards vertically */
    align-items: stretch;
    flex-grow: 1;
    min-height: 0;
    margin-bottom: 0.5rem;
  }

  .day-header {
    grid-column: var(--col-idx);
    grid-row: 1;
    margin-top: 0;
    margin-bottom: 0.15rem;
    border-top: 2px solid var(--border-color);
    padding: 0.2rem 0.25rem;
  }

  .class-item {
    grid-column: var(--col-idx);
    grid-row: var(--row-idx);
    align-self: stretch;
  }

  .slot-placeholder {
    display: flex;
    align-items: center;
    grid-column: var(--col-idx);
    grid-row: var(--row-idx);
    background-color: rgba(26, 26, 25, 0.02); /* very light transparent gray */
    border: 1px solid rgba(26, 26, 25, 0.04);
    border-radius: 3px;
    height: 100%;
    min-height: 2.5rem;
  }

  .no-classes-msg {
    display: none;
  }
}

/* Class Card (Text style) */
.class-item {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0.4rem;
  background-color: white;
  border: 1px solid var(--border-color);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-speed) ease;
  position: relative;
  border-radius: 3px;
  min-height: 2.5rem;
  justify-content: center;
}

.class-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: var(--accent-orange);
  transform: scaleY(0);
  transition: transform var(--transition-speed) ease;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

.class-item:hover {
  background-color: var(--accent-orange-light);
  border-color: var(--accent-orange);
}

.class-item:hover::before {
  transform: scaleY(1);
}

/* Class details */
.class-time-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.05rem;
  gap: 0.25rem;
}

.class-time {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1;
  flex-shrink: 0;
}

.class-item:hover .class-time {
  color: var(--accent-orange);
}

.class-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  flex: 1;
  min-width: 0;
}

.class-instructor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.2rem;
}

.class-instructor {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Spots Badge */
.spots-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  padding: 0.02rem 0.2rem;
  border-radius: 2px;
  border: 1px solid var(--border-color);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
}

.class-item:hover .spots-badge {
  border-color: var(--text-muted);
}

/* Spots Progress Bar (Road-themed) */
.spots-progress-bar {
  width: 5rem;
  height: 0.9rem;
  background-color: #888888; /* Paler road */
  border: 1px solid var(--border-color);
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: 0.25rem;
  position: relative;
}

.spots-progress-bar::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-image: linear-gradient(to right, #FAF9F6 50%, transparent 50%);
  background-size: 5px 1px;
  transform: translateY(-50%);
  opacity: 0.6; /* More visible on pale background */
  z-index: 1;
}

.class-item:hover .spots-progress-bar {
  border-color: var(--text-muted);
}

.spots-progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 2px 0 0 2px;
  position: relative;
  z-index: 2;
}

.spots-progress-fill::after {
  content: '🚴';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%) scaleX(-1);
  font-size: 1.4rem; /* Prominent, visible cyclist scaled with the larger road */
  line-height: 1;
  z-index: 3;
}

/* Spots Custom Tooltip */
.spots-tooltip {
  position: absolute;
  bottom: 155%; /* Display above the road and cyclist */
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background-color: var(--text-primary);
  color: var(--bg-primary);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.spots-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px;
  border-style: solid;
  border-color: var(--text-primary) transparent transparent transparent;
}

.spots-progress-bar:hover .spots-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.spots-low {
  color: var(--accent-orange);
  border-color: var(--accent-orange-light);
  background-color: var(--accent-orange-light);
}

.spots-full {
  color: var(--text-muted);
  background-color: transparent;
  border-style: dashed;
}

.spots-waitlist {
  color: #c2410c;
  background-color: #ffedd5;
  border-color: #fed7aa;
}

/* Special Events Styling */
.class-item.is-special {
  background-color: rgba(255, 107, 53, 0.03);
  border-color: rgba(255, 107, 53, 0.15);
}

.class-item.is-special .class-title {
  color: var(--accent-orange);
}

/* Cancelled Styling */
.class-item.is-cancelled {
  opacity: 0.5;
  pointer-events: none;
}
.class-item.is-cancelled .class-title {
  text-decoration: line-through;
}


/* Footer styling */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.app-footer p {
  margin-bottom: 0.15rem;
}

/* Responsive Breakpoints */
@media (max-width: 1100px) {
  .app-header-controls {
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem;
  }
  
  .brand-section {
    justify-content: center;
  }
  
  .nav-section {
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 0.4rem 0.5rem;
  }
  
  .app-header-controls {
    gap: 0.4rem;
  }
  
  .brand-logo {
    font-size: 1.1rem;
  }
  
  .nav-section {
    gap: 0.15rem;
  }
  
  .date-range-display {
    font-size: 0.85rem;
    padding: 0 0.1rem;
  }
  
  .text-btn {
    font-size: 0.75rem;
    padding: 0.15rem 0.25rem;
  }
}
