/* JuntaPro — capa visual sobre Tailwind */
:root {
  --ink-950: #07090f;
  --ink-900: #0f1419;
  --gold-500: #c9a227;
  --gold-glow: rgba(201, 162, 39, 0.35);
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body.app-body {
  overflow-x: hidden;
  background: #f4f5f7;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201, 162, 39, 0.08), transparent),
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.05), transparent 40%);
}

/* Sidebar */
.sidebar-nav a {
  position: relative;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.sidebar-nav a.active {
  background: rgba(201, 162, 39, 0.12);
  color: #f5e6b8;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gold-500);
  border-radius: 0 4px 4px 0;
}

/* Cards */
.pro-card {
  background: #fff;
  border: 1px solid rgba(15, 20, 25, 0.06);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(7, 9, 15, 0.04), 0 12px 40px -12px rgba(7, 9, 15, 0.08);
}

.stat-card {
  overflow: hidden;
  position: relative;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-glow), transparent 70%);
  pointer-events: none;
}

/* Tablas */
.pro-table thead th {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
}
.pro-table tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  word-break: break-word;
}
.pro-table tbody tr:hover td {
  background: #fafbfc;
}

/* Matriz de pagos */
.matrix-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}
.matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
}
.matrix-table th,
.matrix-table td {
  border: 1px solid #e8ecf1;
  padding: 0;
}
.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f1419;
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.5rem 0.35rem;
  text-align: center;
  min-width: 44px;
}
.matrix-table thead th.week-current {
  background: #1a2332;
  color: #f5e6b8;
  box-shadow: inset 0 -2px 0 var(--gold-500);
}
.matrix-table tbody th.member-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: #0f1419;
  min-width: 140px;
  border-right: 2px solid #e2e8f0;
}
.matrix-table .turn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: #0f1419;
  color: #c9a227;
  font-size: 0.75rem;
  font-weight: 700;
}
.pay-cell {
  width: 44px;
  height: 44px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px;
  border-radius: 8px;
}
.pay-cell:hover {
  transform: scale(1.08);
  z-index: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.pay-cell.paid {
  background: linear-gradient(145deg, #059669, #10b981);
  color: #fff;
}
.pay-cell.pending {
  background: #fef3c7;
  color: #b45309;
}
.pay-cell.week-current-cell {
  outline: 2px solid var(--gold-500);
  outline-offset: -2px;
}
.pay-cell.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Formularios */
.pro-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pro-input:focus {
  outline: none;
  border-color: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
}

.pro-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  background: linear-gradient(135deg, #0f1419 0%, #1a2332 100%);
  color: #f5e6b8;
  border: 1px solid rgba(201, 162, 39, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.pro-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(15, 20, 25, 0.25);
}

/* Login */
.auth-mesh {
  background-color: var(--ink-950);
  background-image:
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9a227' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Toast */
#toast-root {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast-item {
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast-item.success { background: #059669; }
.toast-item.error { background: #dc2626; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* Modal backdrop */
[x-cloak] { display: none !important; }

/* Scrollbar matrix */
.matrix-wrap::-webkit-scrollbar { height: 8px; width: 8px; }
.matrix-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* Barra de acciones de formularios */
.form-actions-bar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin: 2rem -1rem -1rem;
  padding: 1rem 1rem 1.25rem;
  background: linear-gradient(to top, #f4f5f7 70%, transparent);
}
@media (min-width: 1024px) {
  .form-actions-bar { margin-left: -2rem; margin-right: -2rem; padding-left: 2rem; padding-right: 2rem; }
}
.form-actions-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid rgba(15, 20, 25, 0.08);
  border-radius: 14px;
  box-shadow: 0 -4px 24px rgba(7, 9, 15, 0.08);
}
/* Entrega de turnos */
.turn-delivery-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  background: #fff;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.turn-delivery-card.is-current {
  border-color: rgba(201, 162, 39, 0.5);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.12);
}
.turn-delivery-card.is-delivered {
  background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%);
  border-color: #86efac;
}
.turn-delivery-card.is-pending {
  background: #fafafa;
}
.member-row-delivered .member-col {
  background: linear-gradient(90deg, #ecfdf5 0%, #fff 8rem) !important;
}
.member-row-current .member-col {
  background: linear-gradient(90deg, #fffbeb 0%, #fff 8rem) !important;
}
.turn-col-delivered {
  background: #059669 !important;
  color: #fff !important;
}

.form-actions-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: #b45309;
  max-width: 28rem;
}

/* ========== Móvil / tablet ========== */
.touch-target {
  min-height: 44px;
  min-width: 44px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
}
.modal-panel {
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  background: #fff;
  padding: 1.25rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
}
@media (min-width: 640px) {
  .modal-panel {
    max-width: 32rem;
    border-radius: 1rem;
    max-height: 90vh;
  }
}
.modal-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.75rem;
  padding-top: 0.5rem;
}
@media (min-width: 480px) {
  .modal-actions {
    flex-direction: row;
  }
}

#toast-root {
  left: 1rem;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  align-items: stretch;
}
@media (min-width: 640px) {
  #toast-root {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    align-items: flex-end;
    max-width: 22rem;
  }
}

.pay-cell {
  min-width: 40px;
  min-height: 40px;
  width: 40px;
  height: 40px;
}
@media (min-width: 768px) {
  .pay-cell {
    width: 44px;
    height: 44px;
  }
}

.matrix-table thead th {
  min-width: 36px;
  font-size: 0.6rem;
}
.matrix-table tbody th.member-col {
  min-width: 100px;
  max-width: 120px;
  font-size: 0.75rem;
}

/* Tarjetas integrantes (detalle junta) — móvil */
.member-cards-mobile {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.member-card-mobile {
  box-sizing: border-box;
  overflow: hidden;
}

.member-card-mobile .pro-badge,
.member-card-mobile span[class*="rounded-full"] {
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.member-card-mobile form {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.member-card-mobile .pro-input {
  min-width: 0;
}

/* Lista junteros — tarjetas compactas móvil */
.junteros-cards-mobile {
  width: 100%;
  min-width: 0;
}

.juntero-card-mobile {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.juntero-card-mobile .pro-badge,
.juntero-card-mobile span[class*="rounded-full"] {
  flex-shrink: 0;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
}

/* Contenedor gráficos Chart.js */
.chart-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.chart-container canvas {
  display: block;
  max-width: 100% !important;
}

.app-shell-main,
.app-main {
  min-width: 0;
  max-width: 100%;
}

/* Cards con padding adaptable */
@media (max-width: 639px) {
  .pro-card.p-6,
  .pro-card.p-5 {
    padding: 1rem;
  }

  .stat-card .text-3xl {
    font-size: 1.5rem;
    line-height: 2rem;
  }
}

/* Tabla integrantes / junteros / dashboard → tarjetas en móvil */
@media (max-width: 767px) {
  .hide-mobile,
  .hide-mobile-table {
    display: none !important;
  }

  .integrantes-table thead,
  .responsive-table thead {
    display: none;
  }

  .integrantes-table tbody tr,
  .responsive-table tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
  }

  .integrantes-table tbody tr:hover td,
  .responsive-table tbody tr:hover td {
    background: transparent;
  }

  .integrantes-table tbody td,
  .responsive-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border: none;
    text-align: right;
  }

  .integrantes-table tbody td::before,
  .responsive-table tbody td::before {
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    flex-shrink: 0;
  }

  .integrantes-table tbody td.text-right,
  .responsive-table tbody td.text-right {
    justify-content: space-between;
  }

  .integrantes-table tbody td[data-label="Participante"],
  .responsive-table tbody td[data-label="Junta"] {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0.25rem;
  }

  .integrantes-table tbody td[data-label="Participante"]::before,
  .responsive-table tbody td[data-label="Junta"]::before {
    display: none;
  }

  .table-scroll:not(.matrix-wrap) {
    overflow-x: visible;
    margin-left: 0;
    margin-right: 0;
  }

  .matrix-wrap {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  #junta-block-stats .pro-card p.text-xl {
    font-size: 1.125rem;
  }

  .turn-delivery-card {
    padding: 0.875rem 1rem;
  }

  #junta-block-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .form-actions-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions-inner .pro-btn-primary,
  .form-actions-inner a {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  #junta-block-stats {
    grid-template-columns: 1fr !important;
  }
}

.form-actions-bar {
  margin-left: -1rem;
  margin-right: -1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}
