/* ===================================================================
   Play Now — Styles
   Light theme, mobile-first, clean & minimal
   =================================================================== */

/* --- Reset & Base -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Navbar -------------------------------------------------------- */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--gray-900);
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 12px; }
.nav-link {
  font-size: .875rem;
  color: var(--gray-700);
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background .15s;
}
.nav-link:hover { background: var(--gray-100); text-decoration: none; }
.nav-logout-form { display: inline; }
.nav-logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}

/* --- Container ----------------------------------------------------- */
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

/* --- Flash messages ------------------------------------------------ */
.flash-messages { margin-bottom: 16px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 8px;
}
.flash-success { background: var(--green-light); color: #166534; }
.flash-error { background: var(--red-light); color: #991b1b; }
.flash-info { background: var(--blue-light); color: #1e40af; }

/* --- Buttons ------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; border-color: var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 4px 10px; font-size: .8125rem; }
.btn-block { width: 100%; }
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--gray-500);
  transition: background .15s;
}
.btn-icon:hover { background: var(--gray-100); }
.btn-danger-icon { color: var(--red); }
.btn-danger-icon:hover { background: var(--red-light); }

/* --- Forms --------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--gray-700);
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  font-size: .875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.input-sm {
  padding: 6px 10px;
  font-size: .8125rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
}
.input-prefix-group {
  display: flex;
  align-items: stretch;
}
.input-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: .875rem;
  color: var(--gray-500);
}
.input-prefix-group input {
  border-radius: 0 var(--radius) var(--radius) 0;
}
.optional { color: var(--gray-400); font-weight: 400; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }
.edit-actions { display: flex; gap: 8px; margin-top: 8px; }

/* --- Auth pages ---------------------------------------------------- */
.auth-card {
  max-width: 400px;
  margin: 48px auto;
  background: #fff;
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 8px; text-align: center; }
.auth-subtitle { text-align: center; color: var(--gray-500); font-size: .875rem; margin-bottom: 24px; }
.auth-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--gray-400);
  font-size: .8125rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
.auth-divider span { padding: 0 12px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: .875rem; color: var(--gray-500); }

.btn-google {
  background: #fff;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  font-weight: 500;
}
.btn-google:hover { background: var(--gray-50); }
.google-icon { flex-shrink: 0; }

/* --- Dashboard ----------------------------------------------------- */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.dashboard-header h1 { font-size: 1.5rem; }
.meetup-list { display: flex; flex-direction: column; gap: 12px; }
.meetup-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  transition: box-shadow .15s;
}
.meetup-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.meetup-card h3 { font-size: 1rem; margin-bottom: 4px; }
.meetup-meta { display: flex; gap: 16px; font-size: .8125rem; color: var(--gray-500); }
.meetup-stats { display: flex; gap: 12px; margin-top: 6px; }
.meetup-stat {
  font-size: .75rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600, #4b5563);
}
.stat-pending { background: var(--amber-light); color: #92400e; }
.role-badge {
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.role-creator { background: var(--blue-light); color: #1e40af; }
.role-cocreator { background: var(--amber-light); color: #92400e; }
.role-player { background: var(--green-light); color: #166534; }
.empty-state { text-align: center; padding: 48px 0; color: var(--gray-500); }
.empty-state .btn { margin-top: 16px; }

/* --- Form page ----------------------------------------------------- */
.form-page { max-width: 560px; margin: 0 auto; }
.form-page h1 { font-size: 1.5rem; margin-bottom: 24px; }

/* --- Profile ------------------------------------------------------- */
.profile-page { max-width: 560px; margin: 0 auto; }
.profile-page h1 { font-size: 1.5rem; margin-bottom: 24px; }
.avatar-edit-section { margin-bottom: 24px; }
.profile-hint {
  text-align: center;
  color: var(--gray-500);
  font-size: .875rem;
  margin-bottom: 16px;
}
.emoji-hint {
  text-align: center;
  color: var(--gray-400);
  font-size: .8125rem;
  margin-top: 8px;
}
.avatar-preview-area {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 8px;
  width: fit-content;
  margin: 0 auto;
}
.avatar-upload-label {
  grid-column: 2;
  grid-row: 2;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.avatar-upload-hint {
  font-size: .75rem;
  color: var(--gray-400);
  margin-top: 4px;
}
.emoji-picker-slot[data-position="tl"] { grid-column: 1; grid-row: 1; }
.emoji-picker-slot[data-position="tr"] { grid-column: 3; grid-row: 1; }
.emoji-picker-slot[data-position="bl"] { grid-column: 1; grid-row: 3; }
.emoji-picker-slot[data-position="br"] { grid-column: 3; grid-row: 3; }
.emoji-trigger {
  width: 36px;
  height: 36px;
  border: 2px dashed var(--gray-300);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s;
}
.emoji-trigger:hover { border-color: var(--blue); }
.emoji-picker-container {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

/* --- Avatar component ---------------------------------------------- */
.avatar-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.avatar-img {
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.avatar-img-large { width: 96px; height: 96px; }
.avatar-placeholder {
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(var(--avatar-size) * 0.45);
}
.avatar-placeholder-large { width: 96px; height: 96px; font-size: 2.5rem; }
.avatar-emoji {
  position: absolute;
  font-size: calc(var(--avatar-size) * 0.3);
  line-height: 1;
  pointer-events: none;
}
.emoji-tl { top: -4px; left: -4px; }
.emoji-tr { top: -4px; right: -4px; }
.emoji-bl { bottom: 16px; left: -4px; }
.emoji-br { bottom: 16px; right: -4px; }
.avatar-handle {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: 2px;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  position: relative;
}
.avatar-handle:hover { color: var(--blue); }
.copied-tooltip {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  font-size: .6875rem;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  animation: fadeout 1.5s forwards;
}
@keyframes fadeout {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Meetup page --------------------------------------------------- */
.meetup-page { max-width: 720px; margin: 0 auto; }
.meetup-header {
  background: #fff;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.meetup-header-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.meetup-title-area { display: flex; align-items: center; gap: 8px; }
.meetup-name { font-size: 1.5rem; }
.slot-availability { margin-bottom: 12px; }
.availability-badge {
  display: inline-block;
  font-size: .875rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--blue-light);
  color: #1e40af;
}
.meetup-info p { margin-bottom: 6px; font-size: .9rem; }
.meetup-edit-form { margin-bottom: 16px; }
.meetup-creator-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}
.meetup-creator-info .label,
.co-creators-section .label {
  font-size: .8125rem;
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.co-creators-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
}
.co-creators-list { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.co-creator-item { display: flex; align-items: center; gap: 4px; }
.add-cocreator-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* --- Court cards --------------------------------------------------- */
.courts-section { display: flex; flex-direction: column; gap: 20px; }
.court-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.court-header { margin-bottom: 16px; }
.court-title-row { display: flex; justify-content: space-between; align-items: center; }
.court-name { font-size: 1.125rem; }
.court-actions { display: flex; gap: 4px; }
.court-meta { font-size: .875rem; color: var(--gray-500); margin-top: 4px; display: flex; gap: 16px; }
.court-price { font-weight: 500; }
.court-payment-link { font-size: .8125rem; word-break: break-all; }
.court-notes { font-size: .8125rem; color: var(--gray-500); margin-top: 6px; }
.court-edit-form { margin-bottom: 16px; padding: 12px; background: var(--gray-50); border-radius: var(--radius); }

/* --- Slot grid (2x2) ---------------------------------------------- */
.slot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.slot {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 120px;
  justify-content: center;
}
.slot-empty {
  border-style: dashed;
  background: var(--gray-50);
}
.slot-unconfirmed {
  border-color: var(--amber);
  background: #fffbeb;
}
.slot-confirmed {
  border-color: var(--green);
  background: #f0fdf4;
}
.slot-status-badge {
  font-size: .6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-unconfirmed { background: var(--amber-light); color: #92400e; }
.badge-confirmed { background: var(--green-light); color: #166534; }
.slot-creator-actions { display: flex; gap: 4px; margin-top: 4px; }

/* --- Creator controls ---------------------------------------------- */
.creator-controls { margin-top: 24px; }
.add-court-form {
  margin-top: 20px;
  background: #fff;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.add-court-form h3 { font-size: 1rem; margin-bottom: 12px; }
.danger-zone {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

/* --- Share button -------------------------------------------------- */
.btn-share { white-space: nowrap; }

/* --- Admin --------------------------------------------------------- */
.admin-page { max-width: 960px; margin: 0 auto; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-header h1 { font-size: 1.5rem; }
.admin-section { margin-bottom: 32px; }
.admin-section h2 { font-size: 1.125rem; margin-bottom: 12px; color: var(--gray-700); }
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.admin-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-700);
  font-size: .8125rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.admin-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--gray-200);
  color: var(--gray-700);
}
.admin-table tr:hover td { background: var(--gray-50); }

/* --- Responsive ---------------------------------------------------- */
@media (max-width: 640px) {
  .nav-inner { padding: 0 12px; }
  .container { padding: 16px 12px; }
  .meetup-header { padding: 16px; }
  .meetup-header-top { flex-direction: column; gap: 8px; }
  .meetup-name { font-size: 1.25rem; }
  .court-card { padding: 12px; }
  .form-row { flex-direction: column; gap: 0; }
  .dashboard-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .meetup-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .slot-grid { gap: 8px; }
  .slot { padding: 8px; min-height: 90px; }
  .slot .btn-sm { padding: 3px 8px; font-size: .75rem; }
  .slot-creator-actions { flex-wrap: wrap; justify-content: center; }
  .auth-card { margin: 24px 12px; padding: 24px 20px; }
  .add-cocreator-form { flex-wrap: wrap; }
  .co-creators-list { gap: 8px; }
  .btn-share { width: 100%; }
}
