/* Copiado desde index/estilos/chatbotweb.css (reubicado) */
/* ===== CHATBOT ASISTENTE VIRTUAL - VERSIÓN SEGURA ===== */
.chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    font-family: 'Poppins', sans-serif;
    transition: bottom 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), filter 0.35s ease;
    will-change: bottom, transform;
}

.chatbot-container.hero-offset {
    bottom: 80px;
    transform: translateY(-4px);
    filter: drop-shadow(0 8px 18px rgba(127, 12, 23, 0.22));
}

.chatbot-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(111, 9, 20, 0.96) 0%, rgba(127, 12, 23, 0.95) 36%, rgba(179, 15, 31, 0.96) 74%, rgba(214, 48, 67, 0.96) 100%);
    color: #fff;
    border: 1px solid rgba(242, 194, 48, 0.72);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 14px 34px rgba(127, 12, 23, 0.38), 0 0 0 1px rgba(242, 194, 48, 0.3) inset;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.32s ease, filter 0.32s ease;
    position: relative;
    z-index: 10001;
    overflow: hidden;
    isolation: isolate;
    backdrop-filter: blur(6px) saturate(120%);
}

/* Efecto moderno periódico del ícono */
.chatbot-button:not(.active) {
    animation: idle-pulse 6s ease-in-out infinite;
}

.chatbot-button:not(.active)::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(242, 194, 48, 0.28);
    opacity: 0;
    transform: scale(0.8);
    animation: ping-ring 6s ease-out infinite;
    pointer-events: none;
}

.chatbot-button::before {
    content: '';
    position: absolute;
    inset: -30%;
    background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.45) 50%, transparent 80%);
    transform: translateX(-135%) rotate(18deg);
    transition: transform 0.65s ease;
    z-index: 0;
    pointer-events: none;
}

.chatbot-button:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 18px 38px rgba(127, 12, 23, 0.46), 0 0 12px rgba(242, 194, 48, 0.24);
    filter: none;
}

.chatbot-button:hover::before {
    transform: translateX(130%) rotate(18deg);
}

.chatbot-button:hover .chatbot-icon {
    transform: scale(1.03) rotate(-2deg);
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

.chatbot-button:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.85);
    outline-offset: 4px;
}

.chatbot-button.active {
    transform: rotate(45deg) scale(1.01);
    background: linear-gradient(145deg, rgba(111, 9, 20, 0.98), rgba(179, 15, 31, 0.98));
    box-shadow: 0 14px 30px rgba(127, 12, 23, 0.34);
}

/* Ocultamos el halo para que el ícono destaque más y no se pierda en el fondo */
.chatbot-button .pulse {
    display: none;
}

.chatbot-button .chatbot-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.32));
    transition: transform 0.35s ease, filter 0.35s ease;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes idle-pulse {
    0%, 60% {
        transform: scale(1);
        box-shadow: 0 14px 34px rgba(127, 12, 23, 0.26), 0 0 0 1px rgba(242, 194, 48, 0.18) inset;
           filter: drop-shadow(0 0 0 rgba(242, 194, 48, 0));
    }
    68% {
        transform: scale(1.03);
        box-shadow: 0 18px 36px rgba(127, 12, 23, 0.3);
           filter: drop-shadow(0 0 6px rgba(242, 194, 48, 0.28));
    }
    74% {
        transform: scale(1.01);
        box-shadow: 0 16px 32px rgba(179, 15, 31, 0.24);
           filter: drop-shadow(0 0 3px rgba(242, 194, 48, 0.22));
    }
    100% {
        transform: scale(1);
        box-shadow: 0 14px 34px rgba(127, 12, 23, 0.26), 0 0 0 1px rgba(242, 194, 48, 0.18) inset;
           filter: drop-shadow(0 0 0 rgba(242, 194, 48, 0));
    }
}

@keyframes ping-ring {
    0% {
        opacity: 0;
        transform: scale(0.85);
            border-color: rgba(242, 194, 48, 0.32);
    }
    12% {
        opacity: 0.8;
    }
    40% {
        opacity: 0;
        transform: scale(1.25);
            border-color: rgba(179, 15, 31, 0.24);
    }
    100% {
        opacity: 0;
        transform: scale(1.25);
    }
}

.chatbot-window {
    position: absolute;
    bottom: 110px;
    right: 0;
    width: 380px;
    height: 560px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 140px);
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px) saturate(125%);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(2,6,23,0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--light-gray);
    opacity: 0;
    transform: translateY(24px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.active {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.chatbot-security-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--secondary);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-header {
    background: linear-gradient(90deg, rgba(20, 23, 28, 0.98), rgba(127, 12, 23, 0.95));
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.chatbot-avatar {
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 22px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    position: relative;
}

.chatbot-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.chatbot-avatar.verified::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--secondary);
    border-radius: 50%;
    border: 2px solid white;
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-header-info p {
    margin: 5px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-close {
    margin-left: auto;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s;
    padding: 5px;
    border-radius: 50%;
}

.chatbot-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-image: 
        radial-gradient(circle at 25px 25px, rgba(37, 99, 235, 0.03) 2px, transparent 0),
        radial-gradient(circle at 75px 75px, rgba(16, 185, 129, 0.03) 2px, transparent 0);
    background-size: 100px 100px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    animation: messageIn 0.3s ease-out;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
    border: 1px solid rgba(16,24,40,0.06);
    box-shadow: 0 6px 18px rgba(2,6,23,0.06);
    border-bottom-left-radius: 6px;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5a6 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(37,99,235,0.12);
    border-bottom-right-radius: 6px;
}

.message-time {
    display: inline-block;
    margin-left: 8px;
    color: rgba(0,0,0,0.45);
    font-size: 11px;
    vertical-align: middle;
}

.message.typing {
    padding: 15px;
    background: white;
    border: 1px solid var(--light-gray);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    width: 60px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--gray);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

.chatbot-quick-actions {
    padding: 12px 14px;
    background: rgba(255,255,255,0.9);
    border-top: 1px solid var(--light-gray);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.quick-action {
    background: rgba(15,23,42,0.04);
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 999px;
    padding: 5px 5px;
    font-size: 9px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-family: 'Poppins', sans-serif;
}

.quick-action:hover {
    background: #7f0c17;
    color: white;
    border-color: #f2c230;
    transform: translateY(-1px);
}

.chatbot-input-container {
    padding: 14px 16px;
    background: rgba(255,255,255,0.95);
    border-top: 1px solid var(--light-gray);
    display: flex;
    gap: 10px;
    align-items: center;
    position: relative;
}

.chatbot-input {
    flex: 1;
    min-width: 0;
    padding: 12px 18px;
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 999px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    transition: all 0.3s;
    background: #f8fafc;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: white;
}

.chatbot-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chatbot-send {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #670912 0%, #8c0b18 35%, #b30f1f 75%, #cc2235 100%);
    color: white;
    border: 1px solid rgba(242, 194, 48, 0.46);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 6px 14px rgba(127, 12, 23, 0.38), 0 0 10px rgba(242, 194, 48, 0.2);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-footer {
    padding: 10px 20px;
    background: #f1f5f9;
    border-top: 1px solid var(--light-gray);
    font-size: 11px;
    color: var(--gray);
    text-align: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.chatbot-footer a:hover {
    text-decoration: underline;
}

/* ===== MODAL POLÍTICA DE PRIVACIDAD ===== */
.privacy-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.privacy-modal.is-open {
    display: flex;
}

.privacy-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    backdrop-filter: blur(2px);
}

.privacy-modal__content {
    position: relative;
    width: min(880px, 92vw);
    max-height: 86vh;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(2, 6, 23, 0.35);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.35);
    animation: privacyModalIn 0.25s ease-out;
}

.privacy-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.privacy-modal__close:hover {
    background: rgba(15, 23, 42, 0.16);
    transform: scale(1.05);
}

.privacy-modal__body {
    padding: 40px 36px 34px;
    overflow-y: auto;
    max-height: 86vh;
    font-family: 'Poppins', sans-serif;
    color: #0f172a;
}

.privacy-modal__body h1 {
    font-size: 22px;
    margin: 0 0 12px;
    color: #0f172a;
}

.privacy-modal__body h2 {
    font-size: 16px;
    margin: 22px 0 8px;
    color: #1e293b;
}

.privacy-modal__body p,
.privacy-modal__body li {
    font-size: 13px;
    line-height: 1.7;
    color: #334155;
}

.privacy-modal__body ul {
    padding-left: 20px;
    margin: 8px 0 14px;
}

.privacy-modal__body strong {
    color: #0f172a;
}

@keyframes privacyModalIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    .privacy-modal__body {
        padding: 32px 22px 26px;
    }
    .privacy-modal__body h1 {
        font-size: 20px;
    }
}

.chatbot-disclaimer {
    background: #fff8e6;
    border: 1px solid #ffd700;
    border-radius: 8px;
    padding: 4px 4px;
    margin: 5px 20px;
    font-size: 9px;
    color: #8a6d3b;
    text-align: center;
}

.chatbot-disclaimer i {
    color: #ffc107;
    margin-right: 5px;
}

.message.encrypted::before {
    content: '🔒';
    font-size: 10px;
    position: absolute;
    top: -8px;
    right: 10px;
    background: var(--light);
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid var(--light-gray);
}

.chatbot-input-container::before {
    content: '🔐';
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.5;
    pointer-events: none;
}

.chatbot-input {
    padding-left: 35px;
}

@media (max-width: 768px) {
    .chatbot-container {
        bottom: 18px;
        right: 18px;
    }

    .chatbot-container.hero-offset {
        bottom: 72px;
        transform: translateY(-3px);
        filter: drop-shadow(0 8px 18px rgba(127, 12, 23, 0.22));
    }

    .chatbot-button {
        width: 68px;
        height: 68px;
        font-size: 24px;
    }

    .chatbot-window.active {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100dvh;
        border-radius: 0;
        bottom: 0;
        right: 0;
        transform: none;
    }

    .chatbot-window.active .chatbot-messages {
        padding: 14px;
    }

    .chatbot-window.active .chatbot-input-container {
        padding: 10px 12px;
        gap: 8px;
    }

    .chatbot-window.active .chatbot-input {
        font-size: 13px;
        padding: 10px 14px;
        padding-left: 34px;
    }

    .chatbot-window.active .chatbot-send {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    .chatbot-container {
        right: 12px;
        transform: none;
    }

    .chatbot-container.hero-offset {
        bottom: 72px;
        transform: translateY(-3px);
    }

    .chatbot-button {
        width: 62px;
        height: 62px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-button:not(.active) {
        animation: none;
    }
    .chatbot-button:not(.active)::after {
        animation: none;
    }
}

.chatbot-window.high-security {
    border: 2px solid var(--secondary);
    box-shadow: 0 15px 50px rgba(16, 185, 129, 0.2);
}

.chatbot-window.high-security .chatbot-header {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
}

body.chatbot-mobile-open {
    overflow: hidden;
}

html.chatbot-open,
body.chatbot-open {
    overflow: hidden;
    overscroll-behavior: none;
}

body.chatbot-mobile-open .chatbot-container {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: none;
    filter: none;
}

body.chatbot-mobile-open .chatbot-button {
    opacity: 0;
    pointer-events: none;
}

body.chatbot-mobile-open .chatbot-window.active {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    transform: none;
    z-index: 10002;
}

body.chatbot-mobile-open .chatbot-window.active .chatbot-messages {
    padding: 14px;
}

body.chatbot-mobile-open .chatbot-window.active .chatbot-input-container {
    padding: 10px 12px;
    gap: 8px;
}

body.chatbot-mobile-open .chatbot-window.active .chatbot-input {
    font-size: 13px;
    padding: 10px 14px;
    padding-left: 34px;
}

body.chatbot-mobile-open .chatbot-window.active .chatbot-send {
    width: 42px;
    height: 42px;
    font-size: 16px;
}

.ai-toggle-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
    margin-left: 10px;
}

.ai-toggle-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(139, 92, 246, 0.3); }
.ai-toggle-btn.active { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }

.ai-indicator {
    display: inline-block;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 8px;
    animation: pulse-ai 2s infinite;
}

.ai-badge { display: flex; align-items: center; gap: 4px; }

@keyframes pulse-ai { 0% { opacity: 0.8; } 50% { opacity: 1; } 100% { opacity: 0.8; } }

.message.bot.ai-enhanced { border-left: 3px solid #8b5cf6; background: linear-gradient(90deg, #ffffff 0%, #f5f3ff 100%); }
.message.bot.ai-enhanced .ai-source { display: block; font-size: 10px; color: #8b5cf6; margin-top: 5px; font-style: italic; }

.ai-loading { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #6b7280; margin-top: 5px; }
.ai-loading-dot { width: 6px; height: 6px; background: #8b5cf6; border-radius: 50%; animation: ai-loading 1.4s infinite; }
.ai-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-loading { 0%, 60%, 100% { transform: translateY(0); opacity: 0.6; } 30% { transform: translateY(-5px); opacity: 1; } }

.message.bot::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 5px;
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2310b981'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
    background-size: contain;
    opacity: 0.5;
}

.message.bot.ai-enhanced::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238b5cf6'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E"); opacity: 0.8; }
