:root {
    --color-bg: #f1f2f5;
    --color-surface: #ffffff;
    --color-surface-alt: #f7f8fa;
    --color-border: #e2e4ea;
    --color-text: #1a1d24;
    --color-text-muted: #667085;

    --color-primary: #2f5fdb;
    --color-primary-dark: #24469f;
    --color-primary-light: #6b8fe8;
    --color-primary-soft: #e8edfb;
    /* Canales sueltos (sin rgb()/rgba() alrededor) para poder armar
       sombras/resplandores con transparencia a partir del color de acento
       -- rgba(var(--color-primary-rgb), 0.4) los sustituye tal cual. */
    --color-primary-rgb: 47, 95, 219;

    --color-accent: #0f766e;
    --color-accent-soft: #e6f4f2;

    --color-warm: #b45309;
    --color-warm-soft: #fdf1e2;

    --color-danger: #c0362c;
    --color-danger-soft: #fbeae9;

    --color-success: #15803d;
    --color-success-soft: #e7f5eb;

    --gradient-brand: linear-gradient(165deg, #1c2340 0%, #141833 45%, #0a0d1f 100%);
    --gradient-header: linear-gradient(120deg, #2f5fdb, #24469f);

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;

    --shadow-soft: 0 6px 20px rgba(20, 24, 34, 0.08);
    --shadow-pop: 0 20px 50px rgba(15, 18, 26, 0.22);
    --shadow-sidebar: 2px 0 24px rgba(6, 8, 18, 0.4);

    --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-brand: "Sora", var(--font-sans);
    --font-wordmark: "Space Grotesk", var(--font-brand);
}

/* ---------- Modo oscuro ----------
 * Tres estados: sin tocar nada = sigue la preferencia del sistema
 * operativo (bloque de @media de aca abajo); data-theme="dark"/"light" =
 * el usuario lo eligio a mano (boton en el pie del sidebar) y gana pase lo
 * que pase en el sistema. --color-primary/-dark y los degradados NO se
 * repiten aca a proposito: el azul por defecto (o el color personalizado
 * de cada cuenta, ver applyThemeColor() en index.php) ya se lee bien
 * sobre fondo oscuro tal cual esta. Solo cambian los neutros (fondo,
 * superficies, texto) y los tonos "soft" (son tintes pensados para fondo
 * claro -- sobre un fondo oscuro se invierten a oscuros tambien, sea el
 * azul por defecto o el color elegido).
 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #14161c;
        --color-surface: #1c1f27;
        --color-surface-alt: #21242e;
        --color-border: #2d313c;
        --color-text: #e7e9ee;
        --color-text-muted: #9096a8;

        --color-primary-light: #7c98de;
        --color-primary-soft: #232f4e;
        --gradient-brand: linear-gradient(165deg, #121621 0%, #0d1016 45%, #060709 100%);

        --color-accent-soft: #12332f;
        --color-warm-soft: #3a2812;
        --color-danger-soft: #3a1f1c;
        --color-success-soft: #163828;

        --color-icon-muted: #6b7186;
        --color-teal-text: #4fd8c4;
        --color-teal-chip-hover: #163a35;

        --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.4);
        --shadow-pop: 0 20px 50px rgba(0, 0, 0, 0.55);
        --shadow-sidebar: 2px 0 24px rgba(0, 0, 0, 0.55);
    }
}

:root[data-theme="dark"] {
    --color-bg: #14161c;
    --color-surface: #1c1f27;
    --color-surface-alt: #21242e;
    --color-border: #2d313c;
    --color-text: #e7e9ee;
    --color-text-muted: #9096a8;

    --color-primary-light: #7c98de;
    --color-primary-soft: #232f4e;
    --gradient-brand: linear-gradient(165deg, #121621 0%, #0d1016 45%, #060709 100%);

    --color-accent-soft: #12332f;
    --color-warm-soft: #3a2812;
    --color-danger-soft: #3a1f1c;
    --color-success-soft: #163828;

    --color-icon-muted: #6b7186;
    --color-teal-text: #4fd8c4;
    --color-teal-chip-hover: #163a35;

    --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 20px 50px rgba(0, 0, 0, 0.55);
    --shadow-sidebar: 2px 0 24px rgba(0, 0, 0, 0.55);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

[hidden] {
    display: none !important;
}

button {
    font-family: inherit;
}

svg {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

::selection {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: #d6d9ec;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #c1c5e3;
    background-clip: content-box;
}

/* ---------- Loading (barra global + spinners) ---------- */

#global-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 300;
    overflow: hidden;
    background: rgba(47, 95, 219, 0.12);
    pointer-events: none;
}

#global-progress::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    display: inline-block;
    vertical-align: middle;
    animation: spinner-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.spinner-dark {
    border-color: rgba(26, 29, 36, 0.14);
    border-top-color: var(--color-primary);
}

@keyframes spinner-spin {
    to { transform: rotate(360deg); }
}

.loading-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 16px;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 600;
}

/* ---------- Cortina de arranque (tapa el parpadeo de color/imagen por
   defecto mientras la sesion ya autenticada carga lo personalizado) ---------- */

.boot-curtain {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    /* Fijo a proposito (no var(--gradient-brand)): esa variable es
       justamente la que applyThemeColor() reescribe -- si la cortina la
       usara, cambiaria de color mientras sigue puesta, tapando un
       parpadeo con otro. Se repite aca el valor por defecto de :root. */
    background: linear-gradient(165deg, #1c2340 0%, #141833 45%, #0a0d1f 100%);
    opacity: 1;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.boot-message {
    max-width: 280px;
    margin: 0;
    padding: 0 20px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.boot-message.is-visible {
    opacity: 1;
}

.boot-curtain.is-hiding {
    opacity: 0;
    transform: translateY(30px);
    pointer-events: none;
}

.boot-gears {
    position: relative;
    width: 92px;
    height: 82px;
}

.boot-gear {
    position: absolute;
    color: #fff;
}

.boot-gear-1 {
    top: 0;
    left: 0;
    opacity: 0.95;
    animation: boot-gear-spin 3s linear infinite;
}

.boot-gear-2 {
    right: 0;
    bottom: 0;
    color: rgba(255, 255, 255, 0.55);
    animation: boot-gear-spin-reverse 2.1s linear infinite;
}

@keyframes boot-gear-spin {
    to { transform: rotate(360deg); }
}

@keyframes boot-gear-spin-reverse {
    to { transform: rotate(-360deg); }
}

.btn.is-loading {
    color: transparent !important;
    pointer-events: none;
    position: relative;
}

.btn.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: spinner-spin 0.7s linear infinite;
}

/* ---------- Auth screens ---------- */

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background: var(--gradient-brand);
}

.auth-screen::before,
.auth-screen::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(0px);
    pointer-events: none;
}

.auth-screen::before {
    width: 520px;
    height: 520px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.06), transparent 70%);
    top: -180px;
    left: -140px;
}

.auth-screen::after {
    width: 460px;
    height: 460px;
    background: radial-gradient(circle, rgba(47, 95, 219, 0.18), transparent 70%);
    bottom: -160px;
    right: -120px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    padding: 44px 38px;
    position: relative;
    z-index: 1;
}

.auth-brand {
    text-align: center;
    margin-bottom: 30px;
}

.auth-brand h1 {
    font-family: var(--font-wordmark);
    font-weight: 700;
    font-size: 26px;
    margin: 16px 0 4px;
    letter-spacing: -0.01em;
    /* Relleno con degradado en vez de un color plano -- el mismo azul de
       la marca, pero con algo mas de textura que un texto de un solo tono. */
    background: var(--gradient-header);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.auth-brand p {
    color: var(--color-text-muted);
    margin: 0;
    font-size: 14px;
}

.auth-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: var(--gradient-header);
    color: #fff;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 0.5px;
    /* Halo ancho y difuso (sin offset) ademas de la sombra direccional --
       le da ese aire de resplandor "tech" en vez de una sombra plana, y
       sigue al color de acento elegido en vez de quedar fijo en azul. */
    box-shadow:
        0 0 32px 2px rgba(var(--color-primary-rgb), 0.4),
        0 10px 24px rgba(var(--color-primary-rgb), 0.35);
    overflow: hidden;
}

/* Cuando la cuenta ya subio una imagen para mostrar, ocupa toda la marca
   en vez del icono -- esto es propio de esta app, no depende de que el
   proveedor de correo externo (Gmail, Outlook, etc.) la haya aprobado. */
.auth-brand-mark.has-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Icono animado de sobre que reemplaza el viejo "GS" en texto plano --
   solo aparece mientras la cuenta no tenga una imagen propia configurada
   (has-avatar-img lo saca del DOM al reemplazarlo por la foto real). */
.brand-mark-icon {
    width: 58%;
    height: 58%;
}

.brand-mark-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ffb020;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.sidebar-brand .brand-mark-dot {
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
}

@media (prefers-reduced-motion: no-preference) {
    .brand-mark-icon {
        animation: brand-mark-float 3.2s ease-in-out infinite;
    }

    .brand-mark-dot {
        animation: brand-mark-pulse 2.4s ease-in-out infinite;
    }
}

@keyframes brand-mark-float {
    0%, 100% { transform: translateY(0) rotate(-6deg); }
    50% { transform: translateY(-3px) rotate(6deg); }
}

@keyframes brand-mark-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.5; }
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 17px;
}

/* Accesos desde el login hacia afuera de la app (landing/registro) -- el
   de "quiero una cuenta" un poco visible (boton), el de "mas informacion"
   bien discreto (solo texto), para no competir con el login en si. */
.auth-signup-cta {
    margin-top: 22px;
}

.auth-more-info {
    margin: 14px 0 0;
    text-align: center;
    font-size: 13px;
}

.auth-more-info a {
    color: var(--color-text-muted);
}

.auth-more-info a:hover {
    color: var(--color-primary);
}

/* ---------- Login dividido (solo webmail, vista de inicio de sesion) ---------- */

.auth-split-screen {
    min-height: 100vh;
    display: flex;
    background: var(--color-surface);
}

.auth-visual {
    position: relative;
    flex: 1.15;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    background: var(--gradient-brand);
}

.auth-visual-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center bottom;
}

.auth-visual-copy {
    position: relative;
    z-index: 1;
    padding: 56px 56px 68px;
    color: #fff;
}

.auth-visual-copy h2 {
    font-family: var(--font-brand);
    font-weight: 600;
    font-size: 30px;
    line-height: 1.28;
    margin: 0 0 12px;
    max-width: 420px;
    letter-spacing: -0.01em;
}

.auth-visual-copy p {
    margin: 0;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.72);
    max-width: 380px;
}


.auth-form-pane {
    flex: 1;
    min-width: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-form-pane .auth-card {
    box-shadow: none;
    background: transparent;
    padding: 8px 6px;
}

@media (max-width: 960px) {
    .auth-visual {
        display: none;
    }

    .auth-form-pane {
        min-width: 0;
        width: 100%;
    }
}

/* ---------- Boton flotante de soporte (WhatsApp) ---------- */

.whatsapp-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 200;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 18px 12px 14px;
    background: #25d366;
    color: #fff;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 10px 26px rgba(37, 211, 102, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.whatsapp-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(37, 211, 102, 0.5);
}

.whatsapp-fab svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .whatsapp-fab span {
        display: none;
    }

    .whatsapp-fab {
        padding: 12px;
    }
}

/* ---------- Sidebar (compartido entre webmail y admin) ---------- */

.sidebar {
    background: var(--gradient-brand);
    color: #fff;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sidebar);
    position: relative;
    z-index: 2;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 16px;
    padding: 2px 4px 8px;
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

.sidebar-session {
    text-align: center;
    padding: 4px 6px 14px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand .auth-brand-mark {
    width: 38px;
    height: 38px;
    font-size: 13px;
    border-radius: 14px;
    background: var(--gradient-header);
    box-shadow:
        0 0 20px 1px rgba(var(--color-primary-rgb), 0.5),
        0 6px 18px rgba(var(--color-primary-rgb), 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    flex-shrink: 0;
}

.sidebar-brand-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-wordmark);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    margin-top: 10px;
    flex-shrink: 0;
}

/* Solo iconos aca -- con las tres opciones (Modo, Configuracion, Salir)
   el texto de cada una ya no entraba junto sin romper el ancho del menu. */
.sidebar-footer .btn-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 8px;
}

.sidebar-footer .btn-link .btn-label {
    display: none;
}

.sidebar-footer .btn-link:hover {
    color: #fff;
    background: rgba(255, 94, 98, 0.35);
}

/* Enlaces del paso 2 del login (reenviar codigo, cambiar correo, etc.) --
   no son acciones destructivas, asi que no usan el hover rojo por defecto
   de .btn-link (pensado para "cerrar sesion"/"eliminar"). */
.auth-step2-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.auth-step2-links .btn-link:hover {
    color: var(--color-primary);
    background: var(--color-primary-soft);
}

.session-email {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Firma al pie del menu -- deliberadamente chica (no le quita espacio de
   verdad a la lista de carpetas de arriba, que sigue absorbiendo el resto
   con flex:1) y separada del resto con el mismo tipo de linea sutil que
   ya separa sidebar-footer de "Nueva carpeta". */
.sidebar-credit {
    display: block;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-credit-line {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    font-weight: 600;
    transition: color 0.15s ease;
}

.sidebar-credit:hover .sidebar-credit-line {
    color: #fff;
}

.sidebar-credit-copy {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.35);
    font-size: 10px;
}

/* ---------- Form fields ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.field-row {
    display: flex;
    gap: 12px;
}

.field-row .field {
    flex: 1;
}

.field-small {
    max-width: 130px;
}

.field-group {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 4px;
}

.field-group h4 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-surface-alt);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
    resize: vertical;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: 0 0 0 4px var(--color-primary-soft);
}

input::placeholder, textarea::placeholder {
    color: #a7abc4;
    font-weight: 400;
}

/* ---------- Buttons ---------- */

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.05s ease, box-shadow 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
    letter-spacing: 0.01em;
}

/* .btn tambien se usa en <a> (enlaces que se ven como boton) -- por
   defecto un <a> es inline y no centra bien su contenido/padding. */
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--gradient-header);
    color: #fff;
    box-shadow: 0 10px 24px rgba(47, 95, 219, 0.32);
}

.btn-primary:hover {
    filter: brightness(1.06);
    box-shadow: 0 12px 28px rgba(47, 95, 219, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
    box-shadow: none;
}

.btn-block {
    width: 100%;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    box-shadow: 0 10px 24px rgba(192, 54, 44, 0.32);
}

.btn-danger:hover {
    filter: brightness(1.08);
    box-shadow: 0 12px 28px rgba(192, 54, 44, 0.4);
}

.btn-secondary {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    border: 1.5px solid var(--color-primary-light);
}

.btn-secondary:hover {
    background: var(--color-primary-light);
    color: #fff;
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-link:hover {
    color: var(--color-danger);
    background: var(--color-danger-soft);
}

.btn-icon {
    background: var(--color-surface-alt);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    color: var(--color-text-muted);
    transition: all 0.15s ease;
}

.btn-icon:hover {
    color: var(--color-primary);
    border-color: var(--color-primary-light);
    background: var(--color-primary-soft);
    transform: translateY(-1px);
}

/* Estado activo (ej. OTP encendido en una cuenta) -- el icono/accion no
   cambia, solo se resalta en verde para que se note de un vistazo cuales
   cuentas ya lo tienen activo sin tener que abrir cada una. */
.btn-icon.is-active {
    color: var(--color-success);
    border-color: var(--color-success);
    background: var(--color-success-soft);
}

.btn-icon.is-active:hover {
    color: var(--color-success);
    border-color: var(--color-success);
    background: var(--color-success-soft);
    filter: brightness(0.92);
}

.form-error {
    background: var(--color-danger-soft);
    color: #d13438;
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    border: 1px solid rgba(255, 94, 98, 0.25);
}

.compose-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ---------- Toasts ---------- */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 400;
}

.toast {
    background: var(--color-text);
    color: #fff;
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
    font-size: 13px;
    font-weight: 600;
    max-width: 320px;
    animation: toast-in 0.2s ease;
    border-left: 4px solid var(--color-primary-light);
}

.toast.is-error {
    background: #c0392b;
    border-left-color: #ff8a80;
}

.toast.is-success {
    background: #128a5e;
    border-left-color: #6ee7b7;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cabecera de panel (webmail y admin) ---------- */

.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 22px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.pane-header h2 {
    font-size: 17px;
    margin: 0;
    letter-spacing: -0.01em;
}

.pane-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Data table (admin) ---------- */

.data-table {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th, .data-table td {
    text-align: left;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.data-table th {
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-primary-soft);
}

.data-table th.is-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.data-table th.is-sortable:hover {
    color: var(--color-primary);
}

.data-table th.is-sortable .sort-arrow {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.6;
}

/* ---------- Lista de detalle (modal "Ver detalle") ---------- */

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 18px;
    margin: 0;
}

.detail-list dt {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-list dd {
    margin: 0;
    font-size: 14px;
}

.data-table tbody tr {
    transition: background 0.12s ease;
}

.data-table tbody tr:hover {
    background: var(--color-surface-alt);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .empty-row td {
    text-align: center;
    color: var(--color-text-muted);
    padding: 48px 16px;
    font-weight: 500;
}

/* display:flex DIRECTO en un <td> lo saca del alineado vertical normal de
   la tabla -- vertical-align deja de aplicarle sin importar que se lo
   pongamos (por eso el intento anterior con solo vertical-align no
   arreglaba nada). La celda se queda como <td> comun (hereda el
   vertical-align:middle de arriba) y el flex vive en un <div> de adentro. */
.row-actions-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 11px;
    border-radius: 999px;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pill.pill-accent {
    background: var(--color-accent-soft);
    color: #007a68;
}

.pill.pill-success {
    background: var(--color-success-soft);
    color: var(--color-success);
}

/* ---------- Switch (on/off) ---------- */

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: #cdd1e0;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .switch-slider {
    background: var(--color-success);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(18px);
}

.switch input:disabled + .switch-slider {
    opacity: 0.5;
    cursor: default;
}

/* ---------- Dialogo propio (reemplazo de confirm()/prompt()) ---------- */

.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 13, 26, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
    padding: 24px;
    transition: background 0.15s ease;
}

.confirm-overlay.is-open {
    background: rgba(10, 13, 26, 0.5);
}

.confirm-dialog {
    width: 100%;
    max-width: 380px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    padding: 26px 26px 20px;
    transform: translateY(10px) scale(0.98);
    opacity: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.confirm-overlay.is-open .confirm-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.confirm-message {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    white-space: pre-line;
}

.confirm-input {
    width: 100%;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    margin-bottom: 18px;
    outline: none;
}

.confirm-input:focus {
    border-color: var(--color-primary-light);
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-actions .btn {
    padding: 9px 18px;
}

/* ---------- Modal generico (webmail y admin) ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 13, 26, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 220;
    padding: 24px;
}

.modal-panel {
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 48px);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-panel.is-narrow {
    max-width: 440px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: var(--gradient-brand);
    color: #fff;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-family: var(--font-brand);
    font-weight: 600;
    font-size: 17px;
}

.modal-header .btn-icon {
    background: transparent;
    border-color: transparent;
    color: rgba(255, 255, 255, 0.85);
}

.modal-header .btn-icon:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: transparent;
    color: #fff;
    transform: none;
}

.modal-body {
    padding: 22px 24px 26px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.settings-hint {
    margin: 6px 0 14px;
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.settings-form-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

@media (max-width: 640px) {
    .modal-overlay {
        padding: 0;
    }

    .modal-panel {
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

/* ---------- Footer de las paginas publicas (ver partials/site-footer.php) ----------
 * Fondo oscuro (mismo degradado de marca que ya se usa en el login) para
 * que contraste con el resto de la pagina, que es clara -- antes esto era
 * una sola linea de copyright, se sentia muy chico comparado con el resto.
 */
.site-footer {
    background: var(--gradient-brand);
    color: rgba(255, 255, 255, 0.7);
    padding: 56px 32px 28px;
}

.site-footer-grid {
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.3fr repeat(3, 1fr);
    gap: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.site-footer-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.site-footer-brand-name {
    font-family: var(--font-wordmark);
    font-weight: 700;
    font-size: 17px;
    color: #fff;
}

.site-footer-brand p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.5);
    max-width: 26ch;
}

.site-footer-col {
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-width: 0;
}

.site-footer-col h4 {
    margin: 0 0 4px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.4);
}

.site-footer-col a {
    color: rgba(255, 255, 255, 0.75);
    font-size: 13.5px;
    text-decoration: none;
}

.site-footer-col a:hover {
    color: #fff;
}

.site-footer-bottom {
    max-width: 1180px;
    margin: 0 auto;
    padding-top: 20px;
    text-align: center;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.5);
}

.site-footer-bottom p {
    margin: 0;
}

.site-footer-bottom a {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 700;
}

@media (max-width: 780px) {
    .site-footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .site-footer-brand {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .site-footer-grid {
        grid-template-columns: 1fr;
    }
}
