/**
 * Webi Chatbot Styles
 * Modern, animated chatbot interface
 */

/* Floating Chat Icon - Creative Modern Design */
.webi-chat-icon {
    position: fixed;
    bottom: 155px;
    right: 20px;
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
}

/* Hide when chatbot is active */
body.webi-chat-open .webi-chat-icon {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.8) translateY(20px) !important;
}

.webi-chat-icon:hover .webi-robot-wrapper {
    transform: scale(1.08) rotate(5deg);
}

/* Robot Wrapper */
.webi-robot-wrapper {
    position: relative;
    width: 65px;
    height: 65px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation: webi-gentle-float 4s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(6, 117, 232, 0.25));
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

/* Notification Badge */
.webi-notification-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2.5px solid white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    animation: webi-badge-pulse 2s infinite;
}

/* Speech Bubble */
.webi-speech-bubble {
    position: absolute;
    top: 50%;
    right: 75px;
    transform: translateY(-50%);
    background: white;
    padding: 12px 18px;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
    color: #0675e8;
    animation: webi-bubble-appear 0.5s ease-out;
    border: 1.5px solid rgba(6, 117, 232, 0.1);
}

body.webi-chat-open .webi-speech-bubble {
    opacity: 0 !important;
    pointer-events: none !important;
}

.webi-speech-bubble::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -8px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid white;
    filter: drop-shadow(2px 0 2px rgba(0, 0, 0, 0.05));
}

.webi-speech-bubble span {
    transition: opacity 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Animations */
@keyframes webi-gentle-float {

    0%,
    100% {
        transform: translateY(0px) rotate(0deg) translateZ(0);
    }

    25% {
        transform: translateY(-4px) rotate(-1deg) translateZ(0);
    }

    50% {
        transform: translateY(0px) rotate(0deg) translateZ(0);
    }

    75% {
        transform: translateY(-4px) rotate(1deg) translateZ(0);
    }
}

/* Smooth SVG Rendering */
.webi-robot-wrapper svg {
    shape-rendering: geometricPrecision;
    transform: translateZ(0);
}

.robot-eyes,
.robot-mouth,
.robot-face {
    backface-visibility: hidden;
    transform: translateZ(0);
}

@keyframes webi-badge-pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    }

    50% {
        transform: scale(1.15);
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.7);
    }
}

@keyframes webi-bubble-appear {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0) scale(1);
    }
}

/* Chatbot Container */
.webi-chatbot-container {
    position: fixed;
    bottom: 155px;
    right: 24px;
    width: 400px;
    height: 520px;
    height: min(520px, 75vh);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.webi-chatbot-container.webi-hidden {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}

.webi-chatbot-container.webi-show {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.webi-chatbot-header {
    background: linear-gradient(135deg, #0675e8 0%, #005bc2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

.webi-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.webi-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.webi-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.webi-status {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.webi-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: webi-pulse 2s infinite;
}

.webi-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.webi-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Messages Area */
.webi-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.webi-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.webi-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.webi-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.webi-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Messages */
.webi-message {
    display: flex;
    animation: webi-slide-in 0.3s ease-out;
}

@keyframes webi-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.webi-message-content {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.webi-message-user {
    justify-content: flex-end;
}

.webi-message-user .webi-message-content {
    flex-direction: row-reverse;
}

.webi-message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #0675e8 0%, #005bc2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.webi-message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.webi-message-user .webi-message-bubble {
    background: linear-gradient(135deg, #0675e8 0%, #005bc2 100%);
    color: white;
}

.webi-message-text {
    font-size: 14px;
    line-height: 1.5;
    color: #1e293b;
    /* Unified dark text for light bubbles */
}

.webi-message-text a.chatbot-link {
    color: #0675e8;
    text-decoration: underline;
    font-weight: 600;
}

.webi-message-user .webi-message-text a.chatbot-link {
    color: #ffffff;
}

.webi-message-text ul {
    margin: 8px 0;
    padding-left: 20px;
}

.webi-message-text li {
    margin-bottom: 4px;
}

.webi-message-time {
    font-size: 11px;
    opacity: 0.6;
    display: block;
}

/* Typing Indicator */
.webi-typing-indicator {
    display: flex;
    gap: 10px;
    align-items: center;
    animation: webi-slide-in 0.3s ease-out;
}

.webi-typing-dots {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 4px;
}

.webi-typing-dots span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: webi-typing 1.4s infinite;
}

.webi-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.webi-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes webi-typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.webi-chat-input-wrapper {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 16px;
}

.webi-quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.webi-quick-actions::-webkit-scrollbar {
    height: 4px;
}

.webi-quick-actions::-webkit-scrollbar-track {
    background: transparent;
}

.webi-quick-actions::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.webi-quick-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.webi-quick-btn:hover {
    background: #0675e8;
    color: white;
    border-color: #0675e8;
    transform: translateY(-2px);
}

.webi-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.webi-chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s;
}

.webi-chat-input:focus {
    border-color: #0675e8;
    box-shadow: 0 0 0 3px rgba(6, 117, 232, 0.1);
}

.webi-send-btn {
    background: linear-gradient(135deg, #0675e8 0%, #005bc2 100%);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.webi-send-btn svg {
    transform: scaleX(1);

}

.webi-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(6, 117, 232, 0.3);
}

.webi-send-btn:active {
    transform: scale(0.95);
}

/* Rotate phone icon upward for Contact button */
.webi-quick-btn[data-message*="contact"] svg {
    transform: rotate(10deg);
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .webi-chat-icon {
        bottom: 140px;
        top: auto;
        transform: none;
    }

    .webi-speech-bubble {
        display: none;
        /* Hide bubble on mobile to save space */
    }

    .webi-chatbot-container {
        width: calc(100vw - 32px);
        height: auto;
        max-height: calc(100vh - 120px);
        right: 16px;
        bottom: 75px;
        top: auto;
    }
}

/* Laptop Screen Optimizations */
@media (max-height: 800px) {
    .webi-chatbot-container {
        bottom: 100px;
        /* Bring it down closer to other buttons to save top space */
        height: min(480px, 70vh);
    }

    .webi-chat-icon {
        bottom: 100px;
    }
}

@media (max-width: 480px) {
    .webi-chatbot-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        right: 16px;
        bottom: 75px;
    }

    .webi-chat-icon {
        right: 16px;
        bottom: 130px;
    }

    .webi-robot-wrapper {
        width: 60px;
        height: 60px;
    }
}

/* Hide other floating elements when chat is open */
body.webi-chat-open .floating-whatsapp-btn,
body.webi-chat-open #scrollUp,
body.webi-chat-open .floating-scroll-btn {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Print Styles */
@media print {

    .webi-chat-icon,
    .webi-chatbot-container {
        display: none !important;
    }
}

/* Dark Mode Overrides for Chatbot Container itself */
body.dark-mode .webi-chatbot-container {
    background: #18181b;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .webi-chat-messages {
    background: #09090b;
}

body.dark-mode .webi-message-bubble {
    background: #27272a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.dark-mode .webi-message-text {
    color: #e4e4e7;
}

body.dark-mode .webi-message-user .webi-message-bubble {
    background: linear-gradient(135deg, #0675e8 0%, #005bc2 100%);
    border: none;
}

body.dark-mode .webi-message-user .webi-message-text {
    color: #ffffff;
}

body.dark-mode .webi-chat-input-wrapper,
body.dark-mode .webi-input-container {
    background: #18181b;
}

body.dark-mode .webi-chat-input {
    background: #27272a;
    color: #ffffff;
    border-color: #3f3f46;
}

body.dark-mode .webi-chat-input::placeholder {
    color: #71717a;
}

body.dark-mode .webi-quick-btn {
    background: #27272a;
    border-color: #3f3f46;
    color: #d4d4d8;
}

body.dark-mode .webi-quick-btn:hover {
    background: #0675e8;
    color: white;
}

body.dark-mode .webi-typing-dots {
    background: #27272a;
}
