:root {
    /* Colores, tipografías y UI kit del diseño «Wiki en casa»: tokens.css y wiki.css. */
    --wk-brand: var(--azul);
    --wk-sidebar-w: 272px;
}

body {
    min-height: 100vh;
}

/* ---- Login ---- */
.wk-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--papel);
    padding: 1.5rem;
}

.wk-login__card {
    width: 100%;
    max-width: 440px;
    border: var(--borde);
    border-radius: var(--r-xl);
    box-shadow: var(--sombra-m);
}

.wk-login__logo {
    height: 46px;
    width: auto;
}

/* «Error 404» sobre el título de las páginas de error: la etiqueta en mono, con el acento cálido. */
.wk-error__codigo {
    font: 700 .78rem/1 var(--f-mono);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #B4532A;
}

[data-bs-theme="dark"] .wk-error__codigo {
    color: var(--teja);
}

.wk-login__pie {
    font: 600 .78rem/1.4 var(--f-mono);
    color: var(--tinta-suave);
    text-align: center;
}

/* ---- Admin layout ---- */
.wk-sidebar {
    width: var(--wk-sidebar-w);
    height: 100vh;
    /* On phones 100vh is the screen with the browser bars hidden, so the last links
       sat under the bottom bar and the menu thought it fitted: no scroll.
       dvh is the visible height (fallback above for older browsers). */
    height: 100dvh;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 1030;
    background: var(--papel-claro);
    border-right: 1.5px solid color-mix(in srgb, var(--gris) 45%, transparent);
}

.wk-sidebar__marca {
    min-height: 68px;
    border-bottom: 1.5px solid color-mix(in srgb, var(--gris) 45%, transparent);
}

.wk-sidebar__marca img {
    height: 36px;
    width: auto;
}

/* Room under "Cerrar sesión", the last link, so it never sits flush against
   Safari's bottom bar or the iPhone home indicator. */
.wk-sidebar > nav {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
}

.wk-sidebar .nav-link {
    border-radius: 999px;
    padding: .5rem .85rem;
    margin-bottom: .15rem;
    color: var(--tinta);
    font-weight: 700;
}

.wk-sidebar .nav-link .bi {
    color: var(--azul-texto);
}

/* La sección en la que estás, en tinta, como el chip marcado de la web. */
.wk-sidebar .nav-link.active,
.wk-sidebar .nav-link.active .bi {
    background-color: var(--tinta);
    color: var(--papel);
}

@media (hover: hover) {
    .wk-sidebar .nav-link:not(.active):hover {
        background-color: var(--cielo);
        color: var(--tinta);
    }
}

/* «Cerrar sesión», en rojo también su icono. */
.wk-sidebar .nav-link.text-danger .bi {
    color: inherit;
}

/* Animated chevron on collapsible sidebar entries */
.wk-collapse-arrow {
    transition: transform .2s ease;
}

.wk-sidebar .nav-link.collapsed .wk-collapse-arrow {
    transform: rotate(-90deg);
}

.wk-sidebar__heading {
    font: 700 .7rem/1 var(--f-mono);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--tinta-suave);
    padding: 1rem .85rem .4rem;
    margin: 0;
}

.wk-main {
    margin-left: var(--wk-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.wk-content {
    flex: 1;
    padding: 1.5rem;
}

.wk-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: 68px;
    background: color-mix(in srgb, var(--papel) 92%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1.5px solid color-mix(in srgb, var(--gris) 45%, transparent);
}

.wk-topbar .navbar-brand {
    font: 700 1.35rem/1.1 var(--f-titulo);
    color: var(--tinta);
    min-width: 0;
}

/* Phones: menu button, title, theme switch, "Nuevo usuario" and the avatar share 390 px; with less padding, a
   smaller title and no caret on the avatar, the title fits instead of becoming "Mis con…". */
@media (max-width: 575.98px) {
    .wk-topbar {
        min-height: 60px;
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }

    .wk-topbar .navbar-brand {
        font-size: 1.12rem;
        margin-right: .5rem;
    }

    .wk-topbar .ms-auto {
        gap: .25rem !important;
    }

    .wk-topbar .dropdown-toggle {
        padding-left: .25rem;
        padding-right: .25rem;
    }

    .wk-topbar .dropdown-toggle::after {
        display: none;
    }

    .wk-topbar .tema {
        padding: 4px;
    }
}

.wk-pie {
    font: 600 .78rem/1.4 var(--f-mono);
    color: var(--tinta-suave);
    border-top: 1.5px solid color-mix(in srgb, var(--gris) 45%, transparent);
}

/* «Panel v3» en el pie, en segundo plano: más pequeño, sin negrita y más claro (4,5:1 sobre el papel). */
.wk-pie__version {
    font-size: .68rem;
    font-weight: 400;
    color: #666F76;
}

[data-bs-theme="dark"] .wk-pie__version {
    color: #8E9BA5;
}

/* Enlace a Realwigo en el pie: del mismo gris que el texto, subrayado suave. */
.wk-pie a,
.wk-login__pie a {
    color: inherit;
    text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
    text-underline-offset: 2px;
}

.wk-pie a:hover,
.wk-login__pie a:hover {
    color: var(--tinta);
    text-decoration-color: currentColor;
}

/* Dark overlay shown behind the off-canvas sidebar on mobile */
.wk-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 33, 43, .55);
    z-index: 1029;
}

@media (max-width: 991.98px) {
    .wk-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease-in-out;
        border-right: var(--borde);
        box-shadow: var(--sombra-alta);
    }
    .wk-sidebar.show {
        transform: translateX(0);
    }
    .wk-main {
        margin-left: 0;
    }
    .wk-content {
        padding: 1rem;
    }
    .wk-sidebar-backdrop.show {
        display: block;
    }
    body.wk-sidebar-open {
        overflow: hidden;
    }
}

.wk-brand-dot {
    width: 38px;
    height: 38px;
    border-radius: .5rem;
    background: var(--wk-brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.wk-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--azul);
    border: 2px solid var(--linea);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
}

/* ---- Inicio ---- */
/* El saludo a la izquierda y Wiki a la derecha. */
.wk-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 1.5rem;
    padding: 1.75rem 2rem;
    border-radius: var(--r-xl);
    border: var(--borde);
    color: #fff;
    background: var(--pieza-azul);
    box-shadow: var(--sombra-m);
}

.wk-hero__fecha {
    font: 700 .74rem/1.2 var(--f-mono);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #fff;
}

.wk-hero__titulo {
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    line-height: 1.08;
}

.wk-hero__meta {
    font-size: .95rem;
    color: #fff;
}

.wk-stat {
    transition: transform .15s ease, box-shadow .15s ease;
}

@media (hover: hover) {
    .wk-stat:hover {
        transform: translateY(-2px);
        box-shadow: var(--sombra-m);
    }
}

.wk-stat__icono {
    width: 44px;
    height: 44px;
    border-radius: var(--r-s);
    border: 1px solid var(--linea-suave);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.wk-stat__ir {
    transition: color .15s ease;
}

.wk-stat:hover .wk-stat__ir {
    color: var(--wk-brand) !important;
}

.wk-stat__numero {
    font: 700 2.2rem/1.05 var(--f-titulo);
}

.wk-stat__label {
    display: block;
    font-weight: 700;
    color: var(--tinta);
    text-decoration: none;
}

/* Por encima del stretched-link de la tarjeta para que se pueda pulsar */
.wk-stat__extra {
    position: relative;
    z-index: 2;
    display: inline-block;
    margin-top: .35rem;
    font-size: .78rem;
    text-decoration: none;
}

/* Wiki sobre un disco claro (su azul es el del fondo de la franja). */
.wk-hero__wiki {
    position: relative;
    width: 128px;
    height: 128px;
    margin: -.75rem 0;
    border-radius: 50%;
    background: var(--disco-wiki);
}

.wk-hero__wiki .wiki {
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 124px;
    height: auto;
    transform: translateX(-50%);
    overflow: visible;
}

/* Saluda con la mano, parpadea y la bola de la antena late, como en la web pública. */
.wk-hero__wiki .wk-saluda {
    transform-box: view-box;
    transform-origin: 194px 166px;
    animation: wk-saluda 3.4s ease-in-out infinite;
}

.wk-hero__wiki .wk-ojos {
    transform-box: fill-box;
    transform-origin: center;
    animation: wk-parpadeo 6s infinite;
}

.wk-hero__wiki .wk-halo {
    transform-box: fill-box;
    transform-origin: center;
    opacity: 0;
    animation: wk-halo 3.6s ease-out infinite;
}

@keyframes wk-saluda { 0%, 55%, 100% { transform: rotate(0); } 12% { transform: rotate(-16deg); } 24% { transform: rotate(6deg); } 36% { transform: rotate(-12deg); } 46% { transform: rotate(3deg); } }
@keyframes wk-parpadeo { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.12); } }
@keyframes wk-halo { 0% { transform: scale(1); opacity: .55; } 70%, 100% { transform: scale(2.1); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .wk-hero__wiki .wk-saluda,
    .wk-hero__wiki .wk-ojos,
    .wk-hero__wiki .wk-halo {
        animation: none;
    }
}

@media (max-width: 575.98px) {
    .wk-hero {
        padding: 1.25rem;
        column-gap: 1rem;
    }
    .wk-hero__wiki {
        width: 92px;
        height: 92px;
        margin: 0;
    }
    .wk-hero__wiki .wiki {
        width: 90px;
    }
}

/* ---- Personas ---- */
/* Neutral text with a coloured dot, so every colour stays readable in light and dark. */
.wk-persona {
    display: inline-flex;
    align-items: center;
    padding: .15rem .55rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 50rem;
    background: var(--bs-body-bg);
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
}

.wk-persona__dot {
    flex-shrink: 0;
    width: .6rem;
    height: .6rem;
    margin-right: .4rem;
    border-radius: 50%;
    background: var(--wk-persona, var(--bs-secondary));
}

/* "Propia" in the persona dropdown: no colour, just an outline. */
.wk-persona__dot--vacio {
    background: transparent;
    border: 1px solid var(--bs-secondary-color);
}

/* Persona dropdown: the active item keeps its dot visible on the brand background. */
.wk-persona-select .dropdown-item.active .wk-persona__dot {
    box-shadow: 0 0 0 2px #fff;
}

/* Small persona dropdown, inline in a table row ("Importadas"): as wide as its longest name. */
.wk-persona-select--sm {
    display: inline-block;
    min-width: 9rem;
}

/* Icon before each option of an icon dropdown (PIN "Tipo"). */
.wk-select-icono {
    flex-shrink: 0;
    width: 1.25rem;
    margin-right: .4rem;
    color: var(--bs-warning-text-emphasis);
}

.wk-persona-select .dropdown-item.active .wk-select-icono {
    color: inherit;
}

/* "Guardar PIN" legend: a side panel on desktop, a block under the buttons on phones. */
.wk-pin-leyenda {
    padding: 1rem;
    border-radius: var(--bs-border-radius);
    background: var(--bs-tertiary-bg);
}

.wk-pin-leyenda__item {
    display: flex;
    align-items: flex-start;
    gap: .25rem;
    padding: .4rem .5rem;
    border-radius: var(--bs-border-radius-sm);
}

.wk-pin-leyenda__item .wk-select-icono {
    margin-top: .15rem;
}

.wk-pin-leyenda__item.is-active {
    background: var(--bs-warning-bg-subtle);
}

/* "Nuevo" / "Actualizada" on recently changed menu entries: the kit's «Popular» label. */
.wk-nuevo {
    margin-left: auto;
    font: 700 .62rem/1 var(--f-mono);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 4px 7px;
}

.wk-nuevo.text-bg-success {
    background-color: var(--teja) !important;
    color: #14212B !important;
}

.wk-nuevo.text-bg-info {
    background-color: var(--cielo) !important;
    color: var(--tinta) !important;
    box-shadow: inset 0 0 0 1px var(--linea-campo);
}

.wk-personas-filtro .btn {
    display: inline-flex;
    align-items: center;
}

/* ---- DataTables ---- */
/* Our date columns sort by a numeric `data-order` (e.g. Ymd), so DataTables
   auto-detects them as numeric/date and right-aligns the cells while flipping
   the sort arrow to the left of the header. Keep these columns left-aligned
   with the arrow on the right, consistent with every other column. */
table.dataTable thead > tr > th.dt-type-numeric,
table.dataTable thead > tr > th.dt-type-date,
table.dataTable tbody > tr > td.dt-type-numeric,
table.dataTable tbody > tr > td.dt-type-date {
    text-align: left;
}

table.dataTable thead > tr > th.dt-type-numeric div.dt-column-header,
table.dataTable thead > tr > th.dt-type-date div.dt-column-header {
    flex-direction: row;
}
