/* ============================================================
   FactererE — 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-icono.rojo {
        background: var(--cpy-danger-soft, #fee2e2);
        color: #b91c1c;
    }

.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);
}

/* ---------- 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%); }
}

/* ---------- 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");
    }
