/* ========================================
   CHAT WIDGET IMBOCAR - Solo burbuja + ventana
   ======================================== */

.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(145deg, #0066FF 0%, #0052CC 50%, #003D99 100%);
    border: none;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 32px rgba(0, 82, 204, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: chatPulse 3s infinite;
}

.chat-toggle-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 82, 204, 0.55);
    animation: none;
}

.chat-toggle-btn:active {
    transform: scale(1.05);
}

.chat-toggle-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s ease;
}

.chat-toggle-btn:hover svg {
    transform: scale(1.1);
}

.chat-toggle-btn.active svg.chat-icon {
    display: none;
}

.chat-toggle-btn.active svg.close-icon {
    display: block;
}

.chat-toggle-btn svg.close-icon {
    display: none;
}

@keyframes chatPulse {
    0% {
        box-shadow: 0 8px 32px rgba(0, 82, 204, 0.45), 0 0 0 0 rgba(0, 102, 255, 0.4);
    }
    50% {
        box-shadow: 0 8px 32px rgba(0, 82, 204, 0.45), 0 0 0 12px rgba(0, 102, 255, 0);
    }
    100% {
        box-shadow: 0 8px 32px rgba(0, 82, 204, 0.45), 0 0 0 0 rgba(0, 102, 255, 0);
    }
}

.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #F8FAFC;
    border-radius: 24px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(0, 82, 204, 0.08);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: chatWindowOpen 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.chat-window.open {
    display: flex;
}

@keyframes chatWindowOpen {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.chat-header {
    background: linear-gradient(135deg, #0052CC 0%, #003D99 100%);
    padding: 16px 20px;
    position: relative;
    flex-shrink: 0;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #efc341 0%, #efc341 50%, #efc341 100%);
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-avatar img {
    width: 75%;
    height: 75%;
    object-fit: contain;
    border-radius: 50%;
}

.chat-header-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin: 0 0 4px 0;
}

.chat-header-info p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-header-info p::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chat-close-btn svg {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2.5;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
}

.chat-message {
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.bot {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message-content {
    padding: 12px 14px;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-line;
}

.chat-message.bot .chat-message-content {
    background: white;
    color: #0A1628;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #E2E8F0;
}

.chat-message.user .chat-message-content {
    background: linear-gradient(135deg, #0052CC 0%, #003D99 100%);
    color: white;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 3px 10px rgba(0, 82, 204, 0.25);
}

.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    justify-content: flex-start;
}

.chat-options-main {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    width: 100%;
}

.chat-options-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: stretch;
    width: 100%;
}

.chat-options-row .chat-option-btn {
    flex: 1;
    min-width: 0;
}

.chat-option-btn {
    background: #E6F0FF;
    border: 2px solid #0052CC;
    border-radius: 16px;
    padding: 8px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #0052CC;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-family: inherit;
    white-space: nowrap;
}

.chat-option-btn:hover {
    background: #0052CC;
    border-color: #0052CC;
    color: #FFFFFF;
}

.chat-option-btn:active {
    background: #003D99;
    color: #FFFFFF;
}

.chat-option-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 16px;
    background: white;
    border-radius: 16px 16px 16px 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #E2E8F0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #0052CC;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-ended-notice {
    text-align: center;
    padding: 20px 16px;
    margin-top: 16px;
    animation: chatFadeIn 0.4s ease-out;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-ended-notice p {
    font-size: 0.85rem;
    color: #6B7280;
    margin-bottom: 8px;
}

.chat-ended-notice a {
    font-size: 0.85rem;
    color: #0052CC;
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.chat-ended-notice a:hover {
    color: #003D99;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .chat-toggle-btn {
        width: 60px;
        height: 60px;
        bottom: 20px;
        right: 20px;
        border-radius: 18px;
    }

    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 90px;
        right: 10px;
        left: 10px;
        border-radius: 20px;
    }
}
