/* =========================================================
   Paletas Gurabo - Autenticacion
   Pantallas de login, perfil y estados de sesion.
   Depende de los tokens definidos en ps-expressive.css
   ========================================================= */

/* Los tokens viven en :root porque los componentes .auth-* tambien se
   usan dentro del layout de la aplicacion (perfil, usuarios), donde el
   body no lleva la clase .auth-page. */
:root {
    --auth-panel-bg: #FFFFFF;
    --auth-ink: #0A0F1F;
    --auth-ink-soft: rgba(10, 15, 31, 0.62);
    --auth-ink-faint: rgba(10, 15, 31, 0.42);
    --auth-line: rgba(10, 15, 31, 0.10);
    --auth-field-bg: #FFFFFF;
    --auth-field-line: rgba(10, 15, 31, 0.14);
}

.auth-page {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--ps-font-body);
    color: var(--auth-ink);
    background: var(--auth-panel-bg);
    -webkit-font-smoothing: antialiased;
}

.auth-layout {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---------------------------------------------------------
   Panel de marca (columna izquierda)
   --------------------------------------------------------- */
.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(2rem, 4vw, 3.5rem);
    background: var(--ps-gradient-dark);
    color: #fff;
    overflow: hidden;
    isolation: isolate;
}

/* Halo de color, estatico y de bajo costo */
.auth-brand::before {
    content: '';
    position: absolute;
    inset: -30%;
    z-index: -2;
    background:
        radial-gradient(circle at 22% 18%, rgba(0, 92, 255, 0.42) 0%, transparent 46%),
        radial-gradient(circle at 78% 72%, rgba(0, 212, 255, 0.28) 0%, transparent 44%),
        radial-gradient(circle at 48% 96%, rgba(122, 77, 255, 0.26) 0%, transparent 42%);
    animation: authDrift 24s ease-in-out infinite alternate;
}

/* Retícula sutil para dar textura sin ruido visual */
.auth-brand::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(circle at 40% 40%, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(circle at 40% 40%, #000 0%, transparent 78%);
}

@keyframes authDrift {
    from { transform: translate3d(-2%, -1%, 0) scale(1); }
    to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

.auth-brand-mark {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    position: relative;
}

.auth-brand-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: var(--ps-radius-md);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    font-size: 1.5rem;
    color: #fff;
}

.auth-brand-name {
    font-family: var(--ps-font-display);
    font-weight: 800;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.auth-brand-tag {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.62);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-brand-body {
    position: relative;
    max-width: 30rem;
    padding: 3rem 0;
}

/* El color se declara de forma explicita: la regla global de
   encabezados de ps-expressive.css los pinta oscuros. */
.auth-brand-headline {
    font-family: var(--ps-font-display);
    font-weight: 800;
    font-size: clamp(2rem, 3.4vw, 2.875rem);
    line-height: 1.1;
    letter-spacing: -0.025em;
    color: #fff;
    margin: 0 0 1rem;
}

.auth-brand-headline em {
    font-style: normal;
    background: linear-gradient(100deg, var(--ps-aqua), var(--ps-lime));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-brand-lead {
    font-size: 1rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.72);
    margin: 0 0 2.5rem;
}

.auth-brand-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1rem;
}

.auth-brand-points li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9375rem;
    color: rgba(255, 255, 255, 0.86);
}

.auth-brand-points i {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: var(--ps-radius-sm);
    background: rgba(0, 212, 255, 0.14);
    border: 1px solid rgba(0, 212, 255, 0.28);
    color: var(--ps-aqua);
    font-size: 0.875rem;
}

.auth-brand-foot {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    align-items: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.48);
}

.auth-brand-foot a {
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
}

.auth-brand-foot a:hover {
    color: #fff;
    text-decoration: underline;
}

/* ---------------------------------------------------------
   Panel del formulario (columna derecha)
   --------------------------------------------------------- */
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 3rem);
    background: var(--auth-panel-bg);
}

.auth-form-wrap {
    width: 100%;
    max-width: 25rem;
    animation: authRise 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes authRise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

/* Marca compacta, solo visible cuando el panel lateral se oculta */
.auth-mobile-mark {
    display: none;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.auth-mobile-mark .auth-brand-logo {
    background: var(--ps-gradient-blue-aqua);
    border: none;
    box-shadow: var(--ps-shadow-glow-blue);
}

.auth-mobile-mark .auth-brand-name { color: var(--auth-ink); }
.auth-mobile-mark .auth-brand-tag { color: var(--auth-ink-faint); }

.auth-title {
    font-family: var(--ps-font-display);
    font-weight: 800;
    font-size: 1.75rem;
    letter-spacing: -0.02em;
    color: var(--auth-ink);
    margin: 0 0 0.375rem;
}

.auth-subtitle {
    font-size: 0.9375rem;
    color: var(--auth-ink-soft);
    margin: 0 0 2rem;
}

/* ---------------------------------------------------------
   Avisos
   --------------------------------------------------------- */
.auth-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
    border-radius: var(--ps-radius-md);
    border: 1px solid transparent;
    font-size: 0.875rem;
    line-height: 1.5;
    animation: authShakeIn 320ms ease both;
}

.auth-notice i {
    flex-shrink: 0;
    font-size: 1.125rem;
    margin-top: 0.05em;
}

.auth-notice-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.24);
    color: #911C1C;
}
.auth-notice-danger i { color: var(--ps-danger); }

.auth-notice-warning {
    background: rgba(245, 158, 11, 0.10);
    border-color: rgba(245, 158, 11, 0.26);
    color: #8A5206;
}
.auth-notice-warning i { color: var(--ps-warning); }

.auth-notice-info {
    background: rgba(0, 92, 255, 0.06);
    border-color: rgba(0, 92, 255, 0.18);
    color: #0B3E9E;
}
.auth-notice-info i { color: var(--ps-blue); }

.auth-notice-success {
    background: rgba(16, 185, 129, 0.09);
    border-color: rgba(16, 185, 129, 0.24);
    color: #0A6B4E;
}
.auth-notice-success i { color: var(--ps-success); }

@keyframes authShakeIn {
    0%   { opacity: 0; transform: translateY(-6px); }
    60%  { opacity: 1; transform: translateX(3px); }
    80%  { transform: translateX(-2px); }
    100% { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------
   Campos
   --------------------------------------------------------- */
.auth-field {
    margin-bottom: 1.125rem;
}

.auth-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--auth-ink);
    margin-bottom: 0.4375rem;
}

.auth-input-shell {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 0.875rem;
    display: grid;
    place-items: center;
    font-size: 1.0625rem;
    color: var(--auth-ink-faint);
    pointer-events: none;
    transition: color var(--ps-transition-fast);
}

.auth-input {
    width: 100%;
    height: 3rem;
    padding: 0 0.875rem 0 2.875rem;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--auth-ink);
    background: var(--auth-field-bg);
    border: 1.5px solid var(--auth-field-line);
    border-radius: var(--ps-radius-md);
    transition: border-color var(--ps-transition-fast),
                box-shadow var(--ps-transition-fast),
                background var(--ps-transition-fast);
}

.auth-input::placeholder {
    color: rgba(10, 15, 31, 0.34);
}

.auth-input:hover:not(:focus) {
    border-color: rgba(10, 15, 31, 0.24);
}

.auth-input:focus {
    outline: none;
    border-color: var(--ps-blue);
    box-shadow: 0 0 0 4px rgba(0, 92, 255, 0.12);
}

.auth-input-shell:focus-within .auth-input-icon {
    color: var(--ps-blue);
}

.auth-input[aria-invalid="true"] {
    border-color: var(--ps-danger);
}

.auth-input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.14);
}

.auth-input:disabled {
    background: rgba(10, 15, 31, 0.04);
    color: var(--auth-ink-faint);
    cursor: not-allowed;
}

/* Reserva espacio para el boton de mostrar/ocultar */
.auth-input-shell--action .auth-input {
    padding-right: 3rem;
}

.auth-input-action {
    position: absolute;
    right: 0.375rem;
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    background: none;
    border: none;
    border-radius: var(--ps-radius-sm);
    color: var(--auth-ink-faint);
    font-size: 1.0625rem;
    cursor: pointer;
    transition: color var(--ps-transition-fast), background var(--ps-transition-fast);
}

.auth-input-action:hover {
    color: var(--ps-blue);
    background: rgba(0, 92, 255, 0.07);
}

.auth-input-action:focus-visible {
    outline: 2px solid var(--ps-blue);
    outline-offset: 1px;
}

.auth-field-error {
    display: none;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--ps-danger);
    margin-top: 0.4375rem;
}

.auth-field-error.is-visible {
    display: flex;
}

/* Aviso de Bloq Mayus */
.auth-capslock {
    display: none;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #8A5206;
    background: rgba(245, 158, 11, 0.12);
    border-radius: var(--ps-radius-sm);
    padding: 0.375rem 0.5rem;
    margin-top: 0.4375rem;
}

.auth-capslock.is-visible {
    display: inline-flex;
}

/* ---------------------------------------------------------
   Fila de opciones
   --------------------------------------------------------- */
.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.25rem 0 1.5rem;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--auth-ink-soft);
    cursor: pointer;
    user-select: none;
}

.auth-check input {
    appearance: none;
    -webkit-appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
    border: 1.5px solid var(--auth-field-line);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all var(--ps-transition-fast);
}

.auth-check input::after {
    content: '';
    width: 0.5rem;
    height: 0.28rem;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) scale(0);
    transition: transform var(--ps-transition-fast);
    margin-top: -2px;
}

.auth-check input:checked {
    background: var(--ps-blue);
    border-color: var(--ps-blue);
}

.auth-check input:checked::after {
    transform: rotate(-45deg) scale(1);
}

.auth-check input:focus-visible {
    outline: 2px solid var(--ps-blue);
    outline-offset: 2px;
}

.auth-link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ps-blue);
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-link:focus-visible {
    outline: 2px solid var(--ps-blue);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---------------------------------------------------------
   Boton principal
   --------------------------------------------------------- */
.auth-submit {
    position: relative;
    width: 100%;
    height: 3.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    background: var(--ps-gradient-blue-aqua);
    border: none;
    border-radius: var(--ps-radius-md);
    box-shadow: 0 6px 18px rgba(0, 92, 255, 0.28);
    cursor: pointer;
    overflow: hidden;
    transition: transform var(--ps-transition-fast),
                box-shadow var(--ps-transition-fast),
                opacity var(--ps-transition-fast);
}

.auth-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(0, 92, 255, 0.36);
}

.auth-submit:active:not(:disabled) {
    transform: translateY(0);
}

.auth-submit:focus-visible {
    outline: 2px solid var(--ps-dark);
    outline-offset: 2px;
}

.auth-submit:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    box-shadow: none;
}

.auth-submit .auth-submit-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin 640ms linear infinite;
}

.auth-submit.is-loading .auth-submit-label,
.auth-submit.is-loading .auth-submit-icon {
    display: none;
}

.auth-submit.is-loading .auth-submit-spinner {
    display: block;
}

@keyframes authSpin {
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------
   Pie del formulario
   --------------------------------------------------------- */
.auth-foot {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--auth-line);
    text-align: center;
    font-size: 0.75rem;
    color: var(--auth-ink-faint);
    line-height: 1.7;
}

.auth-foot a {
    color: var(--auth-ink-soft);
    font-weight: 600;
    text-decoration: none;
}

.auth-foot a:hover {
    color: var(--ps-blue);
    text-decoration: underline;
}

/* ---------------------------------------------------------
   Dialogo de ayuda
   --------------------------------------------------------- */
.auth-dialog {
    width: min(26rem, calc(100vw - 2rem));
    padding: 0;
    border: none;
    border-radius: var(--ps-radius-lg);
    box-shadow: var(--ps-shadow-lg);
    color: var(--auth-ink);
}

.auth-dialog::backdrop {
    background: rgba(10, 15, 31, 0.55);
    backdrop-filter: blur(3px);
}

.auth-dialog-body {
    padding: 1.75rem;
}

.auth-dialog h2 {
    font-family: var(--ps-font-display);
    font-size: 1.125rem;
    font-weight: 800;
    margin: 0 0 0.625rem;
}

.auth-dialog p {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--auth-ink-soft);
    margin: 0 0 1.25rem;
}

.auth-dialog-close {
    width: 100%;
    height: 2.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--auth-ink);
    background: var(--ps-gray);
    border: none;
    border-radius: var(--ps-radius-md);
    cursor: pointer;
    transition: background var(--ps-transition-fast);
}

.auth-dialog-close:hover {
    background: rgba(10, 15, 31, 0.10);
}

/* ---------------------------------------------------------
   Encabezado de las paginas de cuenta (dentro del layout)
   --------------------------------------------------------- */
.auth-page-header {
    margin-bottom: var(--ps-space-lg);
}

.auth-page-header h1 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-family: var(--ps-font-display);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    color: var(--ps-dark);
    margin: 0 0 0.25rem;
}

.auth-page-header h1 i {
    color: var(--ps-blue);
}

.auth-page-header p {
    font-size: 0.875rem;
    color: rgba(10, 15, 31, 0.55);
    margin: 0;
}

/* ---------------------------------------------------------
   Medidor de fortaleza (perfil / reset)
   --------------------------------------------------------- */
.auth-meter {
    margin-top: 0.625rem;
}

.auth-meter-track {
    display: flex;
    gap: 4px;
}

.auth-meter-track span {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(10, 15, 31, 0.10);
    transition: background var(--ps-transition-normal);
}

.auth-meter-label {
    display: block;
    font-size: 0.75rem;
    color: var(--auth-ink-faint);
    margin-top: 0.375rem;
}

.auth-meter[data-level="1"] .auth-meter-track span:nth-child(-n+1),
.auth-meter[data-level="2"] .auth-meter-track span:nth-child(-n+2) {
    background: var(--ps-danger);
}

.auth-meter[data-level="3"] .auth-meter-track span:nth-child(-n+3) {
    background: var(--ps-warning);
}

.auth-meter[data-level="4"] .auth-meter-track span:nth-child(-n+4),
.auth-meter[data-level="5"] .auth-meter-track span {
    background: var(--ps-success);
}

.auth-meter[data-level="1"] .auth-meter-label,
.auth-meter[data-level="2"] .auth-meter-label { color: var(--ps-danger); }
.auth-meter[data-level="3"] .auth-meter-label { color: #8A5206; }
.auth-meter[data-level="4"] .auth-meter-label,
.auth-meter[data-level="5"] .auth-meter-label { color: #0A6B4E; }

/* ---------------------------------------------------------
   Adaptable
   --------------------------------------------------------- */
@media (max-width: 992px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        display: none;
    }

    .auth-mobile-mark {
        display: flex;
    }

    .auth-page {
        background: linear-gradient(180deg, #F7F9FC 0%, #FFFFFF 42%);
    }

    .auth-panel {
        min-height: 100vh;
        min-height: 100dvh;
        align-items: flex-start;
        padding-top: clamp(2.5rem, 9vh, 5rem);
        background: transparent;
    }
}

@media (max-width: 480px) {
    .auth-title { font-size: 1.5rem; }
    .auth-subtitle { margin-bottom: 1.5rem; }

    .auth-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-brand::before,
    .auth-form-wrap,
    .auth-notice,
    .auth-submit-spinner {
        animation: none !important;
    }

    .auth-submit:hover:not(:disabled) {
        transform: none;
    }
}

/* Respeta el modo de alto contraste del sistema */
@media (forced-colors: active) {
    .auth-input,
    .auth-submit,
    .auth-check input {
        border: 1px solid ButtonBorder;
    }
}

/* ---------------------------------------------------------
   Selector de permisos por usuario
   --------------------------------------------------------- */
.perm-picker {
    --perm-radius: 14px;
    margin-bottom: 0.5rem;
}

/* ---- Barra de resumen ---- */
.perm-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding: 0.875rem 1rem;
    background: linear-gradient(180deg, #FFFFFF 0%, #FAFBFD 100%);
    border: 1px solid var(--auth-line);
    border-radius: var(--perm-radius);
    margin-bottom: 0.875rem;
}

.perm-bar-meter {
    flex: 1 1 15rem;
    min-width: 12rem;
}

.perm-bar-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(10, 15, 31, 0.08);
    overflow: hidden;
}

.perm-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--ps-gradient-blue-aqua);
    transition: width var(--ps-transition-normal);
}

.perm-bar-text {
    font-size: 0.8125rem;
    color: var(--auth-ink-soft);
    margin-top: 0.45rem;
}

.perm-bar-text strong {
    font-family: var(--ps-font-display);
    font-size: 1rem;
    font-weight: 800;
    color: var(--auth-ink);
}

.perm-bar-text span {
    color: var(--auth-ink-faint);
}

.perm-bar-presets {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.perm-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ps-blue);
    background: rgba(0, 92, 255, 0.06);
    border: 1px solid rgba(0, 92, 255, 0.18);
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--ps-transition-fast);
    white-space: nowrap;
}

.perm-chip:hover {
    background: rgba(0, 92, 255, 0.12);
    border-color: rgba(0, 92, 255, 0.35);
}

.perm-chip:focus-visible {
    outline: 2px solid var(--ps-blue);
    outline-offset: 2px;
}

.perm-chip-muted {
    color: var(--auth-ink-soft);
    background: rgba(10, 15, 31, 0.04);
    border-color: rgba(10, 15, 31, 0.12);
}

.perm-chip-muted:hover {
    background: rgba(10, 15, 31, 0.08);
    border-color: rgba(10, 15, 31, 0.2);
}

/* ---- Tarjetas de modulo ---- */
.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
    gap: 0.75rem;
    align-items: start;
}

.perm-card {
    border: 1px solid var(--auth-line);
    border-radius: var(--perm-radius);
    background: #fff;
    overflow: hidden;
    transition: border-color var(--ps-transition-fast),
                box-shadow var(--ps-transition-fast);
}

.perm-card:hover {
    border-color: rgba(10, 15, 31, 0.18);
}

.perm-card.is-on {
    border-color: color-mix(in srgb, var(--mod-color) 45%, transparent);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--mod-color) 18%, transparent);
}

.perm-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--auth-line);
    background: rgba(10, 15, 31, 0.015);
}

.perm-card.is-on .perm-card-head {
    background: color-mix(in srgb, var(--mod-color) 7%, #fff);
}

.perm-card-icon {
    width: 1.625rem;
    height: 1.625rem;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 7px;
    font-size: 0.8125rem;
    color: var(--mod-color);
    background: color-mix(in srgb, var(--mod-color) 12%, transparent);
}

.perm-card-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--auth-ink);
    letter-spacing: -0.01em;
}

.perm-card-tally {
    margin-left: auto;
    font-family: var(--ps-font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--auth-ink-faint);
}

.perm-card.is-on .perm-card-tally {
    color: var(--mod-color);
}

/* ---- Interruptor del modulo ---- */
.perm-switch {
    display: inline-flex;
    align-items: center;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.perm-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.perm-switch-track {
    position: relative;
    display: block;
    width: 30px;
    height: 17px;
    border-radius: 999px;
    background: rgba(10, 15, 31, 0.16);
    transition: background var(--ps-transition-fast);
}

.perm-switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(10, 15, 31, 0.3);
    transition: transform var(--ps-transition-fast);
}

.perm-switch input:checked + .perm-switch-track {
    background: var(--mod-color);
}

.perm-switch input:checked + .perm-switch-track .perm-switch-knob {
    transform: translateX(13px);
}

.perm-switch input:focus-visible + .perm-switch-track {
    outline: 2px solid var(--ps-blue);
    outline-offset: 2px;
}

/* ---- Acciones ---- */
.perm-card-body {
    padding: 0.5rem;
    display: grid;
    gap: 0.25rem;
}

.perm-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--auth-ink-soft);
    cursor: pointer;
    user-select: none;
    transition: background var(--ps-transition-fast), color var(--ps-transition-fast);
}

.perm-action:hover {
    background: rgba(10, 15, 31, 0.035);
}

.perm-action > i {
    font-size: 0.75rem;
    color: var(--auth-ink-faint);
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.perm-action input {
    appearance: none;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    margin: 0;
    border: 1.5px solid var(--auth-field-line);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all var(--ps-transition-fast);
}

.perm-action input::after {
    content: "";
    width: 0.42rem;
    height: 0.22rem;
    margin-top: -2px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) scale(0);
    transition: transform var(--ps-transition-fast);
}

.perm-action input:checked {
    background: var(--mod-color);
    border-color: var(--mod-color);
}

.perm-action input:checked::after {
    transform: rotate(-45deg) scale(1);
}

.perm-action input:focus-visible {
    outline: 2px solid var(--ps-blue);
    outline-offset: 2px;
}

.perm-action input:checked ~ span {
    color: var(--auth-ink);
    font-weight: 600;
}

.perm-action input:checked ~ i {
    color: var(--mod-color);
}

/* "Ver" abre el modulo: se separa del resto */
.perm-action.is-gate {
    border-bottom: 1px dashed var(--auth-line);
    padding-bottom: 0.5rem;
    margin-bottom: 0.15rem;
}

.perm-card.is-locked .perm-action:not(.is-gate) {
    opacity: 0.45;
}

/* ---- Nota al pie ---- */
.perm-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.875rem 0 0;
    padding: 0.7rem 0.85rem;
    border-radius: var(--ps-radius-md);
    background: rgba(0, 92, 255, 0.045);
    border: 1px solid rgba(0, 92, 255, 0.14);
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--auth-ink-soft);
}

.perm-note i {
    color: var(--ps-blue);
    font-size: 0.875rem;
    margin-top: 0.08em;
    flex-shrink: 0;
}

.perm-note strong { color: var(--auth-ink); }

/* ---- Lista en modo lectura (detalle del usuario) ---- */
.perm-readonly {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.perm-readonly-group {
    border: 1px solid var(--auth-line);
    border-radius: var(--ps-radius-md);
    padding: 0.7rem 0.85rem;
}

.perm-readonly-group h4 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--auth-ink-faint);
    margin: 0 0 0.5rem;
}

.perm-readonly-group ul { list-style: none; margin: 0; padding: 0; }

.perm-readonly-group li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    padding: 0.15rem 0;
    color: var(--auth-ink-soft);
}

.perm-readonly-group li i { color: var(--ps-success); font-size: 0.75rem; }

@media (max-width: 576px) {
    .perm-grid { grid-template-columns: 1fr; }
    .perm-bar { flex-direction: column; align-items: stretch; }
    .perm-bar-presets { justify-content: stretch; }
    .perm-chip { flex: 1; justify-content: center; }
}

/* Encabezado de la seccion de permisos (compartido por crear/editar) */
.perm-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ps-blue);
    margin: 1.75rem 0 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(0, 92, 255, 0.14);
}

.perm-section-title i { font-size: 0.9375rem; }

.perm-section-hint {
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--auth-ink-soft);
    margin: 0 0 1rem;
}
