/* 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;
}

.chatbot-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(140deg, rgba(37, 99, 235, 0.85), rgba(16, 185, 129, 0.86));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 14px 34px rgba(2, 132, 199, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.2) 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(99, 102, 241, 0.35);
    opacity: 0;
    transform: scale(0.8);
    animation: ping-ring 6s ease-out infinite;
    pointer-events: none;
}

.chatbot-button::before {
    content: '';
    position: absolute;
    inset: -30%;
    border-radius: 50%;
    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(-4px) scale(1.1);
    box-shadow: 0 24px 50px rgba(2, 132, 199, 0.32), 0 0 24px rgba(16, 185, 129, 0.28);
    filter: saturate(1.18);
}

.chatbot-button:hover::before {
    transform: translateX(130%) rotate(18deg);
}

.chatbot-button:hover .chatbot-icon {
    transform: scale(1.08) rotate(-5deg);
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
}

.chatbot-button:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.85);
    outline-offset: 4px;
}

.chatbot-button.active {
    transform: rotate(45deg) scale(1.03);
    background: linear-gradient(140deg, rgba(37, 99, 235, 0.92), rgba(16, 185, 129, 0.92));
    box-shadow: 0 16px 34px rgba(2, 132, 199, 0.27);
}

/* 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(2, 132, 199, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
        filter: drop-shadow(0 0 0 rgba(99, 102, 241, 0));
    }
    68% {
        transform: scale(1.08);
        box-shadow: 0 22px 44px rgba(59, 130, 246, 0.30);
        filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.65));
    }
    74% {
        transform: scale(1.03);
        box-shadow: 0 20px 40px rgba(16, 185, 129, 0.24);
        filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.45));
    }
    100% {
        transform: scale(1);
        box-shadow: 0 14px 34px rgba(2, 132, 199, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
        filter: drop-shadow(0 0 0 rgba(99, 102, 241, 0));
    }
}

@keyframes ping-ring {
    0% {
        opacity: 0;
        transform: scale(0.85);
        border-color: rgba(99, 102, 241, 0.4);
    }
    12% {
        opacity: 0.8;
    }
    40% {
        opacity: 0;
        transform: scale(1.25);
        border-color: rgba(16, 185, 129, 0.35);
    }
    100% {
        opacity: 0;
        transform: scale(1.25);
    }
}

@media (max-width: 768px) {
    .chatbot-container {
        bottom: 18px;
        right: 18px;
    }
    .chatbot-button {
        width: 82px;
        height: 82px;
        box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
    }
    .chatbot-button .chatbot-icon {
        width: 96%;
        height: 96%;
    }
}

.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(37,99,235,0.95), rgba(16,185,129,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: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.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(90deg, #2563eb 0%, #06b6d4 100%);
    color: white;
    border: none;
    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.1);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.3);
}

.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: 480px) {
    .chatbot-container { bottom: 20px; right: 20px; }
    .chatbot-button { width: 60px; height: 60px; font-size: 24px; }
    .chatbot-window {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 80px;
        width: auto;
        height: min(70vh, 520px);
        max-height: calc(100vh - 120px);
    }
    .chatbot-messages { padding: 15px; }
    .chatbot-input-container { padding: 10px 12px; gap: 8px; }
    .chatbot-input { font-size: 13px; padding: 10px 14px; padding-left: 34px; }
    .chatbot-send { width: 42px; height: 42px; font-size: 16px; }
}

@media (max-height: 700px) {
    .chatbot-window {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 70px;
        width: auto;
        height: min(68vh, 480px);
        max-height: calc(100vh - 110px);
    }
}

@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%);
}

.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; }
