/* css/ui.css - Modals, Panels, and Shared UI Components */

.sa-chat-mode-selector,
.sa-pill-selector {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 99px;
    padding: 3px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    position: relative;
    z-index: 50;
    margin-left: 20px;
}

.sa-mode-btn,
.sa-pill-btn {
    padding: 6px 16px;
    border-radius: 99px;
    font-size: 0.8rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    font-weight: 500;
}

.sa-mode-btn:hover,
.sa-pill-btn:hover {
    color: #e2e8f0;
}

.sa-mode-btn--active,
.sa-pill-btn.is-active {
    background: var(--gradient-sa);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}

/* Action Buttons Group (Notes/Expand/Close) */
.sa-pill-actions {
    display: inline-flex;
    gap: 8px;
    /* Slight gap for action buttons, or remove for joined pill look */
    margin-left: auto;
    /* Push to right */
}

/* Variant: Joined Pill for Actions (Optional, user asked for "same aesthetic") */
.sa-pill-group {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 99px;
    padding: 3px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.sa-pill-group .sa-btn {
    margin: 0;
    border-radius: 99px;
    /* Keep them round inside */
    background: transparent;
    border: none;
    color: #94a3b8;
    box-shadow: none;
    padding: 6px 14px;
    font-size: 0.8rem;
}

.sa-pill-group .sa-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.sa-pill-group .sa-btn.is-active,
.sa-pill-group .sa-btn-primary {
    background: var(--gradient-sa);
    color: #fff !important;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}

/* --- FLOATING HISTORY PANEL --- */
.sa-history-layer {
    position: absolute;
    top: 70px;
    /* Debajo de los botones del modo */
    right: 0;
    width: 320px;
    height: calc(100% - 100px);
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
    padding: 20px;
    z-index: 100;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 40px;
    /* Aumentado a 40px para separar más el botón de la lista */
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sa-history-header {
    margin-bottom: 25px;
    /* Separación efectiva entre botón New Chat y la lista */
}

.sa-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}

.sa-history-item {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 0.85rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.sa-history-item-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-history-rename-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    /* Gris azulado suave acorde al diseño */
    font-size: 14px;
    cursor: pointer;
    padding: 0 5px;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.sa-history-item:hover .sa-history-rename-btn {
    opacity: 1;
}

.sa-history-rename-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--accent-purple);
    border-radius: 6px;
    padding: 4px 8px;
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
}

.sa-history-rename-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.sa-history-item:hover {
    background: rgba(124, 58, 237, 0.1);
    border-color: rgba(124, 58, 237, 0.3);
    color: #ffffff;
}

.sa-history-item--active {
    border-color: var(--accent-purple);
    background: rgba(124, 58, 237, 0.05);
}

/* --- SHARED UTILS/* Panels */
.sa-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    gap: 16px;
}

.sa-header-content {
    flex: 1;
    /* Takes available space, pushing actions to right */
    min-width: 200px;
}

.sa-header-center {
    flex: 0 0 auto;
    /* Center piece (Filter) */
    display: flex;
    justify-content: center;
    align-items: center;
}

.sa-panel-actions {
    flex: 0 0 auto;
    /* Actions stay compact */
    display: flex;
    align-items: center;
    gap: 12px;
}

.sa-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    /* Separación entre cabecera y contenido del chat */
}

.sa-card-title-group h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #ffffff;
    font-weight: 600;
}

.sa-card-title-group p {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

/* --- SHARED BUTTONS & ICONS --- */
.sa-btn {
    border-radius: 999px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-sizing: border-box;
}

.sa-btn-primary {
    background: var(--gradient-sa);
    color: white !important;
    font-weight: 600;
    padding: 8px 14px;
    box-shadow: var(--shadow-sa);
}

.sa-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

.sa-btn-secondary {
    background: var(--bg-glass);
    color: var(--text-main);
    border: 1px solid var(--border-slate);
    padding: 6px 14px;
}

.sa-btn-icon {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    flex-shrink: 0 !important;
    padding: 8px !important;
    border-radius: 50% !important;
    background: var(--gradient-sa);
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    position: relative;
}

/* CRITICAL: Scaling fix for icons inside buttons */
.sa-btn-icon img {
    width: 100% !important;
    height: 100% !important;
    max-width: 22px !important;
    max-height: 22px !important;
    object-fit: contain !important;
    filter: brightness(0) invert(1);
}

.sa-btn-icon svg {
    width: 20px !important;
    height: 20px !important;
}

/* --- CHAT BUTTONS GROUP (TRIANGLE/GRID LAYOUT) --- */
/* Eliminado el grid genérico para usar el sistema específico de Hub & Chat en chat.css */

#sa-chat-send-btn,
#sa-swipe-send-btn {
    grid-area: send;
    margin: 0 auto;
}

#sa-chat-mic-btn {
    grid-area: mic;
}

#sa-chat-copy-btn,
#sa-swipe-copy-btn {
    grid-area: copy;
}

.sa-chat-buttons-secondary {
    display: contents;
    /* Allows children (mic/copy) to participate in the grid */
}

/* Desktop override removed to respect specific chat.css triangular layout */
@media (min-width: 901px) {
    /* ... existing rules ... */
}

/* Logic moved to chat.css */

/* --- PILLS & BADGES --- */
.sa-pill {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.75rem;
    border: 1px solid var(--border-slate);
    background: rgba(15, 23, 42, 0.7);
    white-space: nowrap;
    color: #ffffff;
}

/* --- MODALS & AUTH (V11 PREMIUM) --- */
.sa-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    /* Opacidad premium */
    backdrop-filter: blur(8px) grayscale(100%);
    /* Efecto polarizado premium */
    z-index: 80000;
    /* SOBRE TODO, INCLUIDO HEADER */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.sa-neon-modal,
.sa-modal-content {
    background: #0f172a;
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 16px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
    text-align: center;
    animation: fadeInModal 0.3s ease-out;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.sa-neon-modal:hover {
    border-color: #a855f7;
    box-shadow: 0 0 35px rgba(168, 85, 247, 0.25);
    /* Resplandor al hacer hover */
}

@keyframes fadeInModal {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.sa-modal-logo {
    display: block;
    margin: 0 auto 15px auto;
    width: 200px !important;
    /* Mismo ancho que Welcome Back */
    height: auto !important;
    object-fit: contain;
}

.sa-modal-content h3 {
    font-size: 1.5rem;
    color: #ffffff;
    margin: 0 0 8px 0;
}

.sa-modal-content p {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* Password Toggle & Input Fixes */
.sa-password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.sa-password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
    width: 32px !important;
    height: 32px !important;
}

.sa-password-toggle:hover {
    opacity: 1;
}

.sa-password-toggle img {
    width: 22px !important;
    height: auto !important;
    /* Corregir deformación */
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.sa-input-group {
    text-align: left;
    margin-bottom: 18px;
    width: 100%;
}

.sa-input-group input {
    width: 100% !important;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px 14px;
    color: #ffffff;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sa-input-group input:focus {
    border-color: #20ead7 !important;
    /* Verde Agua (Aqua) del logo */
    outline: none;
    box-shadow: 0 0 10px rgba(32, 234, 215, 0.2);
}

.sa-modal-actions {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sa-btn-google {
    width: 100%;
    padding: 12px;
    background: transparent !important;
    border: 1px solid #1e293b !important;
    border-radius: 8px;
    color: #cbd5e1 !important;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.sa-btn-google:hover {
    border-color: #20ead7 !important;
    /* Verde Agua */
    background: rgba(32, 234, 215, 0.05) !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(32, 234, 215, 0.1);
}

.sa-google-icon-fix {
    width: 20px !important;
    height: 20px !important;
    margin-right: 12px;
}

.sa-close-modal {
    display: none;
}

.sa-modal-title-main {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 25px;
    margin-top: 10px;
    text-align: center;
}

.sa-modal-x-close {
    display: none;
    /* Oculto en escritorio */
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: color 0.2s;
    z-index: 10;
}

.sa-modal-x-close:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* --- PREMIUM ONBOARDING (WELCOME MODAL) --- */
.premium-onboarding {
    background: #020617 !important;
    /* Fondo ultra oscuro para resaltar el neón */
    position: relative;
    border: 1px solid transparent !important;
    border-radius: 16px !important;

    /* Degradado en el borde: Verde Agua a Lila */
    background-image: linear-gradient(#020617, #020617),
        linear-gradient(135deg, #20ead7 0%, #a855f7 100%) !important;
    background-origin: border-box !important;
    background-clip: padding-box, border-box !important;

    /* Resplandor exterior (Glow) */
    box-shadow: 0 0 30px rgba(32, 234, 215, 0.15),
        0 0 60px rgba(168, 85, 247, 0.1) !important;
}

.sa-gradient-text {
    background: linear-gradient(90deg, #20ead7, #a855f7);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

/* Estilo para los inputs dentro del modal para que no desentonen */
.premium-onboarding .sa-input {
    background: rgba(15, 23, 42, 0.8) !important;
    border: 1px solid rgba(148, 163, 184, 0.1) !important;
    /* Sutil por defecto */
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    color: white !important;
}

.premium-onboarding .sa-input:focus {
    border-color: #20ead7 !important;
    /* Verde Agua de Social Authority */
    outline: none;
    box-shadow: 0 0 10px rgba(32, 234, 215, 0.4) !important;
}

.premium-onboarding .sa-onboard-label {
    display: block !important;
    color: #94a3b8 !important;
    font-size: 0.85rem !important;
    margin-bottom: 8px !important;
    text-align: left !important;
}

/* --- CYBER SCAN EFFECT (ONBOARDING FINISH) --- */
.sa-scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg,
            transparent,
            #20ead7,
            /* Verde Agua Oficial */
            #a855f7,
            /* Lila Neón */
            transparent);
    box-shadow: 0 0 15px #20ead7, 0 0 30px #a855f7;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
}

/* Animación de escaneo */
@keyframes cyberScan {
    0% {
        top: 0%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

.sa-scan-active {
    animation: cyberScan 1.5s ease-in-out forwards;
}

/* Efecto de brillo extra en el modal durante el escaneo */
.premium-onboarding.scanning {
    transition: box-shadow 0.5s ease;
    box-shadow: 0 0 50px rgba(32, 234, 215, 0.4) !important;
    /* Brillo Verde Agua */
}

@media (max-width: 900px) {

    /* Botones de cierre eliminados en móvil como se solicitó */
    .sa-modal-content,
    .sa-neon-modal {
        padding-top: 20px !important;
    }

    /* Reposicionamiento del menú de usuario para que abra hacia abajo en móvil */
    .sa-user-menu {
        bottom: auto !important;
        top: 170px !important;
        z-index: 50001 !important;
        animation: saFadeInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
    }

    /* Centrado del panel Activity (Historial) en móvil */
    .sa-history-layer {
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 92% !important;
        max-width: 400px;
        margin: 0 auto !important;
        animation: saFadeInDown 0.3s ease !important;
    }

    /* Detalle 3: Solo para el modal de Ingreso (Auth) */
    #sa-login-modal.sa-modal-backdrop {
        z-index: 85000 !important;
        /* Prioridad máxima absoluta */
        background: #000000 !important;
        backdrop-filter: none !important;
    }
}

.sa-forgot-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
}

.sa-forgot-wrapper .sa-link-dim {
    font-size: 0.8rem;
    color: #64748b;
    text-decoration: none;
}

.sa-divider-or {
    text-align: center;
    margin: 20px 0;
    position: relative;
    width: 100%;
}

.sa-divider-or::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: #1e293b;
}

.sa-divider-or::after {
    display: none;
}

.sa-divider-or span {
    background: #0f172a;
    /* Fondo del modal login */
    padding: 0 10px;
    color: #64748b;
    font-size: 12px;
    position: relative;
}

/* Background override for premium onboarding */
.premium-onboarding .sa-divider-or span {
    background: #020617 !important;
}

/* --- USER MENU (Popover over Sidebar) --- */
.sa-user-menu {
    position: absolute;
    bottom: 80px;
    /* Ajustado para flotar con holgura */
    left: 10px;
    right: 10px;
    background: #111827;
    /* Más oscuro para contraste */
    border: 1px solid #374151;
    border-radius: 12px;
    overflow: hidden;
    z-index: 1000;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    animation: saFadeInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes saFadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes saFadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sa-menu-item {
    padding: 12px 16px;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #334155;
    text-align: left;
}

.sa-menu-item:hover {
    background: #334155;
}

/* --- UPGRADE MODAL OPTIONS --- */
.sa-upgrade-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sa-plan-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.sa-plan-button:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sa-plan-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Sin espacio entre nombre y precio */
}

.sa-plan-name {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.sa-plan-price-row {
    font-size: 0.85rem;
    color: #94a3b8;
}

/* --- AI ASSISTANT BASE (Isolated) --- */
/* Result Box (Global utility for assistants) */
.sa-result-box {
    background: rgba(15, 17, 26, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 20px;
    color: #e2e8f0;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    margin-bottom: 20px;
    animation: sa-fade-in 0.5s ease forwards;
}

@keyframes sa-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sa-plan-chevron {
    color: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    transition: color 0.2s, transform 0.2s;
}

.sa-plan-button:hover .sa-plan-chevron {
    color: #20ead7;
    /* Aqua green en hover */
    transform: translateX(4px);
}

/* --- USER GUIDE LEGAL SECTION --- */
.sa-legal-transparency {
    margin-top: 25px;
    text-align: center;
}

.sa-legal-transparency h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

.sa-legal-transparency p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.sa-legal-transparency a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.sa-legal-transparency a:hover {
    color: #a78bfa;
    /* Lila neón */
}

.sa-legal-divider {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 40px auto;
    width: 100%;
}

.sa-legal-disclaimer {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.sa-legal-disclaimer p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    line-height: 1.6;
}

.sa-mt-15 {
    margin-top: 15px !important;
}

.sa-copyright {
    margin-top: 15px;
}

.sa-slide-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 60000;
    /* Sobre el header (50000) */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sa-slide-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.sa-slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    background: linear-gradient(180deg, #020617 0%, #0f172a 60%, #153a3e 85%, #20ead7 100%);
    border-left: 1px solid rgba(32, 234, 215, 0.15);
    box-shadow: -15px 0 40px rgba(0, 0, 0, 0.8);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 65000;
    /* Sobre el backdrop del slide */
    display: flex;
    flex-direction: column;
    padding: 35px 24px;
    box-sizing: border-box;
}

.sa-slide-panel.active {
    transform: translateX(0);
}

.sa-account-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 35px 0;
    text-align: left;
}

.sa-account-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
}

.sa-acc-label {
    color: #94a3b8;
    font-size: 0.95rem;
}

.sa-acc-value {
    color: #f1f5f9;
    font-size: 0.95rem;
}

.sa-acc-value-special {
    color: #20ead7;
    /* Aqua Green */
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
}

.sa-margin-large {
    margin-top: 15px;
    margin-bottom: 15px;
}

.sa-margin-medium {
    margin-top: 25px;
    margin-bottom: 5px;
}

.sa-email-wrapper {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    padding: 0;
    border: none;
}

.sa-btn-copy-naked {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.sa-btn-copy-naked:hover {
    opacity: 1;
}

.sa-slide-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 30px;
}

.sa-btn-upgrade {
    background: #22c55e !important;
    /* Verde sólido */
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    padding: 12px !important;
    border: none !important;
    border-radius: 999px !important;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.sa-btn-upgrade:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.sa-btn-unsubscribe {
    background: transparent !important;
    color: #ef4444 !important;
    /* Rojo */
    border: 1px solid #ef4444 !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
    padding: 10px !important;
    border-radius: 999px !important;
    cursor: pointer;
    transition: background 0.2s;
}

.sa-btn-unsubscribe:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* --- SECURE DATA IMPORT (UPLOADS) --- */
.sa-upload {
    width: 100% !important;
    margin: 20px 0 !important;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-slate);
    border-radius: 12px;
    padding: 24px;
    box-sizing: border-box;
    text-align: left;
    /* Cambiado de center */
}

.sa-upload .sa-card-header {
    text-align: left;
    /* Cambiado de center */
    margin-bottom: 20px;
}

.sa-upload h2 {
    margin-bottom: 8px;
    color: #ffffff;
    /* font-size hereda de .sa-card-header h2 en base.css (0.95rem) */
}

.sa-upload p {
    color: #94a3b8;
    /* font-size hereda de .sa-card-header p en base.css (0.8rem) */
}

.sa-dropzone {
    border: 2px dashed #334155;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(30, 41, 59, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sa-dropzone:hover,
.sa-dropzone.dragover {
    border-color: var(--accent-blue);
    background: rgba(30, 41, 59, 0.5);
}

/* Hide native file input text/button */
.sa-file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.sa-dropzone-title {
    font-size: 1.1rem !important;
    font-weight: 500;
    color: #e2e8f0 !important;
    margin: 0 auto 10px auto !important;
    display: block;
}

.sa-dropzone-subtitle {
    font-size: 0.85rem !important;
    color: #64748b !important;
    max-width: 450px;
    margin: 0 auto !important;
    display: block;
}

/* Progress bar inside upload */
.sa-progress {
    height: 6px;
    background: #1e293b;
    border-radius: 3px;
    margin-top: 15px;
    overflow: hidden;
}

.sa-progress-bar {
    height: 100%;
    background: var(--gradient-sa);
    width: 0%;
    transition: width 0.3s ease;
}

.sa-progress-text {
    font-size: 0.8rem;
    text-align: center;
    margin-top: 5px;
    color: #94a3b8;
}

/* ============================================================ */
/* STAGE 3: GOOGLE LINK & ONBOARDING PREMIUM REFORCED          */
/* ============================================================ */

/* Stage 3: Google Link Invitation Card - Redesign Premium */
.google-link-prompt {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(167, 139, 250, 0.3);
    /* Lila neón suave */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 20px;
    position: fixed;
    bottom: 24px;
    right: 24px;
    /* Esquina inferior derecha */
    left: auto;
    width: 320px;
    z-index: 70000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 0.95rem;
    animation: saFloatPrompt 4s ease-in-out infinite;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.google-link-prompt .prompt-close-x {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.google-link-prompt .prompt-close-x:hover {
    color: white;
}

.google-link-prompt p {
    margin: 0;
    line-height: 1.5;
    padding-right: 20px;
    font-weight: 500;
    text-align: left;
}

.google-link-prompt .sa-prompt-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
}

.google-link-prompt .sa-btn-link-action {
    background: #a78bfa !important;
    /* Lila sólido */
    color: white !important;
    border: none !important;
    padding: 10px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    transition: transform 0.2s, background 0.2s !important;
    text-align: center !important;
}

.google-link-prompt .sa-btn-link-action:hover {
    background: #8b5cf6 !important;
    transform: translateY(-1px);
}

.google-link-dismiss-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    user-select: none;
}

.google-link-dismiss-wrap input[type="checkbox"] {
    accent-color: #a78bfa;
    cursor: pointer;
}

@keyframes saFloatPrompt {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Botón Link Google Account - Estilo Transparente Premium (My Account) */
.auth-link-button {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 8px;
    color: #ffffff !important;
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-top: 15px;
    cursor: pointer;
}

.auth-link-button:hover {
    border-color: #a78bfa !important;
    background: rgba(167, 139, 250, 0.08) !important;
}

.auth-link-button img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
    /* Logo de Google en blanco para minimalismo total */
}

/* Global Premium Dialog System */
.sa-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: saFadeIn 0.3s ease;
}

.sa-modal-global {
    background: rgba(20, 20, 30, 0.95) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: saSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sa-modal-global h3 {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.sa-modal-global p {
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 25px;
}

.sa-modal-global a {
    color: #a78bfa !important;
    text-decoration: underline;
    font-weight: 500;
}

.sa-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.sa-modal-actions .sa-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.sa-modal-actions .sa-btn-cancel {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #94a3b8 !important;
}

.sa-modal-actions .sa-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: #ffffff !important;
}

.sa-modal-actions .sa-btn-primary {
    background: var(--gradient-sa) !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(167, 139, 250, 0.3);
}

.sa-modal-actions .sa-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(167, 139, 250, 0.4);
}

/* Premium Toast System */
.sa-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2147483647;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.sa-toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(32, 234, 215, 0.3);
    /* Verde Agua por defecto */
    border-radius: 12px;
    padding: 14px 20px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: saToastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1), saToastOut 0.4s 2.6s forwards;
    min-width: 260px;
}

.sa-toast--success {
    border-color: rgba(32, 234, 215, 0.5);
}

.sa-toast--error {
    border-color: rgba(239, 68, 68, 0.5);
}

@keyframes saToastIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes saToastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(50px);
    }
}

@keyframes saSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes saFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Specific adjustment for Google Link Prompt on Mobile */
@media (max-width: 767px) {
    .google-link-prompt {
        left: 5% !important;
        right: 5% !important;
        width: 90% !important;
        bottom: 30px !important;
        transform: none !important;
        box-sizing: border-box;
        z-index: 75000 !important;
    }
}

/* PWA Install Button Styles */
.sa-pwa-install-btn {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 8px;
    color: #ffffff !important;
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-top: 10px;
    cursor: pointer;
}

.sa-pwa-install-btn:hover {
    border-color: #a78bfa !important;
    background: rgba(167, 139, 250, 0.08) !important;
}

.sa-pwa-install-btn svg {
    width: 16px;
    height: 16px;
}

.sa-pwa-installed {
    opacity: 0.6 !important;
    border-color: rgba(34, 197, 94, 0.4) !important;
    pointer-events: none !important;
    cursor: default !important;
}

/* --- ANALYTICS & AUDIT PREMIUM STYLES --- */
.sa-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 10px;
}

.sa-chart-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    height: 350px;
    /* FIXED HEIGHT TO PREVENT CHART.JS LOOP */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sa-chart-card h3 {
    font-size: 0.95rem;
    color: #94a3b8;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sa-audit-container {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sa-audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.sa-audit-table th {
    text-align: left;
    padding: 12px 15px;
    background: rgba(15, 23, 42, 0.6);
    color: #94a3b8;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sa-audit-table td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sa-text-truncate {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.sa-badge--linkedin {
    background: #0077b5;
    color: white;
}

.sa-badge--x {
    background: #000000;
    color: white;
    border: 1px solid #333;
}

.sa-audit-results {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 80vh;
    background: #0f172a;
    border: 1px solid var(--accent-purple);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    animation: saSlideInUp 0.3s ease;
}

.sa-hidden {
    display: none;
}

.sa-audit-res-header {
    padding: 15px 20px;
    background: var(--gradient-sa);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

.sa-audit-res-content {
    padding: 20px;
    overflow-y: auto;
    color: #e2e8f0;
}

.sa-markdown strong {
    color: #20ead7;
}

.sa-markdown li {
    margin-left: 15px;
    margin-bottom: 5px;
}

@keyframes saSlideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}