/* ============================================
   qr-admin.css — Estilos del módulo QRs Aliados
   Acceso restringido a roles admin.
   ============================================ */

/* Por defecto el item del sidebar arranca OCULTO.
   js/qr-admin.js lo muestra solo si el usuario es admin. */
#nav-qr-admin {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    gap: 4px;
}

/* ============================================
   CONTENEDOR PRINCIPAL DE LA VISTA
   ============================================ */

#page-qr-admin {
    background: #f4f6f9;
    min-height: 100vh;
    display: none;
    padding-top: 130px; /* 👈 esta es la única línea que falta */
    box-sizing: border-box;
}

#page-qr-admin.active {
    display: block !important;
    margin: 0 !important;
    padding-top: 130px !important; /* 👈 reemplaza el padding: 0 !important */
}

.qra-wrap {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto !important;    /* 👈 El 'auto' ahora sí centrará horizontalmente con precisión */
    padding: 0px 32px 40px !important; /* 👈 Cambiamos el 0 de arriba por 24px para darle un respiro limpio respecto al techo */
    box-sizing: border-box;
}

/* ============================================
   TOPBAR / HEADER DE LA VISTA
   ============================================ */

.qra-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 18px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 20px;
}

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

.qra-topbar-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #022D2B, #2AA048);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qra-topbar-icon i {
    color: white;
    font-size: 18px;
}

.qra-topbar-title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.3px;
    margin: 0;
}

.qra-topbar-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 1px;
}

/* ============================================
   CONTENEDOR DE CONTENIDO (cascarón vacío)
   ============================================ */

.qra-content {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 40px;
    min-height: 400px;
}

.qra-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.qra-empty-state i {
    font-size: 48px;
    opacity: 0.3;
    display: block;
    margin-bottom: 16px;
}

.qra-empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: #475569;
    margin: 0 0 8px 0;
}

.qra-empty-state p {
    font-size: 14px;
    margin: 0;
}

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

@media (max-width: 768px) {
    .qra-wrap {
        padding: 0 16px 24px;
    }
    .qra-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .qra-topbar-title {
        font-size: 18px;
    }
    .qra-content {
        padding: 24px 16px;
    }
}

@media (max-width: 480px) {
    .qra-wrap {
        padding: 0 12px 20px;
    }
    .qra-topbar-icon {
        width: 36px;
        height: 36px;
    }
    .qra-topbar-icon i {
        font-size: 16px;
    }
    .qra-topbar-title {
        font-size: 16px;
    }
    .qra-empty-state {
        padding: 40px 12px;
    }
    .qra-empty-state i {
        font-size: 40px;
    }
}

/* ============================================
   ESTILOS DE LA VISTA PRINCIPAL (FORMULARIO Y ESTADOS)
   ============================================ */

/* Ocultar vistas inactivas */
.qra-view { display: none; animation: fadeIn 0.3s ease; }
.qra-view.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Headers de vistas */
.qra-form-header, .qra-success-header { margin-bottom: 30px; }
.qra-form-header h3, .qra-success-header h3 { font-size: 20px; color: #1f2937; margin: 0 0 8px 0; }
.qra-form-header p, .qra-success-header p { color: #6b7280; margin: 0; font-size: 14px; }

/* Formulario */
.qra-form-body { max-width: 500px; }
.qra-form-group { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.qra-form-group label { font-size: 14px; font-weight: 600; color: #374151; }
.qra-input { padding: 12px 16px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; transition: border-color 0.2s; font-family: inherit; }
.qra-input:focus { border-color: #2AA048; outline: none; box-shadow: 0 0 0 3px rgba(42, 160, 72, 0.1); }
.qra-help-text { font-size: 12px; color: #9ca3af; }

/* Botones */
.qra-btn-primary { background: #2AA048; color: white; padding: 12px 24px; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.qra-btn-primary:hover { background: #1e8038; }
.qra-btn-secondary { background: white; color: #374151; padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.qra-btn-secondary:hover { background: #f3f4f6; border-color: #9ca3af; }
.qra-btn-outline { background: transparent; color: #2AA048; padding: 10px 20px; border: 1px solid #2AA048; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.qra-btn-outline:hover { background: #f0fdf4; }

/* Loader principal */
.qra-loader-container { text-align: center; padding: 60px 20px; }
.qra-spinner { width: 50px; height: 50px; border: 4px solid #f3f4f6; border-top: 4px solid #2AA048; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Pantalla de Éxito */
.qra-success-header { text-align: center; }
.qra-success-icon { width: 60px; height: 60px; background: #dcfce7; color: #2AA048; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 16px; }

/* Resumen */
.qra-summary-box { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 20px; margin-bottom: 30px; display: flex; gap: 40px; justify-content: center; flex-wrap: wrap; }
.qra-summary-item { display: flex; flex-direction: column; gap: 4px; text-align: center; }
.qra-summary-item span { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; }
.qra-summary-item strong { font-size: 16px; color: #111827; }

/* Cajas de Descarga */
.qra-downloads-section { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.qra-download-box { display: flex; align-items: center; justify-content: space-between; padding: 20px; border-radius: 12px; border: 1px solid transparent; transition: all 0.3s; }
.qra-box-info { display: flex; align-items: center; gap: 16px; }
.qra-box-info i { font-size: 24px; }
.qra-box-info h4 { margin: 0 0 4px 0; font-size: 15px; color: #111827; }
.qra-box-info p { margin: 0; font-size: 13px; }

/* Estado Verde (Listo) */
.green-box { background: #f0fdf4; border-color: #bbf7d0; }
.green-box .qra-box-info i { color: #2AA048; }
.green-box .qra-box-info p { color: #166534; font-weight: 500; }

/* Estado Amarillo (Procesando) */
.yellow-box { background: #fefce8; border-color: #fef08a; }
.yellow-box .qra-box-info i { color: #ca8a04; }
.yellow-box .qra-box-info p { color: #854d0e; }

/* Mini spinner para la caja amarilla */
.qra-mini-spinner { width: 24px; height: 24px; border: 3px solid #fef08a; border-top: 3px solid #ca8a04; border-radius: 50%; animation: spin 1s linear infinite; }

/* Texto aclaratorio */
.qra-disclaimer { font-size: 13px; color: #6b7280; display: flex; align-items: center; gap: 8px; justify-content: center; background: #f3f4f6; padding: 12px; border-radius: 8px; }
.qra-disclaimer i { color: #9ca3af; }

/* ============================================
   TABLA HISTÓRICA DE LOTES (M3)
   ============================================ */

#qra-tabla-lotes td {
    padding: 12px 16px;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    text-align: center;
}

#qra-tabla-lotes tbody tr:hover {
    background: #f9fafb;
}

#qra-tabla-lotes tbody tr:last-child td {
    border-bottom: none;
}

.qra-tabla-cargando,
.qra-tabla-vacia,
.qra-tabla-error {
    text-align: center;
    padding: 40px 16px !important;
    font-size: 14px;
    color: #9ca3af;
}

.qra-tabla-error {
    color: #ef4444;
}

.qra-col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.qra-col-acciones {
    text-align: center;
    white-space: nowrap;
}

.qra-lote-nombre {
    font-weight: 600;
    font-size: 13px;
    color: #111827;
    font-family: monospace;
}

/* ============================================
   BADGES DE ESTADO
   ============================================ */

.qra-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.qra-badge-verde   { background: #dcfce7; color: #166534; }
.qra-badge-amarillo { background: #fefce8; color: #854d0e; }
.qra-badge-rojo    { background: #fee2e2; color: #991b1b; }
.qra-badge-azul    { background: #dbeafe; color: #1e40af; }
.qra-badge-gris    { background: #f3f4f6; color: #6b7280; }
.qra-badge-naranja { background: #fff7ed; color: #9a3412; }
.qra-badge-negro   { background: #f1f5f9; color: #334155; }

/* ============================================
   BOTONES DE ACCIÓN EN TABLA
   ============================================ */

.qra-btn-accion {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
    margin: 0 2px;
}

.qra-btn-accion:hover {
    background: #e5e7eb;
}

.qra-btn-pdf {
    color: #1e40af;
    border-color: #bfdbfe;
    background: #eff6ff;
}

.qra-btn-pdf:hover {
    background: #dbeafe;
}

.qra-btn-reintentar {
    color: #854d0e;
    border-color: #fef08a;
    background: #fefce8;
}

.qra-btn-reintentar:hover {
    background: #fef9c3;
}

.qra-btn-danger {
    color: #991b1b;
    border-color: #fecaca;
    background: #fff1f1;
}

.qra-btn-danger:hover {
    background: #fee2e2;
}

/* ============================================
   PAGINACIÓN
   ============================================ */

.qra-paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    color: #6b7280;
}

.qra-paginacion button {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 14px;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
}

.qra-paginacion button:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* ============================================
   ESTADO ROJO (ERROR PDFs)
   ============================================ */

.red-box {
    background: #fff1f1;
    border-color: #fecaca;
}

.red-box .qra-box-info i { color: #ef4444; }
.red-box .qra-box-info p { color: #991b1b; }

/* ============================================
   MODAL DETALLE DE LOTE
   ============================================ */

#qra-modal-tabla td {
    padding: 10px 12px;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

#qra-modal-tabla tbody tr:last-child td {
    border-bottom: none;
}

.qra-cod-corto {
    font-family: monospace;
    font-weight: 600;
    font-size: 13px;
}

.qra-sin-aliado {
    color: #d1d5db;
}

/* ============================================
   M4 — BÚSQUEDA INDIVIDUAL DE QR
   ============================================ */

.qra-buscando {
    text-align: center;
    padding: 24px;
    color: #6b7280;
    font-size: 14px;
}

.qra-resultado-vacio,
.qra-resultado-error {
    text-align: center;
    padding: 32px 16px;
    color: #9ca3af;
    font-size: 14px;
}

.qra-resultado-error { color: #ef4444; }

.qra-resultado-exito {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #166534;
}

.qra-resultado-exito i { font-size: 20px; }

.qra-resultado-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.qra-resultado-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.qra-uuid-display {
    font-family: monospace;
    font-size: 12px;
    color: #6b7280;
    word-break: break-all;
}

.qra-resultado-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.qra-resultado-campo {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.qra-campo-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.qra-campo-valor {
    font-size: 14px;
    color: #111827;
    font-weight: 500;
}

.qra-resultado-acciones {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.qra-btn-danger-outline {
    background: white;
    color: #ef4444;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.qra-btn-danger-outline:hover {
    background: #fff1f1;
    border-color: #ef4444;
}

.qra-resultado-nota,
.qra-resultado-info-extra {
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

@media (max-width: 480px) {
    .qra-resultado-grid { grid-template-columns: 1fr; }
}

/* ============================================
   SISTEMA DE TABS (Lotes generados | Resumen)
   ============================================ */

.qra-tabs-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 24px;
}

.qra-tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.qra-tab-btn:hover { color: #2AA048; }

.qra-tab-btn.active {
    color: #2AA048;
    border-bottom-color: #2AA048;
}

.qra-tab-content {
    display: none;
    animation: fadeIn 0.25s ease;
}

.qra-tab-content.active { display: block; }

/* ============================================
   M5 — DASHBOARD DE RESUMEN
   ============================================ */

.qra-kpis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.qra-kpi-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: transform 0.15s, box-shadow 0.15s;
}

.qra-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.qra-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.qra-kpi-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.qra-kpi-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.qra-kpi-valor {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.qra-kpi-sub {
    font-size: 11px;
    color: #6b7280;
}

.qra-grafica-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.qra-grafica-placeholder {
    background: #f9fafb;
    border: 2px dashed #e5e7eb;
    border-radius: 8px;
    padding: 48px 24px;
    text-align: center;
    color: #9ca3af;
}

.qra-grafica-placeholder i {
    font-size: 36px;
    opacity: 0.4;
    display: block;
    margin-bottom: 12px;
}

.qra-grafica-placeholder p {
    font-size: 13px;
    margin: 0;
}