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

:root {
  --primary: #1F2235;
  --primary-light: #2a2d42;
  --background: #F5F6F8;
  --white: #ffffff;
  --text-primary: #1F2235;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --border: rgba(255, 255, 255, 0.12);
  --booked: #800020;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: var(--primary);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  margin: 0 auto;
  position: relative;
  width: 100%;
}

.location-btn {
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.location-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dropdown-arrow {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

.location-btn.open .dropdown-arrow {
  transform: rotate(180deg);
}

.refresh-btn {
  background: transparent;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 0;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.refresh-btn svg {
  width: 20px;
  height: 20px;
}

.refresh-btn.spinning svg {
  animation: spin 1s linear infinite;
}

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

/* Date Selector */
.date-selector {
  background: var(--primary);
  border-radius: 0 0 20px 20px;
  padding: 16px;
  padding-bottom: 24px;
  width: 100%;
  overflow: hidden;
}

.date-scroll {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
}

.date-scroll::-webkit-scrollbar {
  display: none;
}

.date-item {
  flex-shrink: 0;
  width: 65px;
  height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.date-item:not(.selected) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.date-item.selected {
  background: var(--white);
}

.date-item.today:not(.selected) {
  position: relative;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.day-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.date-item:not(.selected) .day-name {
  color: rgba(255, 255, 255, 0.7);
}

.date-item.selected .day-name {
  color: var(--primary);
}

.day-number {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

.date-item:not(.selected) .day-number {
  color: var(--white);
}

.date-item.selected .day-number {
  color: var(--primary);
}

.today-badge {
  font-size: 9px;
  font-weight: 900;
  color: var(--white);
  margin-top: 2px;
  position: absolute;
  bottom: 6px;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(31, 34, 53, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinner 0.8s linear infinite;
}

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

.loading-state p {
  color: var(--text-light);
  margin-top: 16px;
  font-size: 14px;
}

/* Error State */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.error-icon {
  width: 48px;
  height: 48px;
  color: var(--text-light);
}

.error-state p {
  color: var(--text-light);
  margin-top: 16px;
  line-height: 1.5;
}

.retry-btn {
  margin-top: 24px;
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.retry-btn:hover {
  background: var(--primary-light);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: #D1D5DB;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 16px;
}

.empty-state p {
  color: #6B7280;
  margin-top: 8px;
  line-height: 1.5;
}

/* Court Cards */
.courts-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.court-card {
  background: var(--white);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.court-header {
  background: var(--primary);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.court-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.court-icon {
  width: 20px;
  height: 20px;
  color: var(--white);
}

.court-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

.court-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
}

.court-badge.full {
  background: var(--booked);
}

.court-body {
  padding: 16px;
  background: var(--white);
}

.slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.slot {
  width: 80px;
  height: 55px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.slot.available {
  background: var(--primary);
  border: 2px solid var(--primary);
}

.slot.booked {
  background: var(--booked);
  border: 2px solid var(--booked);
}

.slot.booked .slot-time,
.slot.booked .slot-divider,
.slot.booked .slot-end {
  opacity: 0.5;
  text-decoration: line-through;
  text-decoration-color: var(--white);
  text-decoration-thickness: 2px;
}

.slot-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
}

.slot-divider {
  width: 40px;
  height: 1px;
  background: rgba(255, 255, 255, 0.54);
  margin: 2px 0;
}

.slot-end {
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
}

.no-slots {
  text-align: center;
  padding: 8px;
  color: var(--text-light);
}

/* Location Menu Overlay */
.location-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
}

.location-menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
}

.location-menu {
  position: absolute;
  top: 65px;
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  max-width: calc(100vw - 32px);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  animation: menuOpen 0.2s ease-out forwards;
  z-index: 201;
}

@keyframes menuOpen {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.location-option {
  padding: 15px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.location-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.location-option.selected {
  background: rgba(255, 255, 255, 0.1);
}

.location-option span {
  color: var(--white);
  font-size: 16px;
}

.location-option.selected span {
  font-weight: 700;
}

.check-icon {
  width: 16px;
  height: 16px;
  color: var(--white);
  display: none;
}

.location-option.selected .check-icon {
  display: block;
}

/* Dim layer when menu is open */
.dim-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: 150;
}

/* Responsive */
@media (max-width: 480px) {
  .date-item {
    width: 60px;
    height: 68px;
  }
  
  .slot {
    width: 70px;
    height: 50px;
  }
  
  .slot-time {
    font-size: 12px;
  }
  
  .slot-end {
    font-size: 10px;
  }
}

/* Animations */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-up {
  animation: slideUp 0.3s ease;
}

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