/* ===== Paleta Ex-Cobachos =====
   Inspirada en el logo COBAQ (guinda), la arquitectura del plantel (rojo)
   y el uniforme de cuadros (azul marino, beige/arena, blanco). */
:root {
  --guinda: #7a1f2b;       /* logo COBAQ */
  --guinda-oscuro: #5c141d;
  --rojo: #c62828;         /* columnas del plantel */
  --marino: #1f2a44;       /* uniforme cuadros */
  --arena: #d9c6a3;        /* uniforme beige */
  --arena-claro: #f5efe6;  /* fondo suave */
  --blanco: #ffffff;
  --texto: #2a2320;
  --borde: #e4d9c6;
  --sombra: 0 6px 20px rgba(92, 20, 29, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--texto);
  background:
    linear-gradient(rgba(245,239,230,0.92), rgba(245,239,230,0.92)),
    repeating-linear-gradient(45deg, var(--arena) 0 14px, var(--arena-claro) 14px 28px);
  background-attachment: fixed;
  line-height: 1.55;
}

/* ===== Encabezado ===== */
.site-header {
  background: linear-gradient(135deg, var(--guinda), var(--guinda-oscuro));
  color: var(--blanco);
  border-bottom: 6px solid var(--rojo);
  box-shadow: var(--sombra);
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: var(--blanco);
  border-radius: 12px;
  padding: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.header-text h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 1px;
}
.subtitle {
  margin: 4px 0 0;
  opacity: 0.92;
  font-size: 0.98rem;
}

/* ===== Layout ===== */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.card {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: 14px;
  box-shadow: var(--sombra);
  padding: 22px;
  margin-bottom: 24px;
}

/* ===== Intro / WhatsApp ===== */
.intro p { margin-top: 0; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }

.btn-whatsapp {
  background: #25d366;
  color: #0a2e17;
}
.btn-whatsapp[data-placeholder="true"] {
  background: #cfd8d2;
  color: #5a6b61;
  cursor: not-allowed;
}
.btn-whatsapp:not([data-placeholder="true"]):hover {
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
}
.wa-note {
  font-size: 0.82rem;
  color: #6b625b;
  margin-bottom: 0;
}
.wa-note code {
  background: var(--arena-claro);
  padding: 1px 6px;
  border-radius: 5px;
}

/* ===== Toolbar tabla ===== */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.table-toolbar h2 {
  margin: 0;
  color: var(--guinda);
  font-size: 1.3rem;
}
.search {
  padding: 9px 14px;
  border: 1px solid var(--borde);
  border-radius: 999px;
  font-size: 0.92rem;
  min-width: 200px;
  outline: none;
}
.search:focus {
  border-color: var(--guinda);
  box-shadow: 0 0 0 3px rgba(122, 31, 43, 0.15);
}

/* ===== Tabla ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}
thead th {
  background: var(--marino);
  color: var(--blanco);
  text-align: left;
  padding: 12px 14px;
  font-size: 0.95rem;
  white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }

th.sortable {
  cursor: pointer;
  user-select: none;
}

/* Encabezado "Agregar al calendario": texto completo en escritorio,
   "Agregar" en móvil (ver media query). */
.th-short { display: none; }
th.sortable:hover { background: #2a3860; }
.sort-ind { margin-left: 6px; font-size: 0.8rem; opacity: 0.9; }
th.sort-asc .sort-ind::after { content: "▲"; }
th.sort-desc .sort-ind::after { content: "▼"; }

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--borde);
  vertical-align: middle;
}
tbody tr:nth-child(even) { background: var(--arena-claro); }
tbody tr:hover { background: #f2e3d8; }

.name-cell { font-weight: 600; }
.date-cell { white-space: nowrap; }
.today-badge {
  display: inline-block;
  margin-left: 8px;
  background: var(--rojo);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}

/* ===== Botones de calendario en celda ===== */
.cal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-cal {
  background: var(--guinda);
  color: #fff;
  padding: 7px 12px;
  font-size: 0.85rem;
}
.btn-cal:hover { box-shadow: 0 4px 12px rgba(122, 31, 43, 0.35); }
.btn-cal.secondary {
  background: transparent;
  color: var(--guinda);
  border: 1px solid var(--guinda);
}
.btn-cal.secondary:hover { background: rgba(122, 31, 43, 0.08); }

.empty-msg {
  text-align: center;
  color: #6b625b;
  padding: 18px;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--marino);
  color: #d7dbe6;
  text-align: center;
  padding: 18px 20px;
  font-size: 0.88rem;
}

/* ===== Responsive ===== */
@media (max-width: 560px) {
  .header-inner { flex-direction: column; text-align: center; }

  /* Buscador + Actualizar en una sola fila (el buscador se estira). */
  .toolbar-right {
    flex-wrap: nowrap;
    width: 100%;
  }
  .search { flex: 1; min-width: 0; }
  .btn-refresh { flex-shrink: 0; white-space: nowrap; }

  /* Encabezado corto en móvil: "Agregar". */
  .th-full { display: none; }
  .th-short { display: inline; }

  /* Mantener la tabla (no tarjetas), pero compacta para que quepa. */
  #birthdayTable { min-width: 0; }
  thead th,
  tbody td { padding: 8px 8px; }
  thead th { font-size: 0.82rem; }
  .name-cell, .date-cell { font-size: 0.85rem; }

  /* Botones de calendario: solo íconos, lado a lado para ahorrar espacio. */
  .cal-actions {
    flex-direction: row;
    gap: 6px;
    justify-content: center;
  }
  .btn-cal {
    padding: 7px 10px;
    font-size: 1rem;
    line-height: 1;
  }
  .btn-cal .btn-label { display: none; }  /* ocultar el texto, dejar el ícono */
}

/* ===== Formulario de Google (botón) ===== */
.intro-sep {
  border: none;
  border-top: 1px dashed var(--borde);
  margin: 20px 0 16px;
}
.add-note { margin: 0 0 12px; font-weight: 600; color: var(--guinda); }
.btn-form {
  background: var(--marino);
  color: #fff;
}
.btn-form[data-placeholder="true"] {
  background: #cfd2da;
  color: #5a607a;
  cursor: not-allowed;
}
.btn-form:not([data-placeholder="true"]):hover {
  box-shadow: 0 4px 14px rgba(31, 42, 68, 0.4);
}

/* ===== Gate de acceso (popup con contraseña) ===== */
.site-content {
  transition: filter 0.3s ease;
}
.site-content.locked {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(44, 12, 16, 0.45);
  backdrop-filter: blur(2px);
}
.gate[hidden] { display: none; }

.gate-card {
  background: var(--blanco);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 30px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  border-top: 6px solid var(--rojo);
  animation: gatePop 0.25s ease-out;
}
@keyframes gatePop {
  from { transform: translateY(10px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.gate-logo {
  width: 72px;
  height: auto;
  margin-bottom: 6px;
}
.gate-card h2 {
  margin: 4px 0 8px;
  color: var(--guinda);
}
.gate-text {
  margin: 0 0 18px;
  font-size: 0.92rem;
  color: #6b625b;
}
.gate-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--borde);
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  margin-bottom: 14px;
}
.gate-input:focus {
  border-color: var(--guinda);
  box-shadow: 0 0 0 3px rgba(122, 31, 43, 0.15);
}
.gate-btn {
  width: 100%;
  justify-content: center;
  background: var(--guinda);
  color: #fff;
  font-size: 1rem;
  padding: 12px;
}
.gate-btn:hover { box-shadow: 0 4px 14px rgba(122, 31, 43, 0.4); }
.gate-error {
  color: var(--rojo);
  font-size: 0.88rem;
  margin: 12px 0 0;
  font-weight: 600;
}

/* ===== Toolbar: búsqueda + botón actualizar ===== */
.toolbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.btn-refresh {
  background: var(--arena);
  color: var(--guinda-oscuro);
  padding: 9px 14px;
  font-weight: 600;
}
.btn-refresh:hover { box-shadow: 0 3px 10px rgba(122, 31, 43, 0.25); }
.btn-refresh:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

/* ===== Mensaje de estado (carga / error) ===== */
.status-msg {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  display: none;
}
.status-msg.show { display: block; }
.status-msg.loading {
  background: #eef3ff;
  color: #27407a;
  border: 1px solid #c9d7f5;
}
.status-msg.error {
  background: #fdecec;
  color: #8a1c1c;
  border: 1px solid #f3c2c2;
}
.status-msg.ok {
  background: #e9f7ec;
  color: #1d6b2e;
  border: 1px solid #bfe4c8;
}
.status-msg code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
}
