/* /css/styles.css*/
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --accent: #eff6ff;
    --border: #f1f5f9;
    --shadow: 0 -10px 25px -5px rgba(0,0,0,0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    /*NUEVO*/
    overscroll-behavior-y: contain;
}

.app-container {
    width: 100vw;
    max-width: 420px;
    /*height: 100vh; OFF*/
    min-height: 100dvh;
    background: var(--card);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.header-info { display: flex; align-items: center; gap: 10px; }
.logo-mini { width: 35px; height: 35px; border-radius: 6px; object-fit: contain; }
h1 { font-size: 1.4rem; margin: 0; font-weight: 700; font-family: 'Inter', sans-serif; }
.btn-logout-mini { background: none; border: none; color: #ef4444; font-weight: 600; font-size: 0.85rem; cursor: pointer; }

.app-body { flex: 1; padding: 20px; overflow-y: auto; padding-bottom: 90px; }
.tab-view { animation: fadeIn 0.3s ease; }
.hidden { display: none !important; }
.hidden-panel { margin-top: 20px; }
.hidden-panel.show { display: block !important; }

/* QR View */
#qr-container { background: #FCF7F7; padding: 20px; border-radius: 24px; text-align: center; margin-top: 5px; }
#qrcode { display: flex; justify-content: center; margin-bottom: 10px; }
#qrcode img { max-width: 240px; }
.instructions { font-weight: 600; margin-bottom: 4px; }
.slogan { font-size: 0.85rem; color: var(--text-light); margin-bottom: 15px; }
.reward { padding: 12px; background: var(--accent); color: var(--primary); border-radius: 12px; font-weight: 700; border: 1px dashed #bfdbfe; margin-bottom: 0px;}

/* Buttons */
.actions {
    margin-top: 22px;
}
.btn-primary {
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-primary:hover { background: var(--primary-dark); }

/* HERO BUTTON (QR principal) */
.btn-hero {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
}

/* INLINE BUTTON (Buscar DNI) */
.btn-inline {
    width: auto;
    padding: 0 20px;
    height: 48px;
    font-size: 0.95rem;
    white-space: nowrap;
}

/* BLOCK BUTTON (Settings) */
.btn-block {
    width: 100%;
    min-height: 52px;
    padding: 14px 18px;
    font-size: 1rem;
}

/* Customers View */
.search-box { display: flex; gap: 8px; margin-top: 15px; }

.search-box input, .customer-buttons input { 
    flex: 1; 
    padding: 12px; 
    border: 1px solid #cbd5e1; 
    border-radius: 12px; 
    font-size: 1rem; 
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.search-box input:focus, .customer-buttons input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.customer-card { background: var(--bg); padding: 16px; border-radius: 16px; border: 1px solid var(--border); margin-top: 15px; }
.customer-card h3 { margin: 0 0 8px 0; font-size: 1.1rem; }
.customer-card p { margin: 4px 0; font-size: 0.9rem; color: var(--text-light); }
.stamps-badge { display: inline-block; background: #dbeafe; color: #1e40af; padding: 4px 10px; border-radius: 20px; font-weight: 700; margin-top: 8px !important; }
.customer-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 15px; }
.btn-action { width: 100%; padding: 12px; border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn-add { background: #bbf7d0; color: #166534; }
.btn-redeem { background: #fed7aa; color: #9a3412; }

/* Metrics View */
.metrics-grid { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; }
.metric-card { background: var(--bg); border: 1px solid var(--border); padding: 20px; border-radius: 16px; text-align: center; }
.metric-value { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.metric-label { font-size: 0.85rem; color: var(--text-light); font-weight: 600; }

/* Bottom Nav Bar */
/*.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: 70px; background: white; border-top: 1px solid var(--border); display: flex; justify-content: space-around; align-items: center; } OFF*/
/* Bottom Nav Bar */
.bottom-nav { 
    position: fixed; 
    bottom: 0; 
    left: 50%; /* Centra la barra en la pantalla */
    transform: translateX(-50%); /* Ajuste técnico para el centrado perfecto */
    width: 100%; /* Ocupa el ancho disponible... */
    max-width: 420px; /* ...pero nunca se estira más que tu contenedor principal */
    height: 70px; 
    background: white; 
    border-top: 1px solid var(--border); 
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    box-sizing: border-box; /* Evita desbordamientos por bordes */
}

.nav-item { background: none; border: none; display: flex; flex-direction: column; align-items: center; color: var(--text-light); cursor: pointer; font-size: 0.75rem; font-weight: 500; }
.nav-icon { font-size: 1.3rem; margin-bottom: 2px; }
.nav-item.active { color: var(--primary); font-weight: 700; }

.tab-view h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    letter-spacing: -0.5px;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Notificaciones Flotantes (Toasts) */
.toast-container {
    position: fixed;
    bottom: 90px; /* Por encima de la barra de navegaci贸n inferior */
    left: 50%;
    transform: translateX(-50%);
    
    width: auto;
    max-width: 90vw;
    min-width: 200px;
    text-align: center;
    white-space: normal;
    
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    white-space: normal;
    
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }

/*NUEVO: SELECT METRICS*/
/* Contenedor del filtro */
.metrics-filter {
    margin: 15px 0;
    display: flex;
    justify-content: flex-end;
}

/* Estilo moderno para el Select */
#metrics-range {
    width: 100%;
    max-width: 200px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: #1e293b;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    /* Flecha personalizada */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 40px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
}

#metrics-range:focus {
    border-color: #3b82f6; /* Cambia esto al color principal de tu app */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}


/* Contenedor del QR y sus capas */
.qr-wrapper {
    position: relative;
    width: 256px;
    height: 256px;
    margin: 0 auto 15px auto;
}

/* Capas absolutas para los estados */
.qr-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff; /* Fondo blanco para tapar el QR por completo */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 10;
    animation: fadeInSmooth 0.4s ease-out forwards;
}

/* Animación suave de aparición */
@keyframes fadeInSmooth {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Diseño del Check de Éxito */
.success-checkmark {
    text-align: center;
    color: #22c55e; /* Verde Éxito */
}
.success-checkmark i {
    font-size: 80px;
    margin-bottom: 15px;
}
.success-checkmark p {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* Diseño del Candado de Expiración */
.expired-lock {
    text-align: center;
    color: #ef4444; /* Rojo Alerta */
}
.expired-lock i {
    font-size: 80px;
    margin-bottom: 15px;
}
.expired-lock p {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* Botón deshabilitado */
.btn-primary.disabled, .btn-primary:disabled {
    background-color: #cbd5e1 !important;
    color: #64748b !important;
    cursor: not-allowed !important;
    border-color: #cbd5e1 !important;
}