/* =============================================================================
   PADEL APP — THEME SYSTEM + FULL STYLES
   ============================================================================= */

/* =============================================================================
   CSS CUSTOM PROPERTIES
   ============================================================================= */

:root,
:root[data-theme="light"] {
  --bg-page: #f5f5f0;
  --bg-card: #ffffff;
  --bg-card-border: #e0ded8;
  --bg-active: #4a6055;
  --bg-active-light: #d0e8e0;
  --bg-slot: #ffffff;
  --bg-slot-selected: #d0e8e0;
  --bg-slot-full: #ffe3e3;
  --bg-slot-past: #f5f5f5;
  --bg-slot-incomplete:     #fef3c7;
  --bg-match: #d0e8e0;
  --bg-match-incomplete:    #fffbeb;

  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #888880;
  --text-on-active: #ffffff;
  --text-accent: #4a6055;

  --border-default: #e0ded8;
  --border-active: #4a6055;
  --border-slot-full: #f08080;
  --border-slot-past: #dddddd;
  --border-slot-incomplete: #f59e0b;
  --border-match: #4a6055;
  --border-match-incomplete: #f59e0b;
  --text-incomplete:         #92400e;
  --border-header: rgba(0, 0, 0, 0.08);

  --accent: #4a6055;
  --accent-text: #ffffff;
  --accent-light: #eaf2ef;

  --badge-bg: #eaf2ef;
  --badge-text: #2d5a4a;

  --slot-count-bg: #eaf2ef;
  --slot-count-text: #4a6055;

  --slot-full-text: #800000;
  --slot-full-count-bg: #ffd3d3;

  --cancel-color: #922b21;
  --cancel-bg-hover: rgba(146, 43, 33, 0.08);

  --toast-success-bg: #d4edda;
  --toast-success-fg: #155724;
  --toast-success-br: #c3e6cb;
  --toast-error-bg: #f8d7da;
  --toast-error-fg: #721c24;
  --toast-error-br: #f5c6cb;

  --footer-text: rgba(0, 0, 0, 0.3);
  --footer-border: rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
  --bg-page: #2d3d38;
  --bg-card: #3d5048;
  --bg-card-border: #4a6055;
  --bg-active: #d4f53c;
  --bg-active-light: #3d5048;
  --bg-slot: #3d5048;
  --bg-slot-selected: #d4f53c;
  --bg-slot-full: #7a2020;
  --bg-slot-past: #2a3830;
  --bg-slot-incomplete:     #3d3000;
  --bg-match: #3d5048;
  --bg-match-incomplete:    #2d2500;

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted: rgba(255, 255, 255, 0.4);
  --text-on-active: #1a2e1e;
  --text-accent: #d4f53c;

  --border-default: #4a6055;
  --border-active: #d4f53c;
  --border-slot-full: #c05050;
  --border-slot-past: #3a4a42;
  --border-slot-incomplete: #d97706;
  --border-match: #d4f53c;
  --border-match-incomplete: #d97706;
  --text-incomplete:         #fbbf24;
  --border-header: rgba(255, 255, 255, 0.08);

  --accent: #d4f53c;
  --accent-text: #1a2e1e;
  --accent-light: #3d5048;

  --badge-bg: #3d5048;
  --badge-text: #d4f53c;

  --slot-count-bg: #3d5048;
  --slot-count-text: #d4f53c;

  --slot-full-text: #ffaaaa;
  --slot-full-count-bg: rgba(255, 170, 170, 0.12);

  --cancel-color: #c0392b;
  --cancel-bg-hover: rgba(192, 57, 43, 0.12);

  --toast-success-bg: #1e3d2a;
  --toast-success-fg: #6fcf97;
  --toast-success-br: #2d5a3d;
  --toast-error-bg: #3d1e1e;
  --toast-error-fg: #ff6b6b;
  --toast-error-br: #5a2d2d;

  --footer-text: rgba(255, 255, 255, 0.25);
  --footer-border: rgba(255, 255, 255, 0.08);
}

/* =============================================================================
   BASE
   ============================================================================= */

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-page);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0 auto;
  padding: 20px;
  background: var(--bg-page);
  color: var(--text-primary);
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =============================================================================
   MAIN CONTENT WRAPPER
   Matches hero min-height so footer stays pinned when hero → auth card swap.
   ============================================================================= */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* =============================================================================
   HERO SCREEN
   Hero is always green — hardcoded intentionally, not themed.
   ============================================================================= */

#hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 1;
  min-height: 360px;
  background: #4a6055;
}

#hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 40px,
    rgba(255, 255, 255, 0.015) 40px,
    rgba(255, 255, 255, 0.015) 41px
  );
  pointer-events: none;
}

#heroInner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: opacity 0.3s ease;
}
#heroInner.fading {
  opacity: 0;
  pointer-events: none;
}

.hero-logo {
  font-family: Georgia, serif;
  font-size: clamp(48px, 8vw, 80px);
  font-weight: 300;
  color: #fff;
  letter-spacing: -2px;
  line-height: 1;
  margin: 0;
  animation: hero-hit 3.2s ease-in-out infinite;
}
@keyframes hero-hit {
  0%,
  33% {
    opacity: 1;
    transform: translateY(0);
  }
  35% {
    opacity: 0.35;
    transform: translateY(-2px);
  }
  37% {
    opacity: 1;
    transform: translateY(0);
  }
  39% {
    opacity: 0.65;
    transform: translateY(-1px);
  }
  41% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-sep {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 14px;
}
.hero-sep__line {
  display: block;
  width: 60px;
  height: 1px;
  background: #d4f53c;
  opacity: 0.5;
}
.hero-sep__dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d4f53c;
  flex-shrink: 0;
  animation: hero-ball 3.2s ease-in-out infinite;
}
@keyframes hero-ball {
  0% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
  }
  35% {
    transform: translateY(-35px);
    animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1);
  }
  65% {
    transform: translateY(0);
    animation-timing-function: ease;
  }
  100% {
    transform: translateY(0);
  }
}

.hero-tagline {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin: 0 0 40px;
}

#heroLoginBtn {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 10px 32px;
  border-radius: 2px;
  cursor: pointer;
  transition:
    color 0.2s,
    border-color 0.2s;
  width: auto;
  margin: 0;
}
#heroLoginBtn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}

#heroReveal {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #d4f53c;
  clip-path: circle(0% at 50% 50%);
  pointer-events: none;
}
#heroReveal.active {
  clip-path: circle(150% at 50% 50%);
  transition: clip-path 1.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#authCard.from-hero {
  animation: authSlideIn 0.35s ease forwards;
}
@keyframes authSlideIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================================================
   HEADER
   ============================================================================= */

header {
  display: flex;
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-header);
  margin-bottom: 20px;
  gap: 12px;
}
header h1 {
  margin: 0;
  font-size: 22px;
  color: var(--text-muted);
  font-weight: 300;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  overflow: hidden;
}
.lang-toggle button {
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.lang-toggle button.active {
  background: var(--accent);
  color: var(--accent-text);
}

#themeToggleBtn {
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: var(--text-muted);
}

#userChip {
  display: none;
  font-size: 14px;
  color: var(--text-secondary);
  align-items: center;
  gap: 6px;
}
#userChip strong {
  color: var(--text-primary);
}
.user-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
#adminLink {
  color: var(--text-accent);
  text-decoration: none;
}
#adminLink:hover {
  text-decoration: underline;
}
#logoutBtn {
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* =============================================================================
   BREADCRUMB
   ============================================================================= */

#breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  margin-bottom: 16px;
  margin-top: -8px;
}

/* =============================================================================
   AUTH CARD
   ============================================================================= */

#authCard {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  margin: auto;
}
#authCard h2 {
  margin-top: 0;
  color: var(--text-primary);
}
#authCard input {
  width: 100%;
  padding: 10px;
  margin: 6px 0;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
}
#authCard button {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
.auth-error {
  color: var(--cancel-color);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}
.auth-toggle {
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.auth-toggle a {
  color: var(--text-accent);
  cursor: pointer;
  text-decoration: underline;
}


#app {
  width: 100%;
}

/* =============================================================================
   WELCOME BLOCK
   ============================================================================= */

#welcome {
  margin: 4px 0 20px;
}
#welcome h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
#welcome p {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* =============================================================================
   UPCOMING MATCH BANNER
   ============================================================================= */

#upcomingBanner {
  margin-bottom: 20px;
}

/* --- Upcoming match accordion ------------------------------------------- */
.upcoming-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.upcoming-card + .upcoming-card {
  margin-top: 6px;
}
.upcoming-card.is-expanded {
  border-color: var(--border-active);
  border-width: 2px;
  padding: 11px 13px; /* compensate for extra border px */
}
.match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.match-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.upcoming-time {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.upcoming-venue {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-top: 2px;
}
.upcoming-loc-link {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upcoming-loc-link:hover {
  text-decoration: underline;
}
.upcoming-court {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.match-expand {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-default);
}
.upcoming-players-line {
  font-size: 13px;
  color: var(--text-secondary);
}
.btn-cancel-spot {
  flex-shrink: 0;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--cancel-color);
  border-radius: 4px;
  color: var(--cancel-color);
  font-size: 12px;
  cursor: pointer;
}
.btn-cancel-spot:hover {
  background: var(--cancel-bg-hover);
}
.btn-cancel-spot:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.upcoming-more-list { display: flex; flex-direction: column; gap: 8px; }
.btn-load-more {
  align-self: center;
  margin-top: 6px;
  background: none;
  border: 1px solid var(--border-active);
  color: var(--text-accent);
  border-radius: 6px;
  padding: 5px 16px;
  font-size: 13px;
  cursor: pointer;
}
.btn-load-more:hover { background: var(--accent-light); }
/* btn-maps kept for venue card */
.btn-maps {
  background: var(--accent-light);
  color: var(--text-accent);
  border: 1px solid var(--border-active);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}

.venue-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.venue-info {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.venue-pin {
  font-size: 14px;
  line-height: 1.5;
  flex-shrink: 0;
}
.venue-location {
  font-size: 14px;
  color: var(--text-secondary);
}
.venue-court {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

#upcomingToast {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.toast-success {
  background: var(--toast-success-bg);
  color: var(--toast-success-fg);
  border: 1px solid var(--toast-success-br);
}
.toast-error {
  background: var(--toast-error-bg);
  color: var(--toast-error-fg);
  border: 1px solid var(--toast-error-br);
}

/* =============================================================================
   DAY PICKER
   ============================================================================= */

#monthHeaders {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 2px;
}
.month-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-default);
  padding: 0 4px 6px;
}
#dayCards {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
}
.day-card {
  flex: 0 0 72px;
  text-align: center;
  padding: 10px 6px;
  background: var(--bg-card);
  border: 2px solid var(--border-default);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  color: var(--text-primary);
}
.day-card:hover {
  border-color: var(--accent);
}
.day-card .dow {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.day-card .day {
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
}
.day-card.today .dow {
  color: var(--text-accent);
}
.day-card.selected {
  border-color: var(--border-active);
  background: var(--bg-active);
  color: var(--text-on-active);
}
.day-card.selected .dow {
  color: var(--text-on-active);
  opacity: 0.75;
}

/* =============================================================================
   SLOT GRID
   ============================================================================= */

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text-primary);
}
#slotsContainer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.slot-tile {
  padding: 14px;
  background: var(--bg-slot);
  border: 2px solid var(--border-default);
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: 0.15s;
  font-weight: 500;
  position: relative;
  color: var(--text-primary);
}
.slot-tile:hover {
  border-color: var(--accent);
}
.slot-selected {
  border-color: var(--border-active);
  background: var(--bg-slot-selected);
  color: var(--text-on-active);
}
.slot-full {
  background: var(--bg-slot-full) !important;
  border-color: var(--border-slot-full) !important;
  color: var(--slot-full-text);
  cursor: not-allowed;
}
.slot-past {
  background: var(--bg-slot-past) !important;
  border-color: var(--border-slot-past) !important;
  color: var(--text-muted);
  cursor: not-allowed;
}
.slot-blocked {
  background: var(--bg-slot-past) !important;
  border-color: var(--border-slot-past) !important;
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.55;
}
.slot-count {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--slot-count-text);
  background: var(--slot-count-bg);
  border-radius: 999px;
  padding: 1px 6px;
}
.slot-full .slot-count {
  color: var(--slot-full-text);
  background: var(--slot-full-count-bg);
}
.slot-incomplete {
  background: var(--bg-slot-incomplete) !important;
  border-color: var(--border-slot-incomplete) !important;
  cursor: not-allowed;
}

/* =============================================================================
   DAY OVERVIEW
   ============================================================================= */

.overview {
  margin-top: 28px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 8px;
}
.overview h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.overview h3 .title-date {
  color: var(--text-accent);
  font-weight: 700;
}
.overview-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
}
.match-card {
  background: var(--bg-match);
  border: 1px solid var(--border-match);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.match-card--incomplete {
  background: var(--bg-match-incomplete);
  border-color: var(--border-match-incomplete);
}
.match-incomplete-label {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-incomplete);
}
.match-card .time {
  font-weight: 700;
  color: var(--text-accent);
}
.match-card .players {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-primary);
}
.match-card .reserve {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}
.match-my-status {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.match-my-status--playing {
  background: var(--toast-success-bg);
  color: var(--toast-success-fg);
}
.match-my-status--reserve {
  background: #fff3cd;
  color: #856404;
}
.btn-waitlist {
  margin-top: 8px;
  padding: 4px 12px;
  background: transparent;
  border: 1px solid var(--border-active);
  border-radius: 4px;
  color: var(--text-accent);
  font-size: 12px;
  cursor: pointer;
  display: block;
}
.btn-waitlist:hover {
  background: var(--accent-light);
}
.btn-waitlist:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.slot-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px dashed var(--border-default);
  align-items: baseline;
}
.slot-row:first-of-type {
  border-top: none;
}
.slot-row .time {
  font-weight: 600;
  min-width: 56px;
  color: var(--text-primary);
}
.slot-row .names {
  color: var(--text-secondary);
  font-size: 13px;
}
.slot-row .badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

/* =============================================================================
   SUBMIT BUTTON
   ============================================================================= */

#submitBtn {
  margin-top: 16px;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
#submitBtn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

/* =============================================================================
   FOOTER
   ============================================================================= */

footer {
  margin-top: 48px;
  padding: 20px 0;
  border-top: 1px solid var(--footer-border);
  font-size: 12px;
  color: var(--footer-text);
  text-align: center;
  line-height: 1.9;
}
footer a {
  color: var(--footer-text);
  text-decoration: underline;
}
footer a:hover {
  opacity: 0.75;
}

.hidden {
  display: none !important;
}

/* =============================================================================
   MOBILE
   ============================================================================= */

@media (max-width: 600px) {
  body {
    padding: 14px;
  }
  header {
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 14px;
  }
  header h1 {
    font-size: 18px;
    flex: 1;
  }
  .header-controls {
    margin-left: 0;
  }
  #userChip {
    flex: 1 1 100%;
    font-size: 13px;
    white-space: nowrap;
  }
  #userChipName {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #welcome h2 {
    font-size: 22px;
  }
  #welcome p {
    font-size: 13px;
  }
  #slotsContainer {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .slot-tile {
    padding: 12px 6px;
    font-size: 14px;
  }
  .day-card {
    flex: 0 0 64px;
    padding: 8px 4px;
  }
  .day-card .day {
    font-size: 20px;
  }
}
