/* ============================================================
   VentasPY — complementos sobre el tema W3CRM
   (el tema define bootstrap, tarjetas, botones y formularios;
   acá solo van los componentes propios de la app)
   ============================================================ */

:root {
    --cpy-ok: #3ac977;
    --cpy-ok-soft: #e3f9ed;
    --cpy-danger: #ff5e5e;
    --cpy-danger-soft: #ffefef;
    --cpy-warning-soft: #fff7e6;
    --cpy-border: #e6e6e6;
    --cpy-muted: #888888;
}

h1:focus {
    outline: none;
}

/* ---------- Encabezado de página ---------- */

.page-header {
    margin-bottom: 1.5rem;
}

    .page-header h1 {
        font-size: 1.4rem;
        font-weight: 600;
        margin-bottom: 0.2rem;
    }

    .page-header .subtitulo {
        color: var(--cpy-muted);
        font-size: 0.9rem;
        margin: 0;
    }

/* ---------- Tabla dentro de tarjeta ---------- */

.tabla-card {
    border: 1px solid var(--cpy-border);
    border-radius: 0.625rem;
    background: #fff;
    max-width: 100%;
    overflow-x: scroll;
}

    .tabla-card .table {
        margin-bottom: 0;
        min-width: 900px;
    }

    .tabla-card td {
        white-space: nowrap;
    }

    .tabla-card::-webkit-scrollbar {
        height: 10px;
    }

    .tabla-card::-webkit-scrollbar-track {
        background: #f2f2f2;
    }

    .tabla-card::-webkit-scrollbar-thumb {
        background: #b3b3b3;
        border-radius: 6px;
    }

.table thead th {
    white-space: nowrap;
}

/* ---------- Badges propios ---------- */

.badge-suave {
    background: var(--rgba-primary-1, #eef2ff);
    color: var(--primary, #4f46e5);
}

.badge-ok {
    background: var(--cpy-ok-soft);
    color: #1a9c56;
}

.badge-neutro {
    background: #f0f0f0;
    color: var(--cpy-muted);
}

/* ---------- Estados vacíos / carga ---------- */

.estado-vacio {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--cpy-muted);
}

    .estado-vacio .bi {
        font-size: 2.4rem;
        display: block;
        margin-bottom: 0.75rem;
        color: #cfcfcf;
    }

.cargando-centro {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--cpy-muted);
    padding: 2rem 0;
    justify-content: center;
}

/* ---------- Métricas / dashboard ---------- */

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--cpy-border);
    border-radius: 0.625rem;
}

.stat-icono {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--rgba-primary-1, #eef2ff);
    color: var(--primary, #4f46e5);
    flex-shrink: 0;
}

    .stat-icono.verde {
        background: var(--cpy-ok-soft);
        color: #1a9c56;
    }

    .stat-icono.ambar {
        background: var(--cpy-warning-soft);
        color: #b45309;
    }

.stat-valor {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    color: #312a2a;
}

.stat-etiqueta {
    font-size: 0.78rem;
    color: var(--cpy-muted);
    font-weight: 500;
}

.uso-licencia {
    min-width: 130px;
}

    .uso-licencia .progress {
        height: 6px;
        border-radius: 4px;
        background: #f0f0f0;
    }

    .uso-licencia .texto {
        font-size: 0.75rem;
        color: var(--cpy-muted);
        margin-top: 0.2rem;
    }

/* ---------- Números contables ---------- */

.num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.fila-total td {
    font-weight: 700;
    border-top: 2px solid var(--cpy-border);
    background: #fafafa;
}

/* ---------- Campos requeridos ---------- */

.form-label.requerido::after,
label.requerido::after {
    content: " *";
    color: var(--cpy-danger);
}

/* ---------- Plan de cuentas (árbol) ---------- */

.arbol-cuentas .nodo-cuenta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    border-left: 2px solid transparent;
}

    .arbol-cuentas .nodo-cuenta:hover {
        background: var(--rgba-primary-1, #f5f6ff);
        border-left-color: var(--primary, #4f46e5);
    }

.arbol-cuentas .nodo-acciones {
    opacity: 0;
    transition: opacity 0.12s ease;
}

.arbol-cuentas .nodo-cuenta:hover .nodo-acciones {
    opacity: 1;
}

.arbol-cuentas .nodo-inactivo {
    opacity: 0.55;
}

.arbol-cuentas .codigo-cuenta {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--primary, #4f46e5);
    background: var(--rgba-primary-1, #eef2ff);
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    white-space: nowrap;
}

/* ---------- Modal propio ---------- */

.modal-cpy-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(49, 42, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1040;
    animation: cpy-fade 0.15s ease;
}

.modal-cpy {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 520px);
    max-height: 88vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 0.875rem;
    box-shadow: 0 8px 30px rgba(49, 42, 42, 0.18);
    z-index: 1050;
    animation: cpy-subir 0.18s ease;
}

.modal-cpy-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--cpy-border);
}

.modal-cpy-titulo {
    font-weight: 600;
    font-size: 1.02rem;
}

.modal-cpy-body {
    padding: 1.25rem;
}

@keyframes cpy-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cpy-subir {
    from { opacity: 0; transform: translate(-50%, -47%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ---------- Productos: miniaturas e imagen ---------- */

.producto-miniatura {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--cpy-border);
    flex-shrink: 0;
}

    .producto-miniatura.vacia {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #f5f5f5;
        color: #c4c4c4;
    }

.producto-imagen-preview {
    width: 96px;
    height: 96px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--cpy-border);
    flex-shrink: 0;
}

    .producto-imagen-preview.vacia {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #f5f5f5;
        color: #c4c4c4;
    }

    .producto-imagen-preview.grande {
        width: 160px;
        height: 160px;
    }

/* ---------- Configuración de facturación: vista previa preimpreso ---------- */

.hoja-preview {
    position: relative;
    background: repeating-linear-gradient(#fff, #fff 19px, #fafafa 19px, #fafafa 20px);
    border: 1px solid var(--cpy-border);
    box-shadow: 0 4px 14px rgba(49, 42, 42, 0.10);
    margin: 0 auto;
    flex-shrink: 0;
}

.hoja-preview-scroll {
    max-height: 460px;
    overflow: auto;
}

.campo-preview {
    position: absolute;
    font-size: 10px;
    line-height: 1;
    background: var(--rgba-primary-1, #eef2ff);
    color: var(--primary, #4f46e5);
    border: 1px dashed var(--primary, #4f46e5);
    border-radius: 3px;
    padding: 1px 3px;
    white-space: nowrap;
}

    .campo-preview.item {
        background: var(--cpy-ok-soft);
        color: #1a9c56;
        border-color: #1a9c56;
    }

    .campo-preview.copia {
        background: #f3f3f3;
        color: #9a9a9a;
        border-color: #c9c9c9;
    }

/* ---------- Cobro: total destacado ---------- */

.cobro-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary, #4f46e5) 0%, #7c3aed 55%, #9333ea 100%);
    border-radius: 0.875rem;
    color: #fff;
    text-align: center;
    padding: 1.15rem 1rem 1.3rem;
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.25);
}

    .cobro-hero::before,
    .cobro-hero::after {
        content: "";
        position: absolute;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.08);
    }

    .cobro-hero::before {
        width: 170px;
        height: 170px;
        left: -60px;
        bottom: -90px;
    }

    .cobro-hero::after {
        width: 140px;
        height: 140px;
        right: -50px;
        top: -60px;
    }

.cobro-hero-etiqueta {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    opacity: 0.85;
}

.cobro-hero-monto {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

    .cobro-hero-monto .gs {
        font-size: 1.1rem;
        font-weight: 600;
        opacity: 0.85;
    }

.cobro-hero-detalle {
    font-size: 0.8rem;
    opacity: 0.85;
}

/* ---------- Cobro: tiles de formas de pago ---------- */

.fp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 0.6rem;
}

.fp-tile {
    --fp: var(--primary, #4f46e5);
    --fp-soft: #eef2ff;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.8rem 0.4rem 0.7rem;
    background: #fff;
    border: 1.5px solid var(--cpy-border);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

    .fp-tile:hover {
        border-color: var(--fp);
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(49, 42, 42, 0.10);
    }

    .fp-tile .fp-icono {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        background: var(--fp-soft);
        color: var(--fp);
        transition: background 0.15s ease, color 0.15s ease;
    }

    .fp-tile .fp-nombre {
        font-size: 0.78rem;
        font-weight: 600;
        color: #312a2a;
        white-space: nowrap;
    }

    .fp-tile .fp-monto {
        font-size: 0.74rem;
        font-weight: 700;
        color: var(--fp);
        font-variant-numeric: tabular-nums;
    }

    .fp-tile .fp-check {
        position: absolute;
        top: -7px;
        right: -7px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        background: var(--fp);
        color: #fff;
        font-size: 0.7rem;
        display: none;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }

    .fp-tile.activo {
        border-color: var(--fp);
        background: var(--fp-soft);
    }

        .fp-tile.activo .fp-icono {
            background: var(--fp);
            color: #fff;
        }

        .fp-tile.activo .fp-check {
            display: inline-flex;
            animation: fp-pop 0.18s ease;
        }

/* Colores por forma de pago (tiles y filas) */
.fp-efectivo { --fp: #1a9c56; --fp-soft: #e3f9ed; }
.fp-debito { --fp: #2563eb; --fp-soft: #e7efff; }
.fp-credito { --fp: #7c3aed; --fp-soft: #f1e9ff; }
.fp-transferencia { --fp: #0d9488; --fp-soft: #e0f5f2; }
.fp-qr { --fp: #d97706; --fp-soft: #fff3e0; }
.fp-cheque { --fp: #64748b; --fp-soft: #eef2f6; }

/* ---------- Cobro: filas de pagos cargados ---------- */

.fp-fila {
    --fp: var(--primary, #4f46e5);
    --fp-soft: #eef2ff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
    background: #fff;
    border: 1px solid var(--cpy-border);
    border-left: 4px solid var(--fp);
    border-radius: 0.6rem;
    animation: cpy-fade 0.15s ease;
}

.fp-fila-icono {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--fp-soft);
    color: var(--fp);
    flex-shrink: 0;
}

.fp-fila-nombre {
    font-size: 0.82rem;
    font-weight: 600;
    min-width: 92px;
}

.fp-fila-monto {
    max-width: 190px;
}

/* ---------- Cobro: barra de progreso y estado ---------- */

.cobro-barra {
    height: 8px;
    border-radius: 6px;
    background: #f0f0f0;
    overflow: hidden;
}

.cobro-barra-relleno {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--cpy-ok), #22c55e);
    transition: width 0.25s ease;
}

    .cobro-barra-relleno.excedido {
        background: linear-gradient(90deg, #0284c7, #38bdf8);
    }

.cobro-estado {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.25rem 0.7rem;
    border-radius: 2rem;
    white-space: nowrap;
}

    .cobro-estado.falta {
        background: var(--cpy-danger-soft);
        color: #c0392b;
    }

    .cobro-estado.vuelto {
        background: #e0f2fe;
        color: #0369a1;
        animation: fp-pop 0.2s ease;
    }

    .cobro-estado.exacto {
        background: var(--cpy-ok-soft);
        color: #1a9c56;
        animation: fp-pop 0.2s ease;
    }

@keyframes fp-pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ---------- Ajustes al tema (deznav con NavLink de Blazor) ---------- */

.deznav .metismenu > li > a.active {
    background: var(--rgba-primary-1, rgba(136, 108, 192, 0.1));
    color: var(--primary, #4f46e5);
    border-radius: 0.625rem;
}

    .deznav .metismenu > li > a.active .menu-icon i {
        color: var(--primary, #4f46e5);
    }

.deznav .metismenu .menu-icon i.bi {
    font-size: 1.15rem;
    line-height: 1;
}

/* El dropdown del perfil se maneja desde Blazor con .mostrar-cpy */
.header-profile2 .dropdown-menu.mostrar-cpy {
    display: block;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1060;
}

/* Avatar con inicial (header) */
.avatar-inicial {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--rgba-primary-1, #eef2ff);
    color: var(--primary, #4f46e5);
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

    .avatar-inicial.grande {
        width: 46px;
        height: 46px;
        font-size: 1.1rem;
    }

.header-profile2 .header-info h6 {
    margin-bottom: 0;
    font-size: 0.85rem;
}

.header-profile2 .header-info p {
    margin-bottom: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cpy-muted);
}

/* Marca en el nav-header */
.brand-cpy {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}

.brand-cpy-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary, #4f46e5);
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.brand-cpy-texto {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

    .brand-cpy-texto .py {
        color: var(--cpy-ok);
    }

/* En sidebar colapsado se oculta el texto de la marca */
[data-sidebar-style="full"] #main-wrapper.menu-toggle .brand-cpy-texto {
    display: none;
}

/* ---------- Login (pantalla dividida del template) ---------- */

.login-marca {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

    .login-marca .brand-cpy-logo {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }

    .login-marca .titulo {
        font-size: 1.5rem;
        font-weight: 700;
        color: #312a2a;
        margin: 0;
    }

        .login-marca .titulo .py {
            color: var(--primary, #4f46e5);
        }

/* ---------- Validación de Blazor ---------- */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--cpy-ok);
}

.invalid {
    outline: 1px solid var(--cpy-danger);
}

.validation-message {
    color: var(--cpy-danger);
}

/* ---------- Error UI de Blazor ---------- */

#blazor-error-ui {
    background: var(--cpy-warning-soft);
    color: #92400e;
    bottom: 0;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.12);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: var(--cpy-danger-soft);
    border-radius: 10px;
    padding: 1rem;
    color: #991b1b;
}

    .blazor-error-boundary::after {
        content: "Ocurrió un error.";
    }

/* ---------- Pantalla de carga inicial ---------- */

.app-loading {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #2c2c2c;
}

.app-loading-brand {
    margin-top: 1.25rem;
    color: #e2e8f0;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
}

.loading-progress {
    position: relative;
    display: block;
    width: 7rem;
    height: 7rem;
}

    .loading-progress circle {
        fill: none;
        stroke: rgba(255, 255, 255, 0.15);
        stroke-width: 0.5rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--cpy-ok);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    color: #e2e8f0;
    inset: calc(50vh - 0.6rem) 0 auto 0;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Cargando");
    }
