/* ========================================
   ESTILOS PARA BOTONES DE TICKET Y ACCIONES
   VERSIÓN FINAL LIMPIA - Sin duplicados
   ======================================== */

/* Botón Ver Ticket en la grilla - Layout Vertical */
.btn-ticket {
  background: linear-gradient(135deg, #6750A4, #4527A0);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 4px;
  margin-top: 6px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 9px;
  font-weight: 700;
  width: 100%;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(103, 80, 164, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  z-index: 10;
}

/* Efecto de brillo radial animado */
.btn-ticket::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.2) 40%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.6s ease-out;
  pointer-events: none;
  z-index: 1;
}

.btn-ticket:hover::before {
  animation: shine-radial 0.8s ease-out;
}

@keyframes shine-radial {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

/* Pulsación sutil continua */
@keyframes pulse-subtle {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(103, 80, 164, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 4px 12px rgba(103, 80, 164, 0.6),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
}

.numero-card.pagado .btn-ticket {
  animation: pulse-subtle 3s ease-in-out infinite;
}

/* Hover del botón */
.btn-ticket:hover {
  background: linear-gradient(135deg, #7C64B8, #5C3FB5);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 16px rgba(103, 80, 164, 0.6),
              inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.btn-ticket:active {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 2px 6px rgba(103, 80, 164, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Contenido del botón */
.btn-ticket .material-icons {
  font-size: 18px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
  line-height: 1;
  position: relative;
  z-index: 2;
}

.btn-ticket .btn-ticket-text {
  line-height: 1;
  white-space: nowrap;
  position: relative;
  z-index: 2;
}

/* Tooltip del botón */
.btn-ticket-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: opacity 0.3s ease-out;
}

.btn-ticket:hover .btn-ticket-tooltip {
  opacity: 1;
}

/* Efecto de borde punteado al hover */
.btn-ticket::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px dashed rgba(255, 255, 255, 0);
  border-radius: 10px;
  transition: all 0.3s;
  pointer-events: none;
}

.btn-ticket:hover::after {
  border-color: rgba(255, 255, 255, 0.4);
  inset: -6px;
}

/* Separación visual entre tarjeta y botón */
.numero-card.pagado {
  padding-bottom: 6px;
}

.numero-card.pagado .btn-ticket {
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 6px;
}

/* Hover de la tarjeta (para editar) */
.numero-card:not(.disabled):hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.numero-card.pagado:hover .btn-ticket {
  transform: translateY(-2px) scale(1.03);
}

/* Indicador de zona editable */
.numero-card.pagado::after {
  content: '✏️';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s;
}

.numero-card.pagado:hover::after {
  opacity: 0.5;
}

/* ======================================== */
/* BOTONES DE ADMIN (Reenviar y Historial) */
/* ======================================== */

.btn-reenviar {
  background: linear-gradient(135deg, #2196F3, #1976D2);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}

.btn-reenviar:hover {
  background: linear-gradient(135deg, #1976D2, #1565C0);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-reenviar:active {
  transform: translateY(0);
}

.btn-historial {
  background: linear-gradient(135deg, #FF9800, #F57C00);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}

.btn-historial:hover {
  background: linear-gradient(135deg, #F57C00, #E65100);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

/* ======================================== */
/* BADGES Y ESTADOS */
/* ======================================== */

.email-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.email-badge.enviado {
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #81C784;
}

.email-badge.pendiente {
  background: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFB74D;
}

.email-badge.error {
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #E57373;
}

/* ======================================== */
/* SPINNER */
/* ======================================== */

.spinner {
  border: 3px solid var(--md-sys-color-surface-variant);
  border-top: 3px solid var(--md-sys-color-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ======================================== */
/* RESPONSIVE */
/* ======================================== */

@media (max-width: 768px) {
  .btn-reenviar,
  .btn-historial {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  .btn-reenviar .material-icons,
  .btn-historial .material-icons {
    font-size: 14px;
  }
  
  .btn-ticket {
    font-size: 8px;
    padding: 4px 3px;
    gap: 1px;
  }
  
  .btn-ticket .material-icons {
    font-size: 16px;
  }
  
  .email-badge {
    font-size: 10px;
    padding: 3px 8px;
  }
}

@media (max-width: 480px) {
  .data-table th:nth-child(8),
  .data-table td:nth-child(8),
  .data-table th:nth-child(9),
  .data-table td:nth-child(9) {
    font-size: 11px;
  }
  
  .btn-reenviar,
  .btn-historial {
    padding: 3px 6px;
    font-size: 10px;
  }
  
  .btn-ticket {
    font-size: 7px;
    padding: 3px 2px;
  }
  
  .btn-ticket .material-icons {
    font-size: 14px;
  }
  
  .btn-ticket-tooltip {
    display: none; /* Ocultar tooltip en móvil */
  }
}
.loading {
  text-align: center;
  padding: 40px;
  color: var(--md-sys-color-outline);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}
/* AGREGAR AL FINAL DE rifa.css */

/* Ocultar elementos admin en vista pública */
#public-view:not([style*="display: none"]) ~ * #busqueda-rapida-admin,
#public-view:not([style*="display: none"]) ~ * #admin-data-display {
  display: none !important;
}

/* Asegurar que solo se muestre una grilla a la vez */
#admin-view[style*="display: none"] ~ * #admin-rifa-grid {
  display: none !important;
}

#public-view[style*="display: none"] ~ * #public-rifa-grid {
  display: none !important;
}
/* ========================================
   CORRECCIÓN DE CONFLICTOS CSS
   Agregar AL FINAL de rifa.css
   ======================================== */

/* ============================================
   REGLA CRÍTICA: Ocultar elementos admin en vista pública
   ============================================ */

/* Cuando public-view está visible, ocultar TODO lo de admin */
#public-view:not([style*="display: none"]) ~ * #busqueda-rapida-admin,
#public-view:not([style*="display: none"]) ~ * #admin-data-display,
#public-view:not([style*="display: none"]) ~ * .search-panel {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Cuando admin-view está oculto, ocultar grilla admin */
#admin-view[style*="display: none"] #admin-rifa-grid,
#admin-view[style*="display: none"] .search-panel,
#admin-view[style*="display: none"] #busqueda-rapida-admin {
  display: none !important;
}

/* Cuando public-view está oculto, ocultar grilla pública */
#public-view[style*="display: none"] #public-rifa-grid {
  display: none !important;
}

/* ============================================
   ASEGURAR VISIBILIDAD CORRECTA
   ============================================ */

/* Vista pública: solo mostrar elementos públicos */
#public-view {
  display: block;
}

#public-view #public-rifa-grid {
  display: grid !important;
}

#public-view #public-loading {
  display: flex;
}

/* Vista admin: solo mostrar elementos admin */
#admin-view #admin-rifa-grid {
  display: grid !important;
}

#admin-view #busqueda-rapida-admin {
  display: block !important;
}

#admin-view #admin-data-display {
  display: block !important;
}

/* ============================================
   OCULTAR ELEMENTOS ESPECÍFICOS POR CONTEXTO
   ============================================ */

/* Si public-view tiene display:block, NO mostrar search-panel */
body:has(#public-view:not([style*="display: none"])) .search-panel {
  display: none !important;
}

body:has(#public-view:not([style*="display: none"])) #busqueda-rapida-admin {
  display: none !important;
}

body:has(#public-view:not([style*="display: none"])) #admin-data-display {
  display: none !important;
}

/* Si admin-login está visible, ocultar todo lo demás */
body:has(#admin-login:not([style*="display: none"])) #busqueda-rapida-admin,
body:has(#admin-login:not([style*="display: none"])) #admin-data-display {
  display: none !important;
}

/* ============================================
   CLASES AUXILIARES PARA CONTROL DESDE JS
   ============================================ */

.public-mode #busqueda-rapida-admin,
.public-mode #admin-data-display,
.public-mode .search-panel {
  display: none !important;
}

.admin-mode #public-rifa-grid {
  display: none !important;
}

/* ============================================
   FIX PARA LOADING
   ============================================ */

/* Loading público solo visible cuando corresponde */
#public-loading {
  display: none;
}

#public-view:not([style*="display: none"]) #public-loading.active {
  display: flex !important;
}

/* Loading admin solo visible cuando corresponde */
#admin-loading {
  display: none;
}

#admin-view:not([style*="display: none"]) #admin-loading.active {
  display: flex !important;
}

/* ============================================
   RESPONSIVE - MANTENER REGLAS
   ============================================ */

@media (max-width: 768px) {
  /* Asegurar que las reglas se mantengan en móvil */
  #public-view:not([style*="display: none"]) ~ * #busqueda-rapida-admin,
  #public-view:not([style*="display: none"]) ~ * #admin-data-display {
    display: none !important;
  }
}