/**
 * Utilidades propias de JR Civil Suite.
 *
 * Reemplazan a los atributos style="" y bloques <style> inline de las
 * vistas: la CSP no permite 'unsafe-inline' en style-src (ver
 * docs/decisions/0005). Ningún archivo de vista debe volver a usar
 * style="" ni <style>; si hace falta un ajuste visual, va aquí.
 */

/* --- Listados de administración --- */
.jrcs-search-box {
    max-width: 320px;
}

.jrcs-col-index {
    width: 4rem;
}

/* --- Formularios --- */
.jrcs-hex-input {
    max-width: 110px;
}

/* --- Login --- */
.jrcs-auth-card {
    max-width: 420px;
    width: 100%;
}

/* --- Matriz de permisos (company-admin/roles/_permissions-matrix.php) --- */
@keyframes jrcsFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.jrcs-fade-in {
    animation: jrcsFadeIn .18s ease-out;
}

/* Línea separadora entre grupos de módulo, solo cuando ambos lados
   están visibles — evita un separador huérfano antes del primer grupo
   realmente mostrado. */
.js-role-module-group:not(.d-none) + .js-role-module-group:not(.d-none) {
    border-top: 1px solid var(--bs-border-color);
    margin-top: 1rem;
    padding-top: 1rem;
}

/* --- Markup del demo DashQ (partials/modals-drawers.php, rightbar.php) --- */
.theme-swatch[data-theme="theme-purple"] { background: #7c3aed; }
.theme-swatch[data-theme="theme-indigo"] { background: #4f46e5; }
.theme-swatch[data-theme="theme-sky"] { background: #378aff; }
.theme-swatch[data-theme="theme-emerald"] { background: #4dcf7d; }
.theme-swatch[data-theme="theme-rose"] { background: #f43f5e; }
.theme-swatch[data-theme="theme-orange"] { background: #fa8738; }
.theme-swatch[data-theme="theme-slate"] { background: #475569; }
.theme-swatch[data-theme="theme-mocha"] { background: #7b4a2e; }
.theme-swatch[data-theme="theme-mustard"] { background: #ca8a04; }

.font-pill[data-font="inter"] { font-family: 'Inter', system-ui; }
.font-pill[data-font="dm"] { font-family: 'DM Sans', system-ui; }
.font-pill[data-font="poppins"] { font-family: 'Poppins', system-ui; }
.font-pill[data-font="space"] { font-family: 'Space Grotesk', system-ui; }

.jrcs-fs-xxs {
    font-size: .7rem;
}

.jrcs-avatar-34 {
    width: 34px;
    height: 34px;
}

/* ------------------------------------------------------------------
   Navegación por módulos — launcher (/modules) con el estilo de
   blank-page.html del template: card mini + miniatura que imita una
   captura de la app (rail de íconos, barra superior, contenido) con el
   ícono del módulo al centro. Sin imágenes: todo CSS.
   ------------------------------------------------------------------ */
.jrcs-module-preview {
    display: flex;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bs-body-bg);
    transition: transform .2s ease, box-shadow .2s ease;
}

.jrcs-mp-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7%;
    width: 11%;
    padding-top: 6%;
}

.jrcs-mp-rail span {
    width: 42%;
    aspect-ratio: 1;
    border-radius: 30%;
    background: var(--bs-secondary-bg);
}

.jrcs-mp-rail span:first-child {
    background: var(--bs-primary);
}

.jrcs-mp-main {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.jrcs-mp-top {
    display: flex;
    align-items: center;
    gap: 5%;
    height: 14%;
    padding: 0 6%;
}

.jrcs-mp-top span {
    width: 12%;
    height: 22%;
    border-radius: 1rem;
    background: var(--bs-secondary-bg);
}

.jrcs-mp-top span:first-child {
    width: 18%;
    background: rgba(var(--bs-primary-rgb), .35);
}

.jrcs-mp-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    margin: 0 5% 5% 0;
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: .6rem;
    background: linear-gradient(160deg, rgba(var(--bs-primary-rgb), .10), var(--bs-tertiary-bg) 70%);
}

.jrcs-mp-icon {
    display: grid;
    place-items: center;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 1rem;
    background: var(--bs-primary);
    color: var(--bs-white);
    font-size: 1.6rem;
    box-shadow: 0 .4rem 1rem rgba(var(--bs-primary-rgb), .35);
}

.jrcs-mp-line {
    height: .3rem;
    border-radius: 1rem;
    background: var(--bs-secondary-bg);
}

.jrcs-mp-line.long { width: 45%; }
.jrcs-mp-line.short { width: 28%; }

.jrcs-module-card .card-footer .jrcs-module-go {
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
}

.jrcs-module-card:hover .jrcs-module-preview {
    transform: translateY(-3px);
    box-shadow: 0 .6rem 1.4rem rgba(var(--bs-primary-rgb), .18);
}

.jrcs-module-card:hover .card-footer .jrcs-module-go {
    opacity: 1;
    transform: translateX(2px);
}

.jrcs-module-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.5em;
}

/* Coming soon: miniatura apagada, sin hover. */
.jrcs-module-card.is-soon .jrcs-module-preview {
    filter: grayscale(1);
    opacity: .55;
}

.jrcs-module-card.is-soon:hover .jrcs-module-preview {
    transform: none;
    box-shadow: none;
}

/* Selector de módulos del header: rejilla de 3 columnas con mosaicos. */
.jrcs-module-switcher {
    width: min(92vw, 360px);
}

.jrcs-switcher-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    height: 100%;
    padding: .7rem .25rem;
    border-radius: 1rem;
    text-align: center;
    font-size: .78rem;
    line-height: 1.2;
    color: var(--bs-body-color);
    text-decoration: none;
}

.jrcs-switcher-icon {
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: .85rem;
    background: rgba(var(--bs-primary-rgb), .12);
    color: var(--bs-primary);
    font-size: 1.25rem;
}

a.jrcs-switcher-item:hover,
.jrcs-switcher-item.active {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.jrcs-switcher-item.active .jrcs-switcher-icon {
    background: var(--bs-primary);
    color: var(--bs-white);
}

.jrcs-switcher-item.disabled {
    cursor: default;
}

.jrcs-switcher-item.disabled .jrcs-switcher-icon {
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
}

.jrcs-switcher-soon {
    font-size: .62rem;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* Selector de proyecto: la tarjeta completa es el botón del POST. */
.jrcs-project-card {
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.jrcs-project-card:hover,
.jrcs-project-card:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(var(--bs-primary-rgb), .5);
    box-shadow: 0 .5rem 1.2rem rgba(var(--bs-primary-rgb), .15);
}

.jrcs-project-card.is-current {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 .15rem rgba(var(--bs-primary-rgb), .2);
}

/* Chip del proyecto activo en el header. */
.jrcs-project-chip {
    max-width: 260px;
}

/* Logos de compañía: vista previa en formularios y marca en sidebar/header. */
.jrcs-logo-preview {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bs-tertiary-bg);
}

.jrcs-logo-preview img,
.jrcs-company-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.jrcs-logo-preview-main {
    width: 160px;
    height: 64px;
}

.jrcs-logo-preview-small {
    width: 64px;
    height: 64px;
}

.jrcs-company-logo-sm {
    width: 32px;
    height: 32px;
}

.jrcs-company-logo-md {
    width: 44px;
    height: 44px;
}

/* Icon-bar (sidebar): íconos centrados y en el gris del sistema, como los
   SVG del template (stroke var(--bs-secondary)); primario al pasar el
   mouse o en la opción activa. En mobile (offcanvas) van alineados a la
   izquierda junto a su etiqueta. */
aside .jrcs-sidebar-link {
    display: flex;
    align-items: center;
    color: var(--bs-secondary);
}

aside .jrcs-sidebar-link > .bi {
    line-height: 1;
}

aside .jrcs-sidebar-link:hover,
aside .jrcs-sidebar-link:focus-visible,
aside .jrcs-sidebar-link.active {
    color: var(--bs-primary);
}

[data-bs-theme="dark"] aside .jrcs-sidebar-link:not(:hover):not(.active) {
    color: var(--bs-gray-300);
}

@media (min-width: 992px) {
    aside .jrcs-sidebar-link {
        justify-content: center;
    }
}

/* Tamaño de los íconos del icon-bar: equivalente visual a los SVG de
   26px y trazo fino del template/Site Intel. */
aside .jrcs-sidebar-link > .bi {
    font-size: 1.25rem;
}

/* Desktop: todos los botones del icon-bar con el mismo tamaño fijo y
   centrados sobre el eje del logo (si el ancho depende del ícono, cada
   botón queda en una posición distinta). */
@media (min-width: 992px) {
    aside .jrcs-sidebar-link {
        width: 3rem !important;
        height: 2.75rem;
        padding: 0 !important;
        margin-left: auto;
        margin-right: auto;
    }

    aside .offcanvas-body > ul > li:not(.w-100) {
        display: flex;
        justify-content: center;
        width: 100%;
    }
}

/* El resaltado del template (layout-main.css: aside li a::after) se
   posiciona con left:16px pensando en el padding original; con los
   botones de tamaño fijo se centra sobre el ícono. */
@media (min-width: 992px) {
    aside .jrcs-sidebar-link::after {
        left: 50% !important;
        top: 50% !important;
        width: 40px !important;
        height: 40px !important;
        transform: translate(-50%, -50%);
    }
}

/* Import de reconciliación: guía de pasos + zonas de carga. */
.jrcs-steps li {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    color: var(--bs-secondary-color);
}

.jrcs-steps li span {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--bs-secondary-bg);
    font-weight: 600;
    font-size: .8rem;
}

.jrcs-steps li.is-current {
    color: var(--bs-body-color);
    font-weight: 600;
}

.jrcs-steps li.is-current span {
    background: var(--bs-primary);
    color: var(--bs-white);
}

.jrcs-dropzone {
    --jrcs-tone: var(--bs-primary-rgb);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    height: 100%;
    padding: 1.5rem 1.25rem;
    border: 2px dashed var(--bs-border-color);
    border-radius: 1rem;
    background: var(--bs-tertiary-bg);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.jrcs-dropzone:hover,
.jrcs-dropzone:focus-within {
    border-color: rgba(var(--jrcs-tone), .6);
    background: rgba(var(--jrcs-tone), .04);
}

.jrcs-dropzone.tone-success { --jrcs-tone: var(--bs-success-rgb); }
.jrcs-dropzone.tone-danger { --jrcs-tone: var(--bs-danger-rgb); }

.jrcs-dropzone-icon {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: rgba(var(--jrcs-tone), .12);
    color: rgb(var(--jrcs-tone));
    font-size: 1.6rem;
}

.jrcs-dropzone .form-control {
    max-width: 100%;
}

.jrcs-dropzone-hint {
    font-size: .72rem;
    color: var(--bs-secondary-color);
}

.jrcs-steps li.is-done span {
    background: rgba(var(--bs-success-rgb), .15);
    color: var(--bs-success);
}
