/* =====================================================
   CANCHA SEGURA – Global Styles
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --green: #22c55e;
  --green-dim: #15803d;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #f1f5f9;
  --subtext: #94a3b8;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── NAVBAR ─── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.4rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -.02em;
}

.navbar .logo img {
  height: 32px;
  width: auto;
}

.navbar .logo .tu {
  color: #1e3a5f;
}

.navbar .logo .hora {
  color: var(--green);
}

.navbar .field-name {
  font-size: .85rem;
  color: var(--subtext);
}

/* ─── LEGEND ─── */
.legend {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: .75rem 1.5rem;
  font-size: .78rem;
  color: var(--subtext);
}

.legend span {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot.green {
  background: var(--green);
}

.dot.yellow {
  background: var(--yellow);
}

.dot.red {
  background: var(--red);
}

/* ─── WEEK NAV ─── */
.week-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem .5rem;
}

.week-nav button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .4rem .9rem;
  cursor: pointer;
  font-size: .9rem;
  transition: background .2s;
}

.week-nav button:hover {
  background: var(--border);
}

.week-nav .week-label {
  font-weight: 600;
  font-size: .95rem;
}

/* ─── CALENDAR GRID ─── */
.calendar-wrapper {
  overflow-x: auto;
  padding: 0 1rem 2rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 70px repeat(7, 1fr);
  min-width: 750px;
  gap: 2px;
}

.col-header {
  text-align: center;
  padding: .6rem .3rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.col-header.today-col {
  color: var(--green);
}

.time-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: .6rem;
  font-size: .7rem;
  color: var(--subtext);
  height: 48px;
}

.slot {
  height: 48px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.slot.available {
  background: var(--surface);
  border: 1px solid var(--border);
  color: transparent;
}

.slot.available:hover {
  background: rgba(34, 197, 94, .15);
  border-color: var(--green);
  color: var(--green);
  transform: scale(1.03);
}

.slot.available:hover::after {
  content: 'RESERVAR';
}

.slot.pending {
  background: rgba(245, 158, 11, .15);
  border: 1px solid var(--yellow);
  color: var(--yellow);
  cursor: default;
}

.slot.pending::after {
  content: 'EN ESPERA';
}

.slot.confirmed {
  background: rgba(239, 68, 68, .18);
  border: 1px solid var(--red);
  color: var(--red);
  cursor: default;
}

.slot.confirmed::after {
  content: 'OCUPADO';
}

/* ─── MODAL ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  animation: slideUp .25s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

.modal .slot-info {
  font-size: .85rem;
  color: var(--subtext);
  margin-bottom: 1.2rem;
}

.nequi-box {
  background: rgba(34, 197, 94, .1);
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.2rem;
  font-size: .9rem;
  line-height: 1.6;
}

.nequi-box strong {
  color: var(--green);
  font-size: 1.1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: .8rem;
  color: var(--subtext);
  margin-bottom: .4rem;
}

.form-group input[type="text"],
.form-group input[type="file"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .65rem .9rem;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}

.form-group input:focus {
  border-color: var(--green);
}

.form-group input[type="file"] {
  padding: .5rem;
  cursor: pointer;
}

.upload-preview {
  margin-top: .5rem;
  border-radius: 8px;
  overflow: hidden;
  display: none;
}

.upload-preview img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
}

.btn-row {
  display: flex;
  gap: .75rem;
  margin-top: 1.2rem;
}

.btn {
  flex: 1;
  padding: .75rem;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
}

.btn:active {
  transform: scale(.97);
}

.btn-primary {
  background: var(--green);
  color: #0f172a;
}

.btn-primary:hover {
  opacity: .9;
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--subtext);
}

.btn-ghost:hover {
  background: var(--border);
}

/* ─── SUCCESS/ERROR TOAST ─── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: .75rem 1.5rem;
  font-size: .9rem;
  font-weight: 500;
  transition: transform .3s ease;
  z-index: 300;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--green);
  color: var(--green);
}

.toast.error {
  border-color: var(--red);
  color: var(--red);
}

/* ─── ADMIN ─── */
.admin-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.admin-layout h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.admin-layout h1 span {
  color: var(--green);
}

.login-card {
  max-width: 380px;
  margin: 6rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

.login-card p {
  font-size: .85rem;
  color: var(--subtext);
  margin-bottom: 1.5rem;
}

.login-card input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .7rem 1rem;
  font-family: inherit;
  font-size: .95rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color .2s;
}

.login-card input:focus {
  border-color: var(--green);
}

.admin-error {
  color: var(--red);
  font-size: .82rem;
  margin-top: .5rem;
}

.reservas-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.reserva-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.reserva-thumb {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s;
}

.reserva-thumb:hover {
  transform: scale(1.05);
}

.reserva-info {
  flex: 1;
  min-width: 160px;
}

.reserva-info .cliente {
  font-size: 1rem;
  font-weight: 700;
}

.reserva-info .detalle {
  font-size: .82rem;
  color: var(--subtext);
  margin-top: .25rem;
  line-height: 1.6;
}

.reserva-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.btn-confirm {
  background: rgba(34, 197, 94, .15);
  border: 1px solid var(--green);
  color: var(--green);
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.btn-confirm:hover {
  background: rgba(34, 197, 94, .3);
}

.btn-reject {
  background: rgba(239, 68, 68, .1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.btn-reject:hover {
  background: rgba(239, 68, 68, .25);
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--subtext);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: .75rem;
}

/* ─── SETUP ─── */
.setup-card {
  max-width: 480px;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
}

.setup-card h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: .4rem;
}

.setup-card h1 span {
  color: var(--green);
}

.setup-card .subtitle {
  font-size: .88rem;
  color: var(--subtext);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.setup-card .section-title {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--subtext);
  margin-bottom: .75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.setup-card .section-title:first-of-type {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

/* ─── IMAGE LIGHTBOX ─── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .85);
  z-index: 500;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .6);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 600px) {
  .modal {
    padding: 1.5rem 1.2rem;
  }

  .reserva-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ─── COURT TABS ─── */
.court-tabs-wrapper {
  padding: .75rem 1.5rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.court-tabs {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.court-tabs::-webkit-scrollbar { display: none; }

.court-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .55rem 1.1rem;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--subtext);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.court-tab:hover {
  background: rgba(255,255,255,.05);
  color: var(--text);
}

.court-tab.active {
  background: var(--bg);
  border-color: var(--border);
  color: var(--green);
  border-bottom: 2px solid var(--bg);
  margin-bottom: -1px;
}

.court-tab-name {
  font-size: .85rem;
  font-weight: 600;
}

.court-tab-type {
  font-size: .65rem;
  font-weight: 500;
  opacity: .7;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ─── ADMIN TABS ─── */
.admin-tabs {
  display: flex;
  gap: .4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.admin-tab-btn {
  padding: .6rem 1.1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--subtext);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.admin-tab-btn:hover {
  color: var(--text);
}

.admin-tab-btn.active {
  color: var(--green);
  border-bottom-color: var(--green);
  font-weight: 600;
}

/* ─── CANCHA ROWS ─── */
.canchas-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.cancha-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  transition: opacity .2s;
}

.cancha-row.inactive {
  opacity: .5;
}

.cancha-row-nombre {
  font-weight: 700;
  font-size: .95rem;
  margin-bottom: .2rem;
}

.cancha-row-meta {
  font-size: .8rem;
  color: var(--subtext);
}

.cancha-row-meta strong {
  color: var(--green);
}

.cancha-row-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.btn-edit-cancha {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--subtext);
  padding: .4rem .85rem;
  border-radius: 7px;
  font-family: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s;
}

.btn-edit-cancha:hover {
  background: var(--border);
  color: var(--text);
}

.btn-toggle-cancha {
  padding: .4rem .85rem;
  border-radius: 7px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-toggle-cancha.on {
  background: rgba(34,197,94,.12);
  border: 1px solid var(--green);
  color: var(--green);
}

.btn-toggle-cancha.off {
  background: rgba(239,68,68,.1);
  border: 1px solid var(--red);
  color: var(--red);
}

/* ─── EDIT FORM ─── */
.cancha-edit-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.edit-form-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.edit-form-row input,
.edit-form-row select {
  flex: 1;
  min-width: 120px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .6rem .9rem;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}

.edit-form-row input:focus,
.edit-form-row select:focus {
  border-color: var(--green);
}

/* ─── REGISTRO CARD ─── */
.registro-card {
  max-width: 480px;
  margin: 2.5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.8rem;
}

.registro-card .form-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .65rem .9rem;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  margin: 0;
}

.registro-card .form-group input:focus {
  border-color: var(--green);
}

.section-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--subtext);
  margin-bottom: .75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ─── URL DISPLAY BOX ─── */
.url-display-box {
  background: rgba(34,197,94,.07);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: 8px;
  padding: .65rem .85rem;
  margin-bottom: 1rem;
  text-align: left;
}

/* ─── WHATSAPP BTN ─── */
.btn-wa {
  background: rgba(37,211,102,.15);
  border: 1px solid #25d366;
  color: #25d366;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  transition: background .15s;
}

.btn-wa:hover {
  background: rgba(37,211,102,.3);
}

/* ─── RESPONSIVE (additions) ─── */
@media (max-width: 600px) {
  .court-tabs-wrapper { padding: .5rem 1rem 0; }
  .admin-tabs { overflow-x: auto; scrollbar-width: none; }
  .cancha-row { flex-direction: column; align-items: flex-start; }
  .edit-form-row { flex-direction: column; }
}
