/* ==========================================================================
   COMADRE - HOJA DE ESTILOS DEL PANEL ADMINISTRATIVO
   ========================================================================== */

:root {
  --admin-bg: #f4fbf7;
  --admin-card: #ffffff;
  --admin-border: #d2ebd9;
  --emerald-950: #022c22;
  --emerald-900: #064e3b;
  --emerald-850: #0b5c3b;
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-100: #d1fae5;
  --emerald-50:  #ecfdf5;

  --text-primary: #112a1d;
  --text-secondary: #4b6355;
  --text-muted: #748c7e;

  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --danger-bg: #fef2f2;
  --whatsapp-color: #25d366;
  --whatsapp-hover: #1ebd5a;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(6, 78, 59, 0.05);
  --shadow-md: 0 4px 12px rgba(6, 78, 59, 0.08);
  --shadow-lg: 0 12px 28px rgba(6, 78, 59, 0.12);
}

body.admin-body {
  background-color: var(--admin-bg);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ==========================================================================
   CABECERA DEL PANEL ADMIN
   ========================================================================== */
.admin-header {
  background: #ffffff;
  border-bottom: 1px solid var(--admin-border);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-brand img {
  height: 44px;
}

.admin-badge {
  background: var(--emerald-100);
  color: var(--emerald-850);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--emerald-850);
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--emerald-50);
  border-color: var(--emerald-500);
}

.btn-danger-outline {
  color: var(--danger-color);
  border-color: #fecaca;
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
  border-color: var(--danger-color);
}

/* ==========================================================================
   PANTALLA DE ACCESO CON PIN (BLOQUEO)
   ========================================================================== */
.pin-lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 44, 34, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.pin-lock-overlay.hidden {
  display: none;
}

.pin-lock-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border: 2px solid var(--emerald-300);
}

.pin-lock-icon {
  width: 68px;
  height: 68px;
  background: var(--emerald-50);
  color: var(--emerald-700);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 2rem;
}

.pin-lock-card h3 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--emerald-950);
  margin-bottom: 0.35rem;
}

.pin-lock-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}

.pin-input-group {
  margin-bottom: 1.25rem;
}

.pin-input {
  width: 100%;
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--admin-border);
  background: var(--admin-bg);
  color: var(--emerald-950);
  font-weight: 700;
  outline: none;
}

.pin-input:focus {
  border-color: var(--emerald-600);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.btn-admin-submit {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--emerald-700);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-admin-submit:hover {
  background: var(--emerald-850);
}

.pin-helper-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* ==========================================================================
   CONTENEDOR PRINCIPAL DEL PANEL
   ========================================================================== */
.admin-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Tarjetas de Métricas / KPIs */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--emerald-50);
  color: var(--emerald-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--emerald-950);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 0.25rem;
}

/* Barra de Herramientas (Búsqueda, Filtro, Exportar) */
.toolbar-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  font-size: 0.92rem;
  font-family: inherit;
  border: 1.5px solid var(--admin-border);
  border-radius: var(--radius-md);
  background: var(--admin-bg);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--emerald-600);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-select {
  padding: 0.75rem 1.2rem;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1.5px solid var(--admin-border);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.btn-export-excel {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  color: #ffffff;
  background: linear-gradient(135deg, var(--emerald-850) 0%, var(--emerald-700) 100%);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(6, 78, 59, 0.25);
  transition: all 0.2s ease;
}

.btn-export-excel:hover {
  background: linear-gradient(135deg, var(--emerald-900) 0%, var(--emerald-800) 100%);
  transform: translateY(-1px);
}

/* ==========================================================================
   TABLA DE REGISTROS
   ========================================================================== */
.table-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-header-info {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--emerald-50);
}

.table-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--emerald-950);
}

.records-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--emerald-850);
  background: #ffffff;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--admin-border);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background: #fafdfb;
  color: var(--text-secondary);
  font-weight: 700;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--admin-border);
  white-space: nowrap;
}

.data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--admin-border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f7fdf9;
}

.cell-name {
  font-weight: 700;
  color: var(--emerald-950);
}

.cell-date {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.badge-location {
  display: inline-block;
  background: var(--emerald-50);
  color: var(--emerald-850);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--admin-border);
}

/* Botones de Acción en Fila */
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-action {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--admin-border);
  background: #ffffff;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.btn-action:hover {
  background: var(--emerald-50);
  color: var(--emerald-850);
  border-color: var(--emerald-400);
}

.btn-action.whatsapp {
  color: #ffffff;
  background: var(--whatsapp-color);
  border-color: var(--whatsapp-color);
}

.btn-action.whatsapp:hover {
  background: var(--whatsapp-hover);
}

.btn-action.delete:hover {
  background: var(--danger-bg);
  color: var(--danger-color);
  border-color: #fecaca;
}

/* Estado Vacío */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--emerald-500);
}

.empty-state h4 {
  font-size: 1.2rem;
  color: var(--emerald-950);
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   MODAL DE DETALLE DEL REGISTRO
   ========================================================================== */
.detail-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 44, 34, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.detail-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.detail-modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--emerald-200);
  position: relative;
}

.detail-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--admin-border);
  padding-bottom: 1rem;
}

.detail-modal-header h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--emerald-950);
}

.detail-id-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-item.full-width {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--emerald-700);
  margin-bottom: 0.25rem;
}

.detail-value {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================================================
   RESPONSIVIDAD DEL PANEL ADMIN
   ========================================================================== */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-export-excel {
    justify-content: center;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

