/* ==========================================================================
   1. VARIABLES Y PALETA DE COLORES (ALTO CONTRASTE NEÓN AZUL / NEÓN ROJO)
   ========================================================================== */
:root {
    --bg-dark: #090b10;
    --bg-panel: #111520;
    --bg-card: #161b29;
    --border-subtle: rgba(255, 255, 255, 0.12);
    --text-main: #f3f6fc;
    --text-muted: #9aa5b8;
    --neon-blue: #00d2ff;
    --neon-blue-glow: rgba(0, 210, 255, 0.35);
    --neon-red: #ff2a55;
    --neon-red-glow: rgba(255, 42, 85, 0.35);
    --status-green: #10b981;
    --status-blue: #3b82f6;
    --status-amber: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   2. BARRA SUPERIOR Y BOTONES NEÓN
   ========================================================================== */
.topbar {
    background-color: rgba(17, 21, 32, 0.95);
    border-bottom: 1px solid rgba(0, 210, 255, 0.3);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(0, 210, 255, 0.12);
    border: 1px solid var(--neon-blue);
    color: var(--neon-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 0 12px var(--neon-blue-glow);
}

.brand-area h1 {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.6px;
}

.brand-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    cursor: pointer;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.84rem;
    padding: 9px 15px;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.2s ease;
}

.btn-neon-blue {
    background: rgba(0, 210, 255, 0.16);
    border: 1px solid var(--neon-blue);
    color: #ffffff;
    box-shadow: 0 0 14px var(--neon-blue-glow);
}

.btn-neon-blue:hover {
    background: var(--neon-blue);
    color: #05070b;
}

.btn-neon-red {
    background: rgba(255, 42, 85, 0.18);
    border: 1px solid var(--neon-red);
    color: #ffffff;
    box-shadow: 0 0 14px var(--neon-red-glow);
}

.btn-neon-red:hover {
    background: var(--neon-red);
    color: #ffffff;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--neon-blue);
    color: var(--neon-blue);
}

/* ==========================================================================
   3. CONTENEDOR PRINCIPAL, KPIs Y FILTROS
   ========================================================================== */
.main-container {
    width: 94%;
    max-width: 1320px;
    margin: 22px auto;
    flex: 1;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-card.kpi-green { border-left: 4px solid var(--status-green); }
.kpi-card.kpi-blue { border-left: 4px solid var(--neon-blue); }
.kpi-card.kpi-red { border-left: 4px solid var(--neon-red); }

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 1.7rem;
    font-weight: 800;
}

.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
    background: var(--bg-panel);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.search-box {
    flex: 1;
    min-width: 240px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 9px 14px;
}

.search-box i { color: var(--neon-blue); }

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 100%;
    outline: none;
    font-size: 0.9rem;
}

.filter-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill {
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 8px 13px;
}

.pill.active, .pill:hover {
    border-color: var(--neon-blue);
    color: #ffffff;
    background: rgba(0, 210, 255, 0.14);
}

.pill-history {
    border-color: rgba(255, 42, 85, 0.5);
    color: #ffd6df;
}

/* ==========================================================================
   4. CUADRÍCULA DE TARJETAS DE ACTIVOS Y ESTADOS VISUALES
   ========================================================================== */
.assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 18px;
}

.asset-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.asset-card:hover {
    transform: translateY(-3px);
    border-color: var(--neon-blue);
}

.asset-card.estado-Disponible { border-top: 4px solid var(--status-green); }
.asset-card.estado-En-Uso { border-top: 4px solid var(--neon-blue); }
.asset-card.estado-Mantenimiento { border-top: 4px solid var(--neon-red); }

.asset-card.card-updated-flash {
    animation: pulseBorder 1.8s ease;
}

@keyframes pulseBorder {
    0% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.85); }
    70% { box-shadow: 0 0 0 14px rgba(0, 210, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0); }
}

.asset-media {
    position: relative;
    width: 100%;
    height: 175px;
    background: #07090d;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.asset-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.asset-no-photo {
    color: var(--text-muted);
    font-size: 2.4rem;
    opacity: 0.45;
}

.qr-badge-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(9, 11, 16, 0.9);
    border: 1px solid var(--neon-blue);
    color: var(--neon-blue);
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 800;
}

.status-pill-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 800;
    color: #ffffff;
}

.status-pill-tag.Disponible { background: var(--status-green); }
.status-pill-tag.En-Uso { background: #0284c7; }
.status-pill-tag.Mantenimiento { background: var(--neon-red); }

.asset-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.asset-category {
    font-size: 0.73rem;
    color: var(--neon-blue);
    text-transform: uppercase;
    font-weight: 700;
}

.asset-title {
    font-size: 1.02rem;
    font-weight: 800;
    color: #ffffff;
}

.asset-meta-list {
    list-style: none;
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 2px;
}

.asset-meta-list strong {
    color: var(--text-main);
}

.asset-actions {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.asset-actions button {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.8rem;
}

.btn-icon-only {
    flex: 0 0 auto !important;
    padding: 8px 11px !important;
}

/* ==========================================================================
   5. MODALES, FORMULARIOS, AUTORIZACIÓN Y ESCÁNER QR MÓVIL
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 11, 0.88);
    backdrop-filter: blur(6px);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--bg-panel);
    border: 1px solid rgba(0, 210, 255, 0.45);
    border-radius: 14px;
    width: 100%;
    max-width: 480px;
    padding: 22px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.85);
}

.modal-box.modal-wide {
    max-width: 740px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.modal-header h3 {
    font-size: 1.05rem;
    color: var(--neon-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    padding: 0 6px;
}

.modal-hint {
    font-size: 0.83rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.qr-reader-box {
    width: 100%;
    min-height: 250px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    border: 1px solid rgba(0, 210, 255, 0.35);
    margin-bottom: 14px;
}

.qr-reader-box video {
    width: 100% !important;
    height: auto !important;
    object-fit: cover;
    border-radius: 10px;
}

.inline-code-form {
    display: flex;
    gap: 8px;
}

.inline-code-form input {
    flex: 1;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-group {
    margin-bottom: 13px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.auth-confirm-box {
    background: rgba(255, 42, 85, 0.08);
    border: 1px solid rgba(255, 42, 85, 0.45);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 14px;
}

.auth-confirm-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    color: #ff6b88;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 10px;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--neon-blue);
}

.help-text {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.asset-summary-banner {
    background: rgba(0, 210, 255, 0.08);
    border: 1px solid rgba(0, 210, 255, 0.35);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
    font-size: 0.85rem;
}

/* Miniatura de fotografía en el modal de movimiento de activo */
.mov-summary-flex {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mov-asset-thumb {
    width: 78px;
    height: 78px;
    min-width: 78px;
    border-radius: 8px;
    overflow: hidden;
    background: #07090d;
    border: 1px solid rgba(0, 210, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mov-asset-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mov-asset-no-photo {
    color: var(--text-muted);
    font-size: 1.6rem;
    opacity: 0.55;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.mov-summary-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.35;
}

.mov-summary-info small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.modal-footer-btns {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-footer-btns button {
    flex: 1;
    justify-content: center;
}

/* ==========================================================================
   6. TARJETA QR IMPRIMIBLE Y BITÁCORA
   ========================================================================== */
.text-center { text-align: center; }

.qr-card-printable {
    background: #ffffff;
    color: #090b10;
    padding: 18px;
    border-radius: 10px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 2px solid #090b10;
}

.qr-canvas-holder {
    padding: 6px;
    background: #ffffff;
}

.qr-code-text {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 1px;
}

.qr-url-hint {
    font-size: 0.68rem;
    color: #4b5563;
    word-break: break-all;
    max-width: 240px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

.history-item {
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--neon-blue);
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 0.83rem;
}

.history-item-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-weight: 700;
}

.app-footer {
    text-align: center;
    padding: 18px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 30px;
}

.app-footer a {
    color: var(--neon-blue);
    text-decoration: none;
    font-weight: 700;
}

/* ==========================================================================
   7. ESTILOS DE IMPRESIÓN LIMPIA PARA ETIQUETAS QR
   ========================================================================== */
.bulk-print-grid {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }
    #bulkPrintArea, #bulkPrintArea * {
        visibility: visible;
    }
    #bulkPrintArea {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        padding: 12px;
        background: #ffffff;
    }
    .print-label-item {
        border: 2px solid #000000;
        border-radius: 8px;
        padding: 12px;
        text-align: center;
        color: #000000;
        page-break-inside: avoid;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}