/* RESET */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial;
    background: #0f172a; /* azul oscuro elegante */
    color: #e5e7eb;
}

/* CONTENEDOR PRINCIPAL */
#app {
    max-width: 480px;
    margin: auto;
    padding: 16px;
}

/* HEADER */
header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 22px;
    margin: 0;
}

/* sweetalert2 */
.swal2-popup {
    font-size: 1.2rem;
    border-radius: 12px;
}

/* CARD */
.card {
    background: #1e293b;
    box-shadow: none;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

/* INFO */
#info p {
    margin: 4px 0;
    font-size: 14px;
}

/* BOTONES */
button {
    border: none;
    border-radius: 10px;
    padding: 8px;
    font-size: 15px;
    font-weight: 600;
    width: 100%;
}

/* BOTÓN PRINCIPAL */
#btn-open-camera {
    background: #6366f1; /* violeta moderno */
    color: white;
}

/* BOTÓN SECUNDARIO */
#btn-upload {
    background: #6366f1; /* verde más elegante */
    color: white;
}

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button svg {
    width: 32px;
    height: 32px;
}

/* BOTONES DISABLED */
button:disabled {
    background: #ccc;
}

.btn-alt {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    
    background: #334155; /* gris elegante */
    color: #e2e8f0;

    font-weight: 500;
    font-size: 15px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    transition: all 0.2s ease;
}

/* hover / touch */
.btn-alt:active {
    transform: scale(0.98);
    background: #3b475f;
}

/* icono */
.btn-alt svg {
    opacity: 0.9;
}

/* THUMBNAILS */
#preview {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    min-height: 100px;
}

#empty-state {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    pointer-events: none;
}

.empty-icon {
    color: #94a3b8;
    opacity: 0.25;
}

/* THUMB */
.thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: #111827;
}

/* IMAGEN */
.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 🔥 clave */
}

/* BOTÓN ELIMINAR */
.thumbnail button {
    position: absolute;
    top: 4px;
    right: 4px;

    width: 22px;
    height: 22px;

    border-radius: 50%;
    border: none;

    background: rgba(0,0,0,0.6);
    color: #fff;

    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;
}

#numero {
    margin-right: 20px;
}

/* STATUS */
#status {
    text-align: center;
    margin-top: 10px;
    font-weight: 500;
}

/* =============================
   📌 LOADER OVERLAY (PRO)
============================= */

#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    background: rgba(15, 23, 42, 0.85); /* fondo oscuro semitransparente */
    backdrop-filter: blur(4px);

    display: none; /* oculto por defecto */
    align-items: center;
    justify-content: center;
    flex-direction: column;

    z-index: 9999;
}

/* Spinner */
.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #6366f1;
    border-radius: 50%;

    animation: spin 1s linear infinite;
}

/* Texto */
.loader-text {
    margin-top: 15px;
    color: #fff;
    font-size: 14px;
    opacity: 0.9;
    letter-spacing: 0.5px;
}

/* Animación spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#empty-state {
    text-align: center;
    padding: 30px 10px;
    color: #6b7280;
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

#toast-container {
    position: fixed;
    top: 12px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 999;
    pointer-events: none;
}

.toast {
    max-width: 90%;
    padding: 15x 24px;
    border-radius: 10px;

    font-size: 15px;
    font-weight: 500;

    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    background: rgba(30, 41, 59, 0.85);
    color: #fff;

    box-shadow: 0 8px 20px rgba(0,0,0,0.2);

    opacity: 0;
    transform: translateY(-10px);

    animation: toastInOut 3s forwards;
}

/* WARNING */
.toast.warning {
    background: rgba(245, 158, 11, 0.35);
    color: #facc15;
    border: 1px solid rgba(245, 158, 11, 0.55);

}

/* SUCCESS */
.toast.success {
    background: rgba(34, 197, 94, 0.35);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.55);
}

/* ERROR */
.toast.error {
    background: rgba(239, 68, 68, 0.35);
    color: #f0b7b7;
    border: 1px solid rgba(239, 68, 68, 0.55);
}
    
/* ANIMACIÓN PRO */
@keyframes toastInOut {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    10% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

#scanner-container {
    position: relative;
}

/* ELIMINAMOS overlay oscuro completamente */
.scanner-overlay {
    display: none;
}

/* Video limpio */
#qr-reader video {
    width: 100% !important;
    height: auto !important;
    border-radius: 12px;
}

/* CONTENEDOR */
#qr-reader__scan_region {
    position: relative;
}

/* MARCO QR (ESQUINAS PRO) */
#qr-reader__scan_region::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 65%;
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    box-sizing: border-box;

    background:
        linear-gradient(white, white) top left,
        linear-gradient(white, white) top right,
        linear-gradient(white, white) bottom left,
        linear-gradient(white, white) bottom right;

    background-size: 30px 3px, 30px 3px, 30px 3px, 30px 3px;
    background-repeat: no-repeat;
}

/* TEXTO */
.scanner-text {
    text-align: center;
    margin-top: 12px;
    color: #cbd5f5;
    font-size: 14px;
}

/* BOTÓN CERRAR ELIMINADO */
.scanner-close {
    display: none;
}