/* ==========================================================
   bioqr_serv — estilos propios (vista cobros QR / misqrs)
   Sin dependencias externas. Mobile-first.
   ========================================================== */

:root {
    --bio:        #ff5d00;
    --bio-dark:   #d94e00;
    --bio-soft:   #fff3ec;
    --ink:        #1f2630;
    --ink-soft:   #5b6573;
    --line:       #e7eaee;
    --bg:         #f4f6f9;
    --card:       #ffffff;
    --success:    #1f9d57;
    --success-dk: #157a43;
    --danger:     #d23b3b;
    --radius:     16px;
    --radius-sm:  10px;
    --shadow:     0 10px 30px rgba(31, 38, 48, .08);
    --shadow-sm:  0 2px 8px rgba(31, 38, 48, .06);
    --mono:       "SFMono-Regular", "Consolas", "Liberation Mono", Menlo, monospace;
    --sans:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--sans);
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ----------------------------- Topbar ----------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 18px;
    color: #fff;
    background: linear-gradient(100deg, var(--bio) 0%, var(--bio-dark) 100%);
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: .2px;
}

.brand-dot {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ----------------------------- Botones ---------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 999px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-light   { background: #fff; color: var(--bio); box-shadow: var(--shadow-sm); }
.btn-light:hover { background: var(--bio-soft); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dk); }

.btn-sm { padding: 6px 14px; font-size: .82rem; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--bio);
    box-shadow: var(--shadow-sm);
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform .3s ease, background .15s ease;
}
.btn-icon:hover { background: var(--bio-soft); }
.btn-icon:active { transform: rotate(180deg); }

/* el botón de esperar es un poco más ancho (pastilla) */
#btnWait {
    width: 58px;
    border-radius: 999px;
}
#btnWait:active { transform: none; }
/* en modo "detener" el cuadrado ■ se ve mejor un poco más pequeño */
#btnWait.is-stopping { font-size: 1.05rem; }

/* ----------------------------- Layout ----------------------------- */
.container {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 22px 16px 40px;
}

/* --------------------------- Tarjeta QR --------------------------- */
.qr-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: rise .35s ease both;
}

.qr-image-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 22px;
    background:
        radial-gradient(circle at 50% 0%, var(--bio-soft), #fff 70%);
}

.qr-image-wrap img {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: #fff;
    transition: opacity .2s ease;
}

/* spinner de carga de la imagen del QR */
.qr-spinner {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 52px;
    height: 52px;
    border: 5px solid var(--bio-soft);
    border-top-color: var(--bio);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: none;
}
.qr-image-wrap.loading .qr-spinner { display: block; }
.qr-image-wrap.loading img        { opacity: 0; }

.qr-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--line);
    border-top: 1px solid var(--line);
}

.detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--card);
}

.detail-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-soft);
    font-weight: 600;
}

.detail-value {
    font-family: var(--mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.15;
    word-break: break-word;
}

.detail-value.accent { color: var(--bio); }

/* ------------------------- Estado vacío --------------------------- */
.empty-state {
    text-align: center;
    padding: 70px 20px;
    color: var(--ink-soft);
    animation: rise .35s ease both;
}
.empty-icon {
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bio-soft);
    color: var(--bio);
    font-size: 2.4rem;
    font-weight: 800;
}
.empty-state p {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}

/* ----------------------------- Modal ------------------------------ */
.modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: none;
}
/* El centrado se resuelve con flex y NO con transform: las animaciones de
   entrada (rise/fade) animan transform y, con fill-mode both, borrarían un
   translate(-50%,-50%) dejando el cuadro fuera de la pantalla. */
.modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(15, 20, 27, .5);
    animation: fade .2s ease both;
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0,0,0,.28);
    animation: rise .25s ease both;
}

.modal-header {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.modal-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}
.modal-close {
    border: 0;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
    flex: 1 1 auto;
    min-height: 0;              /* permite que el scroll interno funcione */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
}

/* --------------------------- Lista QRs ---------------------------- */
.qr-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.qr-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--card);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.qr-list-item:hover {
    border-color: var(--bio);
    box-shadow: var(--shadow-sm);
}

.qr-list-num {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--bio-soft);
    color: var(--bio);
    font-size: .8rem;
    font-weight: 700;
}

.qr-list-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}
.qr-list-placa {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
}
.qr-list-meta {
    font-size: .76rem;
    color: var(--ink-soft);
}
.qr-list-monto {
    font-family: var(--mono);
    font-weight: 700;
    color: var(--bio);
    white-space: nowrap;
}

/* ----------------------------- Loader ----------------------------- */
.loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    place-items: center;
    background: rgba(244, 246, 249, .82);
    backdrop-filter: blur(2px);
}
.loader-overlay.open { display: grid; }

.loader-content { text-align: center; }
.loader-brand {
    margin: 0 0 10px;
    font-size: 3.2rem;
    font-weight: 800;
    color: var(--bio);
}
.loader-text {
    margin: 0 0 16px;
    font-size: .92rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.loader-dots {
    display: inline-flex;
    gap: 8px;
}
.loader-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bio);
    animation: bounce 1s infinite ease-in-out;
}
.loader-dots span:nth-child(2) { animation-delay: .15s; }
.loader-dots span:nth-child(3) { animation-delay: .3s; }

/* --------------------- Espera de pago (drain) --------------------- */
.wait-zone {
    margin-top: 10px;
    padding: 12px 18px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: none;
    animation: rise .3s ease both;
}
.wait-zone.open { display: block; }

.wait-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.wait-text {
    margin: 0;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.wait-count {
    font-family: var(--mono);
    font-weight: 700;
    color: var(--bio);
    font-size: 1rem;
}

.wait-bar {
    height: 12px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}
.wait-bar-fill {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--bio) 0%, var(--bio-dark) 100%);
}
/* el loader se "descarga": va de lleno a vacío.
   La duración la define el JS con --wait-seconds (fallback 30s). */
.wait-bar-fill.draining {
    animation: drain var(--wait-seconds, 30s) linear forwards;
}

/* --------------------- Resultado de la espera (modal) ------------- */
.modal-alert {
    position: relative;
    width: 100%;
    max-width: 360px;
    max-height: 100%;
    overflow-y: auto;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 26px 26px;
    text-align: center;
    animation: rise .25s ease both;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.modal-actions .btn { flex: 1; }

.btn-outline {
    background: #fff;
    color: var(--bio);
    border: 2px solid var(--bio);
}
.btn-outline:hover { background: var(--bio-soft); }

.wait-result-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bio-soft);
    color: var(--bio);
    font-size: 2.2rem;
    font-weight: 800;
}
.wait-result-icon.success {
    background: #e8f7ee;
    color: var(--success);
}
.wait-result-text {
    margin: 0 0 22px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.4;
}

/* --------------------------- Página 404 --------------------------- */
.error-page {
    min-height: calc(100vh - 62px);
    display: grid;
    place-items: center;
    padding: 30px 16px;
}
.error-card {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 28px;
    text-align: center;
    animation: rise .35s ease both;
}
.error-code {
    font-size: 4.6rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    background: linear-gradient(100deg, var(--bio) 0%, var(--bio-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.error-card h2 {
    margin: 12px 0 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
}
.error-card p {
    margin: 0 0 24px;
    color: var(--ink-soft);
    font-size: .95rem;
    line-height: 1.5;
}
.btn-primary { background: var(--bio); color: #fff; }
.btn-primary:hover { background: var(--bio-dark); }

/* ----------------------- Selección de bombas ---------------------- */
.topbar-chip {
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
}

.section-head { margin: 4px 0 18px; }
.section-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
}
.section-sub {
    margin: 4px 0 0;
    font-size: .85rem;
    color: var(--ink-soft);
}

.bomba-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.bomba-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .1s;
    animation: rise .3s ease both;
}
.bomba-card:hover {
    border-color: var(--bio);
    box-shadow: var(--shadow);
}
.bomba-card:active { transform: translateY(1px); }

.bomba-num {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bio-soft);
    color: var(--bio);
    font-family: var(--mono);
    font-size: 1.05rem;
    font-weight: 800;
}

.bomba-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.bomba-titulo {
    font-weight: 700;
    color: var(--ink);
}
.bomba-desc {
    font-size: .78rem;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bomba-tipo {
    flex: none;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    background: var(--line);
    color: var(--ink-soft);
}
.bomba-tipo.tipo-L { background: var(--bio-soft);  color: var(--bio); }
.bomba-tipo.tipo-G { background: #e8f7ee;          color: var(--success); }
.bomba-tipo.tipo-W { background: #eaf1fb;          color: #2a63b8; }

/* --------------------------- Animaciones -------------------------- */
@keyframes rise   { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
@keyframes drain  { from { width: 100%; } to { width: 0%; } }
@keyframes spin   { to { transform: rotate(360deg); } }
