/* ==========================================================================
   1. CONFIGURACIÓN GLOBAL Y VARIABLES
   ========================================================================== */

@font-face {
    font-family: 'CodecPro';
    src: url('/font/CodecPro-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Pusia';
    src: url('/font/Pusia-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   2. VARIABLES
   ========================================================================== */
:root {
    --primario: #FFD600;
    --primario-oscuro: #E6C200;
    --negro: #1a1a1a;
    --gris-oscuro: #4a4a4a;
    --gris-medio: #6c757d;
    --gris-claro: #e0e0e0;
    --blanco: #fff;
    --fondo: #f4f7f6; /* Un gris muy claro para el fondo principal */
    --tarjeta: #ffffff;
    --rojo: #dc3545;
    --verde: #28a745;
    --verde-oscuro: #218838; /* Nuevo para efecto active */

    --titulos: 'Pusia', 'Arial Black', sans-serif;
    --texto-principal: 'CodecPro', Arial, sans-serif;

    --sombra-suave: 0 4px 6px rgba(0, 0, 0, 0.04);
    --sombra-media: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radio: 12px;
    --radio-boton: 8px;
    --transicion: 0.2s ease-in-out;
}

/* ==========================================================================
   3. NORMALIZACION
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  font-family: var(--texto-principal);
  background-color: #e9e9e9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%239C92AC' fill-opacity='0.1' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");
  color: var(--gris-oscuro);
}

/* ==========================================================================
   4. ESTRUCTURA PRINCIPAL (LAYOUT)
   ========================================================================== */

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

.sidebar {
    width: 240px;
    background-color: var(--negro);
    color: var(--blanco);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all var(--transicion);
    height: 100vh;
    box-sizing: border-box; 
}

.sidebar-header {
    text-align: center;
    padding: 1.5rem 1rem; 
    border-bottom: 1px solid #333;
}

.sidebar-header h2 {
    font-family: var(--titulos);
    color: var(--primario);
    margin: 0;
    font-size: 1.5rem;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto; 
}

.user-info {
    font-size: 0.8em;
    padding: 1rem;
    text-align: center;
    word-break: break-all;
    opacity: 0.7;
    
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    color: var(--blanco);
    text-align: left;
    font-family: var(--texto-principal);
    font-size: 1rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background-color var(--transicion), border-left-color var(--transicion);
    /* Quitar parpadeo gris en móvil */
    -webkit-tap-highlight-color: transparent;
}

/* ESTADO ACTIVE (Cuando presionas con el dedo) */
.nav-button:active {
    background-color: #333;
    transform: scale(0.98); /* Ligero efecto de pulsación */
}

/* FIX: Hover solo en PC */
@media (hover: hover) {
    .nav-button:hover {
        background-color: #333;
    }
}

.nav-button.active {
    background-color: var(--primario);
    color: var(--negro);
    font-weight: bold;
    border-left-color: var(--primario-oscuro);
}

.sidebar-footer {
    padding: 2rem; 
    flex-shrink: 0; 
}

.sidebar-footer .button-secondary {
    width: 100%;
}

.main-content {
    flex-grow: 1;
    padding: .3rem 2rem;
    overflow-y: auto;
    height: 100vh;
    min-height: 0;
}

/* ==========================================================================
   4. BOTONES (ESTILO PRO PARA TABLET)
   ========================================================================== */
.button-primary, .button-secondary {
    font-family: var(--texto-principal);
    padding: 12px 20px;
    border: none;
    border-radius: var(--radio-boton);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold; 
    text-transform: uppercase;
    letter-spacing: 0.5px; 
    transition: transform 0.1s, background-color 0.2s; /* Transición más rápida para touch */
    
    /* Quitar caja gris de selección en móviles */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.button-primary { 
    background-color: var(--primario); 
    color: var(--negro); 
}

.button-secondary { 
    background-color: var(--gris-medio); 
    color: var(--blanco); 
}

/* --- ESTADO ACTIVE: EL EFECTO DE PULSACIÓN PRO --- */
/* Esto se activa MIENTRAS tienes el dedo puesto en el botón */

.button-primary:active {
    background-color: var(--primario-oscuro) !important;
    transform: scale(0.96); /* Se encoge un poquito */
}

.button-secondary:active {
    background-color: var(--gris-oscuro) !important;
    transform: scale(0.96);
}


/* --- ESTADO HOVER: SOLO PARA PC (Ratón) --- */
@media (hover: hover) {
    .button-primary:hover { 
        background-color: var(--primario-oscuro); 
        box-shadow: var(--sombra-suave); 
        transform: translateY(-2px); 
    }
    
    /* Si pulsamos con el ratón, el transform se sobreescribe */
    .button-primary:active {
        transform: translateY(0) scale(0.96);
    }
    
    .button-secondary:hover { 
        background-color: var(--gris-oscuro); 
    }
}


/* ==========================================================================
   5. PANEL DE INICIO SESION
   ========================================================================== */

body:has(#app-layout[style*="display: none"]) {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.admin-card {
    background-color: var(--tarjeta);
    border-radius: var(--radio);
    box-shadow: var(--sombra-media);
    padding: 2rem;
}

/* --- Estilos Específicos para la Tarjeta de Login --- */
#adminLoginSection {
    width: 90%;
    max-width: 420px; 
    border-top: 5px solid var(--primario);
    text-align: center; 
}


#adminLoginSection h1 {
    font-family: var(--titulos);
    font-size: 2.2rem;
    color: var(--negro);
    margin: 0;
    text-shadow: none;
}

#adminLoginSection h2 {
    font-family: var(--texto-principal);
    font-size: 1.4rem;
    color: var(--gris-medio);
    font-weight: normal;
}


#adminLoginForm .form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem; 
    font-size: 0.9rem; 
    text-align: left;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%; 
    padding: 12px 15px; 
    border: 1px solid var(--gris-claro); 
    border-radius: var(--radio-boton);
    font-family: var(--texto-principal); 
    font-size: 1rem; 
    transition: border-color var(--transicion), 
    box-shadow var(--transicion);
}

input:focus, select:focus, textarea:focus { 
    outline: none; 
    border-color: var(--primario); 
    box-shadow: 0 0 0 3px rgba(255, 214, 0, 0.25); 
}

textarea { 
    min-height: 120px; 
    resize: vertical; 
}

/* --- Botón de Ingreso (Call to Action) --- */
#adminLoginForm .button-primary {
    width: 80%;
    padding: 15px;
    font-size: 1.1rem;
    margin-top: 1.5rem;
    font-family: var(--titulos);
}

/* --- Icono del Ojo en Contraseña --- */
.password-input-container {
    position: relative;
}
.password-toggle-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    user-select: none;
    opacity: 0.6;
    transition: opacity var(--transicion);
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    .password-toggle-icon:hover {
        opacity: 1;
    }
}

/* --- Mensaje de Error --- */
#adminLoginError {
    min-height: 1.5em; 
    margin-top: 1rem;
    padding: 0; 
    font-weight: bold;
    color: var(--rojo); 
    background-color: transparent; 
    border-radius: var(--radio-boton);
    transition: background-color 0.3s ease, padding 0.3s ease; 
}


#adminLoginError:not(:empty) {
    padding: 0.75rem; 
    background-color: rgba(220, 53, 69, 0.1); 
}

.controls-container { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 1rem; 
    margin-bottom: 1.5rem; 
}

.pagination-controls { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 1rem; 
    margin-top: 1.5rem; 
}

/* ==========================================================================
   4. DASHBOARD INICIO
   ========================================================================== */

.dashboard-header { 
    margin-bottom: 2rem; 
}

#welcome-message { 
    color: var(--gris-medio); 
}

.dashboard-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 1.5rem; 
}

.dashboard-card {
    background-color: var(--tarjeta); 
    border-radius: var(--radio); 
    padding: 1.5rem;
    box-shadow: var(--sombra-suave); 
    transition: transform var(--transicion), box-shadow var(--transicion);
    text-decoration: none; 
    color: var(--gris-oscuro); 
    display: flex; 
    flex-direction: column;
    /* Quitar resaltado tap */
    -webkit-tap-highlight-color: transparent;
}

/* Efecto pulsación en tarjeta */
.dashboard-card:active {
    transform: scale(0.98);
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    .dashboard-card:hover { transform: translateY(-5px); box-shadow: var(--sombra-media); }
    .dashboard-card:active { transform: translateY(-5px) scale(0.98); }
}

.quick-action-card .card-icon { font-size: 2.5rem; line-height: 1; margin-bottom: 1rem; }
.stat-card .stat-number { font-family: var(--titulos); font-size: 3rem; color: var(--primario); margin: 0.5rem 0; }
.stat-card .card-link { margin-top: auto; text-decoration: none; color: var(--gris-oscuro); font-weight: bold; }
#stat-pending-reviews-card.has-pending { border: 2px solid var(--primario-oscuro); background-color: #fffbeb; }



/* --- Hero Header con Logo --- */
.dashboard-hero {
    text-align: center;
    margin-bottom: 3rem;
}
.dashboard-logo {
    max-width: 180px;
    margin-bottom: 1rem;
}
.dashboard-hero h2 {
    font-family: var(--titulos);
    font-size: 2.2rem;
    margin: 0 0 0.5rem 0;
}
.hero-subtitle {
    font-size: 1.1rem;
    color: var(--gris-medio);
    margin: 0;
}

/* ================================================= */
/* ===== ESTILOS PARA EL GRID DEL DASHBOARD ===== */
/* ================================================= */

.dashboard-grid-dynamic {
    display: grid;
    /* 2 columnas en escritorio, 1 en móvil (ver @media) */
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

/* --- ESTILO BASE PARA TODAS LAS TARJETAS --- */
.dashboard-card {
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden; /* Para los iconos de fondo */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    .dashboard-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    }
}

/* --- TARJETAS DE ACCIÓN PRINCIPAL (GRIS OSCURO) --- */
.highlight-card {
    background-color: #2c2c2e;
    grid-column: span 1; /* Cada una ocupa 1 columna */
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.highlight-card h3 {
    color: var(--primary-color); /* Color amarillo de tu marca */
    margin: 0 0 8px 0;
}

.highlight-card p {
    color: #aaa;
    font-size: 0.9rem;
    max-width: 80%;
}

.highlight-card .card-icon-bg {
    position: absolute;
    bottom: -20px;
    right: -20px;
    font-size: 100px;
    color: rgba(255, 255, 255, 0.05);
    transform: rotate(-15deg);
}

.highlight-card .card-icon-bg svg {
    width: 120px;
    height: 120px;
    fill: rgba(255, 255, 255, 0.05);
}


/* --- TARJETAS DE ESTADÍSTICAS (STAT-CARDS) --- */
.stat-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 25px 20px;
}

.stat-card h4 {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-card .stat-number {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .card-link {
    font-size: 0.8rem;
    margin-top: 10px;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    .stat-card .card-link:hover {
        opacity: 1;
    }
}

/* --- VARIANTE "ATENCIÓN" (AMARILLO/DORADO) --- */
.stat-card.attention {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #333; /* Texto oscuro para contraste */
}
.stat-card.attention .stat-number {
    color: #000;
}
.stat-card.attention .card-link {
    color: #333;
}

/* --- VARIANTE "INFORMATIVA" (GRIS OSCURO) --- */
.stat-card.info {
    background-color: #3a3a3c;
    color: #fff;
}

.stat-card.info .card-link {
    color: #fff;
}


/* --- LÓGICA DE INDICADOR (has-pending) --- */
.stat-card.has-pending {
    /* Mantenemos el estilo de "atención" cuando hay tareas */
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #333;
}
.stat-card.has-pending .stat-number {
    color: #000;
}
.stat-card.has-pending .card-link {
    color: #333;
}
/* Opcional: animar el indicador */
.stat-card.has-pending .status-indicator {
    display: block !important;
    width: 10px;
    height: 10px;
    background-color: #ff3b30; /* Rojo vivo */
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}



/* ==========================================================================
   8. SECCIÓN DE GESTIÓN DE CLIENTES 
   ========================================================================== */

/* --- Tabla --- */
.list-container { 
    overflow-x: auto; 
}

table th, table td { 
    padding: 1rem; 
    text-align: left; 
    border-bottom: 1px solid var(--gris-claro); 
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px; 
    font-size: 0.9rem;
}

table th {
    background-color: var(--negro); 
    color: var(--primario); 
    font-family: var(--texto-principal);
    font-size: 0.8rem;
    border: none;
    text-transform: uppercase;
    letter-spacing: 1px;
}

table td {
    background-color: var(--tarjeta);
    padding: 1.25rem 1.5rem;
    border: none;
    border-bottom: 1px solid var(--fondo-body);
    vertical-align: middle;
}

table tbody tr {
    box-shadow: var(--sombra-suave);
    border-radius: var(--radio);
    cursor: pointer;
    transition: transform var(--transicion), box-shadow var(--transicion);
    position: relative;
    /* Efecto de toque para móvil */
    -webkit-tap-highlight-color: transparent;
}

/* Efecto pulsación en filas */
table tbody tr:active {
    transform: scale(0.99);
    background-color: #f5f5f5;
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    table tbody tr:hover {
        transform: translateY(-3px);
        box-shadow: var(--sombra-media);
        background: none;
    }
}

table tbody tr td:first-child { border-radius: var(--radio) 0 0 var(--radio); }
table tbody tr td:last-child { border-radius: 0 var(--radio) var(--radio) 0; }


/* --- Estilos Específicos para la Tabla de Clientes --- */
#clientesTable td:nth-child(1) { /* Email */
    font-weight: bold;
    color: var(--negro);
}

/* Centrado para las columnas de Puntos (título y datos) */
#clientesTable th:nth-child(2),
#clientesTable th:nth-child(3),
#clientesTable td:nth-child(2),
#clientesTable td:nth-child(3) {
    text-align: center;
}

/* Estilo específico para los datos de Puntos */
#clientesTable td:nth-child(2),
#clientesTable td:nth-child(3) {
    font-family: var(--titulos);
    font-size: 1.1rem;
}
#clientesTable td:nth-child(2) {
    color: var(--primario-oscuro);
}

/* Alineación derecha para la columna de Fecha (título y datos) */
#clientesTable th:nth-child(4),
#clientesTable td:nth-child(4) {
    text-align: right;
}
/* Estilo específico para los datos de Fecha */
#clientesTable td:nth-child(4) {
    color: var(--gris-medio);
    font-size: 0.9rem;
}

/* --- Encabezado y Barra de Herramientas de la Sección --- */
#clientesSection .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gris-claro);
}

#clientesSection h2 {
    margin: 0;
}

#clientesSection .controls-container {
    background-color: #f8f9fa;
    padding: 1rem 1.5rem;
    border-radius: var(--radio);
    margin-bottom: 1rem; 
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
}
#clientesSection .controls-container label {
    font-family: var(--titulos);
    color: var(--gris-oscuro);
}
#clientesSection .search-group {
    flex-grow: 1;
}

/* ==========================================================================
   16. MEJORAS VISUALES PARA LA VISTA DE DETALLE DE CLIENTE
   ========================================================================== */

.clienteDetail {
    padding: 0; /* Quitamos el padding principal para tener más control */
}

/* --- Cabecera de la Vista de Detalle --- */
.clienteDetail .section-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--gris-claro);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.clienteDetail h3 {
    margin: 0;
    font-size: 1.5rem; /* Título más grande */
    color: var(--negro);
}

.clienteDetail .button-secondary {
    margin: 0; /* Quitamos márgenes extra del botón */
}

/* --- Panel de Información del Cliente --- */
.cliente-info-panel {
    padding: 2rem;
    background-color: #f8f9fa;
    border-top: 1px solid var(--gris-claro);
    border-bottom: 1px solid var(--gris-claro);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    text-align: center;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    margin-bottom: 2rem; /* Espacio antes de los botones de acción */
}

.cliente-info-panel p {
    margin: 0;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
}

.cliente-info-panel p strong {
    font-family: var(--texto-principal);
    font-size: 0.8rem;
    color: var(--gris-medio);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* Estilo para los datos numéricos en cualquier ficha */
.cliente-info-panel span[id*="Puntos"] {
    font-family: var(--titulos);
    font-size: 2.2rem;
    color: var(--negro);
    line-height: 1;
}

/* Estilo para los datos numéricos */
#clienteDetailPuntos, #clienteDetailPuntosTotales {
    font-family: var(--titulos);
    font-size: 2.2rem; /* Ligeramente más grandes para destacar */
    color: var(--negro);
    line-height: 1;
}

#clienteDetailPuntos, #clienteEscaneadoPuntos {
    color: var(--primario-oscuro);
}

/* --- Paneles de Acciones (Acreditar/Canjear) --- */
.clienteDetail .actions-container {
    padding: 2rem;
    border-top: none;
}

/* --- Mensaje de Estado --- */
#clienteDetailMessage {
    text-align: center;
    padding: 0 2rem 1.5rem 2rem;
    min-height: 1.5em; /* Reserva espacio para evitar saltos */
    font-weight: bold;
}
#clienteDetailMessage:not(:empty) {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}


/* ==========================================================================
   6. SECCION SCANNER
   ========================================================================== */

#escanearQrSection #scannerContainer {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px auto;
    border: 2px dashed #555;
    border-radius: 12px;
    padding: 20px;
    position: relative;
}

#scanner-instructions {
    text-align: center;
    color: #888;
    padding: 40px 0;
}
#scanner-instructions i {
    font-size: 3rem;
}

#qrScannerElement video {
    width: 100% !important; /* Forzar el ancho del vídeo de la cámara */
    height: auto !important;
    border-radius: 8px;
}

#clienteEncontradoInfo #btnVolverAEscanear {
    margin: 30px auto;
    display: block;      
    width: auto;         
    min-width: 250px;    
}


/* ==========================================================================
   13. REDISEÑO FUNCIONAL DE SUMA/CANJE DE PUNTOS
   ========================================================================== */

.actions-container {
    width: 100%;
    margin-top: 1.5rem;
    border-top: 1px solid var(--gris-claro);
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.action-panel h3 {
    font-family: var(--titulos);
    text-align: left;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.action-btn-sumar,
.action-btn-restar {
    padding: 1rem;
    border: 2px solid;
    border-radius: var(--radio-boton);
    font-family: var(--texto-principal);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transicion);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.action-btn-sumar span,
.action-btn-restar span {
    font-family: var(--titulos);
    font-size: 1.1rem;
}

/* Efecto active PRO (tactil) */
.action-btn-sumar:active {
    background-color: var(--verde);
    color: var(--blanco);
    transform: scale(0.96);
}

.action-btn-restar:active {
    background-color: var(--primario);
    color: var(--negro);
    transform: scale(0.96);
}


/* Estilos para Acreditar */
.action-btn-sumar {
    border-color: var(--verde);
    background-color: transparent;
    color: var(--verde);
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    .action-btn-sumar:hover {
        background-color: var(--verde);
        color: var(--blanco);
    }
    
    .action-btn-restar:hover {
        background-color: var(--primario);
        color: var(--negro);
    }
}

/* Estilos para Canjear */
.action-btn-restar {
    border-color: var(--primario);
    background-color: transparent;
    color: var(--primario-oscuro);
}


/* Estilo para botones desactivados */
.action-btn-restar:disabled {
    border-color: var(--gris-claro);
    color: var(--gris-claro);
    background-color: transparent;
    cursor: not-allowed;
    opacity: 0.6;
}
.action-btn-restar:disabled:hover, .action-btn-restar:disabled:active {
    color: var(--gris-claro); /* Para que no cambie de color */
    transform: none;
    background-color: transparent;
}




/* ==========================================================================
   17. REDISEÑO VISUAL DE LA VISTA DE ACCIONES DEL CLIENTE
   ========================================================================== */

/* --- Nuevo Encabezado --- */
.actions-hero {
    text-align: center;
    margin-bottom: 1.5rem;
}
.actions-hero .hero-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem auto;
    background-color: var(--verde);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blanco);
}
.actions-hero .hero-icon svg {
    width: 32px;
    height: 32px;
}
.actions-hero h2 {
    font-family: var(--titulos);
    font-size: 1.8rem;
    margin: 0;
}
.client-email-display {
    font-size: 1.1rem;
    color: var(--gris-medio);
    margin-top: 0.25rem;
}

/* --- Panel de Puntos --- */
.points-display-panel {
    width: 100%;
    background-color: #f8f9fa;
    border-radius: var(--radio);
    padding: 1rem 1.5rem;
    text-align: center;
    margin-bottom: 2rem;
    border: 1px solid var(--gris-claro);
}
.points-display-panel p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--gris-medio);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.points-display-panel span {
    font-family: var(--titulos);
    font-size: 2.5rem;
    color: var(--primario-oscuro);
    line-height: 1.2;
}


/* ==========================================================================
   9. MEJORAS VISUALES PARA LA SECCIÓN DE ENVIAR MENSAJE (CON SCROLL INTERNO)
   ========================================================================== */

#mensajesSection.admin-card {
    display: flex;
    flex-direction: column;
    height: 100%; 
    max-height: calc(100vh - 5rem); 
    margin: 0 auto; 
    max-width: 700px;
    padding: 0; 
}

#mensajesSection .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem; 
    border-bottom: 1px solid var(--gris-claro);
    flex-shrink: 0; 
}
#mensajesSection h2 {
    margin: 0;
}
#mensajesSection .button-secondary {
    margin: 0;
}

/* --- Contenedor del Formulario --- */
#mensajesSection .message-creation-container {
    
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 2rem; 
}

/* --- Formulario Mejorado --- */
#crearMensajeForm .form-step {
    border-bottom: 1px dashed var(--gris-claro);
}
#crearMensajeForm .form-step:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}
#crearMensajeForm h4.step-title {
    font-family: var(--titulos);
    color: var(--gris-medio);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#crearMensajeForm label {
    font-weight: bold;
    color: var(--gris-oscuro);
}
#crearMensajeForm input[type="text"],
#crearMensajeForm select,
#crearMensajeForm textarea {
    background-color: #f9f9f9;
}
#crearMensajeForm textarea {
    min-height: 150px; 
}

/* --- Botón de Envío --- */
.submit-container {
    text-align: center;
    margin-top: 1.5rem;
}
.submit-container .button-primary {
    width: 100%;
    max-width: 300px;
    padding: 15px;
    font-size: 1.1rem;
    font-family: var(--titulos);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* --- Mensaje de Estado --- */
#mensajeEnvioStatus {
    min-height: 1.5em;
    margin-top: 1rem;
    font-weight: bold;
    padding: 0;
    background-color: transparent;
}
#mensajeEnvioStatus:not(:empty) {
    padding: 0.75rem;
    border-radius: var(--radio-boton);
}
#mensajeEnvioStatus[style*="color: green"] { background-color: rgba(40, 167, 69, 0.1); }
#mensajeEnvioStatus[style*="color: red"] { background-color: rgba(220, 53, 69, 0.1); }
#mensajeEnvioStatus[style*="color: blue"] { background-color: rgba(0, 123, 255, 0.1); }


/* ==========================================================================
   20. UNIFICACIÓN DE ESTILOS PARA VISTAS DE ACCIONES (CLIENTE DETALLE Y QR)
   ========================================================================== */

#clienteDetailContainer,
#clienteEncontradoInfo {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    background-color: var(--tarjeta);
    border-radius: var(--radio);
    box-shadow: var(--sombra-media);
    display: flex; 
    flex-direction: column;
    align-items: center;
    padding: 2rem; 
}

.clienteDetail .section-header,
.actions-hero {
    width: 100%;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gris-claro);
    margin-bottom: 2rem;
}

.cliente-info-panel {
    width: 100%; 
    border-top: none; 
    background-color: #f8f9fa;
    border-radius: var(--radio);
    border: 1px solid var(--gris-claro);
    padding: 1.5rem 2rem;
}


.actions-wrapper {
    width: 100%;
}
.actions-container {
    padding-top: 2rem; 
    border-top: 1px solid var(--gris-claro);
    margin-top: 2rem;
}

#escanearQrSection.admin-card {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* ========================================================= */
/* ===== ESTILOS FINALES PARA LISTAS (Cumpleaños, Referidos y Reseñas) ===== */
/* ========================================================= */
#resenasSection h2,
#cumpleanosSection h2,
#referidosSection h2 {
    display: block;
    margin: 20px auto;
    text-align: center;
    font-size: 35px;
    font-family: var(--texto-principal);
        
}

.lista-items-moderna {
    list-style-type: none;
    padding: 0;
    margin: 0;
    
}

.list-item-cumpleanos {
    
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 10px; 
    border-bottom: 1px solid #444;
    transition: background-color 0.2s ease-in-out;
}

.list-item-cumpleanos:last-child {
    border-bottom: none;
}


.info-cliente {
    display: flex;
    flex-direction: column;
    gap: 4px; /* Espacio entre nombre y email */
}

.info-cliente strong {
    color: #180505;
    font-size: 1rem;
    font-weight: 600;
}

.info-cliente span {
    color: #aaa;
    font-size: 0.85rem;
}

/* ========================================================= */
/* ===== ESTILOS PARA LA LISTA DE CUPONES EN DETALLE ===== */
/* ========================================================= */

#lista-cupones-detalle,
#lista-cupones-scanner {
    
    list-style-type: none;
    padding: 0;
    margin-top: 10px;
    border-top: 1px solid #444;
}

#lista-cupones-detalle .list-item-cumpleanos, 
#lista-cupones-scanner .list-item-cumpleanos {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #444;
}

#lista-cupones-detalle .list-item-cumpleanos:last-child,
#lista-cupones-scanner .list-item-cumpleanos:last-child {
    border-bottom: none;
}

#lista-cupones-detalle .info-cliente strong,
#lista-cupones-scanner .info-cliente strong {
    color: #aa2525;
    font-size: 1.2rem;
    font-weight: 600;
}

#lista-cupones-detalle .info-cliente span,
#lista-cupones-scanner .info-cliente span {
    color: #aaa;
    font-size: 0.8rem;
    font-family: monospace; /* Ideal para IDs */
}

/* --- ESTILOS PARA EL BOTÓN DE CANJE --- */
.btn-canjear-cupon {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 110px;
    text-align: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    .btn-canjear-cupon:hover {
        background-color: var(--negro);
        color: var(--primario); /* Texto oscuro al hacer hover */
        box-shadow: 0 0 10px rgba(255, 214, 0, 0.5);
    }
}

.btn-canjear-cupon:active {
    background-color: var(--negro);
    color: var(--primario);
    transform: scale(0.96);
}

/* Estilo para cuando se hace clic y está procesando */
.btn-canjear-cupon:disabled {
    cursor: default;
    border-color: #555;
    background-color: #333;
    color: #888;
    transform: none;
}

/* Estilo para éxito (si lo añades con JS) */
.btn-canjear-cupon.btn-success {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

/* ========================================================= */
/* ===== ESTILOS PARA LA SECCIÓN DE GESTIÓN DE RULETA ===== */
/* ========================================================= */

.ruleta-admin-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}

.premio-ruleta-card {
    background-color: var(--tarjeta);
    border: 1px solid var(--gris-claro);
    border-radius: var(--radio);
    padding: 1.5rem;
    box-shadow: var(--sombra-suave);
    display: flex;
    flex-direction: column;
    gap: 1.25rem; /* Espacio entre los grupos de formulario */
}

.premio-ruleta-card h4 {
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gris-claro);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 1.2rem;
}

.premio-tipo {
    font-size: 0.8rem;
    font-weight: normal;
    color: var(--gris-medio);
    text-transform: uppercase;
}

.premio-ruleta-card .form-group {
    margin-bottom: 0; /* Quitamos el margen por defecto */
}

.premio-ruleta-card .form-group label {
    font-weight: bold;
    color: var(--gris-oscuro);
}

.form-group-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stock-info {
    margin-top: 5px;
    padding-top: 1rem;
    border-top: 1px solid var(--gris-claro);
    font-size: 0.9rem;
    color: var(--gris-medio);
    text-align: center;
}
.stock-info strong {
    font-family: var(--titulos);
    font-size: 1.1rem;
    color: var(--gris-oscuro);
}

/* --- Estilos para el Interruptor (Toggle Switch) --- */
.switch {position: relative; display: inline-block; width: 50px; height: 28px;}
.switch input {opacity: 0; width: 0; height: 0;}
.slider {position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s;}
.slider:before {position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s;}
input:checked + .slider {background-color: var(--verde);}
input:focus + .slider {box-shadow: 0 0 1px var(--verde);}
input:checked + .slider:before {transform: translateX(22px);}
.slider.round {border-radius: 34px;}
.slider.round:before {border-radius: 50%;}

/* ========================================================= */
/* ===== ESTILOS MEJORADOS PARA EL MODAL DE ADMIN ===== */
/* ========================================================= */

.modal-admin {
    display: none; 
    position: fixed; 
    z-index: 1050;
    left: 0; top: 0; 
    width: 100%; height: 100%;
    overflow-y: auto; /* Permite scroll si el contenido es largo */
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    
    /* Centrado flexible */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-admin-content {
    background-color: var(--tarjeta);
    padding: 2rem;
    border-radius: var(--radio);
    width: 100%; 
    max-width: 550px; /* Un poco más ancho */
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-admin-content .close-button {
    position: absolute; 
    top: 15px; right: 20px;
    font-size: 1.8rem; 
    font-weight: bold;
    color: #aaa; 
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    .modal-admin-content .close-button:hover {
        color: var(--rojo);
    }
}

.modal-admin-content h3 { 
    margin-top: 0;
    margin-bottom: 1.5rem; /* Más espacio debajo del título */
    text-align: center;
}

/* --- Estilos específicos para el formulario dentro del modal --- */
#form-nuevo-premio .form-group {
    margin-bottom: 1.25rem; /* Espaciado consistente entre campos */
}

#form-nuevo-premio label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--gris-medio);
}

/* Campos dinámicos que se ocultan/muestran */
.campos-dinamicos {
    border-left: 3px solid var(--primario);
    padding-left: 15px;
    margin-left: 5px;
    margin-top: 1rem;
}

/* Botón de envío */
#form-nuevo-premio .button-primary {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 1.5rem; /* Más espacio arriba del botón */
}

.campos-dinamicos-wrapper {
    border-left: 3px solid var(--primario);
    padding-left: 15px;
    margin-left: 5px;
}

/* ===================================================================
   ESTILOS "DARK MODE" IMPRESIONANTES PARA LA SECCIÓN DE ANALÍTICAS
   =================================================================== */

/* --- Contenedor Principal de la Sección --- */
#analiticasSection.admin-section {
    width: 100%;
    padding: 24px;
    box-sizing: border-box;
    background-color: #1a1a1a; 
}

/* --- La Rejilla --- */
#analiticasSection .analiticas-grid {
    width: 100%;
    display: grid;
    justify-content: center;
    align-items: center;
    grid-template-columns: repeat(2, 1fr); 
    gap: 20px; 
}

#analiticasSection h2 {
    color: var(--primario-oscuro);
    text-align: center;
    margin-bottom: 40px;
}

/* --- Estilo de la Tarjeta --- */
#analiticasSection .analiticas-card {
    display: flex; 
    flex-direction: column; 
    max-height: 400px; /* Un poco más de altura para que respire */
    background-color: #2c2c2c; /* Fondo de tarjeta gris oscuro */
    border-radius: 16px; /* Bordes más redondeados */
    padding: 24px;
    border: 1px solid #444; /* Borde sutil */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

/* FIX: Hover solo en dispositivos con ratón */
@media (hover: hover) {
    #analiticasSection .analiticas-card:hover {
        transform: translateY(-5px);
        border-color: var(--color-primario); /* Borde amarillo al hacer hover */
    }
}

/* Canvas del gráfico dentro de la tarjeta */
#analiticasSection .analiticas-card canvas {
    flex-grow: 1; 
    min-height: 0; 
}

/* --- Título de la Tarjeta --- */
#analiticasSection .analiticas-card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1em;
    font-weight: 600;
    color: #f0f0f0; /* Texto claro */
    border-bottom: 1px solid #444;
    padding-bottom: 15px;
    text-align: center;
}

/* --- Lista de Top Clientes --- */
#analiticasSection #topClientesList {
    padding-left: 0;
    list-style: none;
    margin: 0;
    overflow-y: auto; /* Permite scroll si hay muchos clientes */
}

#analiticasSection #topClientesList li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5px; /* Más padding vertical */
    border-bottom: 1px solid #444;
}

#analiticasSection #topClientesList li:last-child {
    border-bottom: none;
}

#analiticasSection .cliente-nombre {
    color: #e0e0e0;
    font-weight: 500;
}

#analiticasSection .cliente-puntos {
    background-color: rgba(255, 214, 0, 0.5); /* Fondo amarillo muy transparente */
    color: var(--color-primario); /* Texto amarillo */
    border: 1px solid var(--color-primario);
    font-weight: bold;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9em;
}


/* ==========================================================================
   10. RESPONSIVE DESIGN (TABLET Y MÓVILES)
   ========================================================================== */

@media (max-width: 992px) {
    .sidebar { width: 70px;}
    .sidebar-header h2, .sidebar-nav .nav-button span, .user-info, .sidebar-footer { display: none; /* Ocultamos texto */ }
    .nav-button { justify-content: center; padding: 1rem 0; }
    .main-content { padding: 1.5rem; }
}

@media (max-width: 768px) {
    body {
        /* Para evitar que el scroll de la barra de nav afecte al cuerpo entero */
        height: 100vh;
        overflow: hidden;
    }
    .app-container {
        flex-direction: column;
        height: 100vh;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 0.5rem 1rem;
        box-shadow: var(--sombra-media);
        order: -1; /* Pone la barra arriba */
    }
    .sidebar-header {
        border-bottom: none;
        padding: 0;
        margin-right: auto; /* Empuja el nav hacia la derecha */
    }
    .sidebar-nav {
        flex-grow: 1;
        overflow-x: auto;
        /* Ocultar barra de scroll visualmente */
        -ms-overflow-style: none; /* IE y Edge */
        scrollbar-width: none; /* Firefox */
    }
    .sidebar-nav::-webkit-scrollbar { display: none; /* Chrome, Safari y Opera */ }
    .sidebar-nav ul {
        display: flex;
        flex-direction: row;
        margin: 0;
        white-space: nowrap;
    }
    .nav-button {
        padding: 0.75rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    .nav-button.active {
        border-left: none;
        border-bottom-color: var(--primario-oscuro);
    }
    .sidebar-footer { display: none; }
    
    .main-content {
        padding: 1.5rem;
        flex-grow: 1;
        overflow-y: auto; /* Permite scroll solo en el contenido */
    }
    .dashboard-grid { grid-template-columns: 1fr; }
    .admin-card h2 { font-size: 1.5rem; }

    .action-buttons {
        grid-template-columns: repeat(3, 1fr); /* 3 columnas en escritorio para Acreditar */
    }
    #client-actions-view .action-panel:last-of-type .action-buttons {
        grid-template-columns: repeat(4, 1fr); /* 4 columnas para Canjear */
    }

    #clientesSection .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    #clientesSection .button-secondary {
      width: 100%;
    }

    .dashboard-grid-dynamic {
        grid-template-columns: 1fr; /* 1 columna en móvil */
    }

    .highlight-card {
        min-height: 120px;
    }

    .list-item-cumpleanos,
    .list-item-referido {
        flex-direction: column; /* Apilamos los elementos en vertical */
        align-items: flex-start; /* Alineamos al inicio */
        gap: 15px; /* Espacio entre el info y el botón */
    }

    .btn-enviar-regalo,
    .btn-aprobar-referido {
        width: 100%; 
    }
}


/* ==========================================================================
   SKELETON LOADERS (Animación de Carga)
   ========================================================================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    color: transparent !important;
    height: 1.2em;
    width: 100%;
    display: inline-block;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}