/* Modern Chat Bot Wrapper */
.wp-bot-wrapper {
    position: fixed;
    right: 10px;
    bottom: 75px;
    z-index: 2147483647 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    pointer-events: auto;
}

.wp-bot-wrapper * {
    pointer-events: auto;
    box-sizing: border-box;
}

/* Modern Floating Toggle Button */
.wp-bot-toggle {
    padding: 0 !important;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 100% !important;
    cursor: pointer !important;
    background-color: #253664 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2147483647 !important;
    outline: none;
    pointer-events: auto !important;
    touch-action: manipulation;
    box-shadow: 0 8px 32px rgba(36, 31, 33, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.wp-bot-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #253664;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
}

.wp-bot-toggle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 12px 40px rgba(36, 31, 33, 0.6);
}

.wp-bot-toggle:hover::before {
    opacity: 1;
}

.wp-bot-toggle:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

/* Chat Icon with Animation */
.wp-bot-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.wp-bot-toggle:hover .wp-bot-toggle-icon {
    transform: scale(1.1);
}

/* Modern Chat Bubble Icon */
.wp-bot-toggle-icon::before {
    content: "";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 100%;
    background-image: url('../image/batajh.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    animation: wp-bot-pulse 1.8s ease-in-out infinite;
}

/* Alternative: SVG-style chat icon */
.wp-bot-toggle-icon::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 16px;
    background: white;
    border-radius: 12px 12px 12px 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@keyframes wp-bot-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(36, 31, 33, 0.0);
    }
    60% {
        transform: scale(1.08);
        box-shadow: 0 0 0 12px rgba(36, 31, 33, 0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(36, 31, 33, 0.0);
    }
}

/* Modern Chat Panel */
.wp-bot-widget {
    background: #1f1f1d !important;
    border-radius: 20px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 450px;
    max-height: calc(100vh - 100px);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    overflow: hidden;
    position: fixed;
    right: 10px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    z-index: 2147483646 !important;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
}

.wp-bot-widget.is-closed {
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.94);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modern Header */
.wp-bot-header {
    padding: 15px 24px 10px;
    background: linear-gradient(135deg, #241F21 0%, #050709 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space title and close button */
    position: relative;
    flex-shrink: 0;
}

/* Wave edge inspired by mockup */
/* Wave edge inspired by mockup */
.wp-bot-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px; /* The -1px is a common trick to hide potential seams */
    height: 64px;
    background-repeat: no-repeat;
    background-size: 100% 100%; /* Ensures the SVG stretches to cover the full width and 64px height */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320' preserveAspectRatio='none'><path fill='%23050709' fill-opacity='1' d='M0,128L60,133.3C120,139,240,149,360,128C480,107,600,53,720,58.7C840,64,960,128,1080,128C1200,128,1320,64,1380,32L1440,0L1440,320L1380,320C1320,320,1200,320,1080,320C960,320,840,320,720,320C600,320,480,320,360,320C240,320,120,320,60,320L0,320Z'></path></svg>");
    transform: scaleY(-1);
    transform-origin: center;
}

.wp-bot-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
    margin: 0;
}

.wp-bot-close {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    width: 28px;
    height: 28px;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 300;
    line-height: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    position: relative;
    overflow: hidden;
}

.wp-bot-close::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.wp-bot-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

.wp-bot-close:hover::before {
    width: 100%;
    height: 100%;
}

.wp-bot-close:active {
    transform: scale(0.95) !important;
    transition: all 0.1s ease !important;
}

/* Modern Messages Area */
.wp-bot-messages {
    flex: 1; /* Take remaining space */
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
    scroll-behavior: smooth;
}

.wp-bot-messages::-webkit-scrollbar {
    width: 4px;
}

.wp-bot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wp-bot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.wp-bot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Modern Message Bubbles */
.wp-bot-message {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    position: relative;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wp-bot-message.from-user {
    background: #FEFEFD !important;
    color: #241F21 !important;
    align-self: flex-end;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06) !important;
    border: none !important;
}

.wp-bot-message.from-bot {
    background: rgba(255,255,255,0.08) !important;
    color: #f5f5f5 !important;
    align-self: flex-start;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06) !important;
    border: none !important;
}

/* Modern Form */
.wp-bot-form {
    display: flex;
    gap: 10px;
    padding: 12px 16px 15px;
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    align-items: center;
}

.wp-bot-input {
    flex: 1;
    padding: 12px 16px 12px 16px;
    border: none !important;
    border-radius: 999px;
    background: #1f1f1d !important;
    color: #FEFEFD !important;
    caret-color: #FEFEFD !important;
    font-size: 14px;
    resize: none;
    transition: all 0.2s ease;
    outline: none;
    min-height: 44px;
    max-height: 120px;
}

.wp-bot-input:focus {
    border: none !important;
    background: #1f1f1d !important;
    color: #FEFEFD !important;
    box-shadow: none !important;
    outline: none !important;
}

.wp-bot-input::placeholder {
    color: #a0a0a0;
}

/* Ensure text is visible when browser autofill applies styles */
.wp-bot-input:-webkit-autofill,
.wp-bot-input:-webkit-autofill:hover,
.wp-bot-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #FEFEFD !important;
    -webkit-box-shadow: 0 0 0px 1000px #1f1f1d inset;
    box-shadow: 0 0 0px 1000px #1f1f1d inset;
    transition: background-color 9999s ease-in-out 0s;
}

/* Increase specificity to beat theme/global input styles */
.wp-bot-form .wp-bot-input,
#wp-bot-input.wp-bot-input {
    background: #1f1f1d !important;
    color: #FEFEFD !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
}

/* Dark mode: keep same input styling */
@media (prefers-color-scheme: dark) {
    .wp-bot-form .wp-bot-input,
    #wp-bot-input.wp-bot-input {
        background: #1f1f1d !important;
        color: #FEFEFD !important;
        border: none !important;
        box-shadow: none !important;
        outline: none !important;
    }
}

.wp-bot-send {
    background-color: #B02827 !important;
    background-image: none !important;
    color: #FEFEFD !important;
    border: none !important;
    width: 44px;
    height: 44px;
    border-radius: 50% !important;
    cursor: pointer !important; 
    font-weight: 700;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease !important;
    box-shadow: 0 6px 16px rgba(176, 40, 39, 0.35) !important;
    opacity: 1 !important;
    text-shadow: none !important;
}

.wp-bot-send:hover {
    background-color: #8B1F1F !important;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(176, 40, 39, 0.45) !important;
}

.wp-bot-send:active {
    background-color: #B02827 !important;
    transform: translateY(0);
}

/* Increase specificity to beat theme button styles */
.wp-bot-form .wp-bot-send {
    background-color: #B02827 !important;
    color: #FEFEFD !important;
    border: none !important;
    text-shadow: none !important;
}

/* Typing Indicator */
.wp-bot-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #253664 0%, #1a2347 100%);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(37, 54, 100, 0.3);
    border: none;
    align-self: flex-start;
    max-width: 85%;
}

.wp-bot-typing-dots {
    display: flex;
    gap: 4px;
}

.wp-bot-typing-dot {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.wp-bot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.wp-bot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Welcome Message */
.wp-bot-welcome {
    text-align: center;
    padding: 0px 20px 10px;
    color: #FEFEFD;
    font-size: 16px;
}

.wp-bot-welcome-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 5px;
    border-radius: 50%;
    background-image: url('../image/batajh.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    color: transparent;
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    animation: botFloat 3.2s ease-in-out infinite;
    box-shadow: 0 10px 24px rgba(37, 54, 100, 0.25);
}

/* Fallback icon to ensure visibility across fonts */
.wp-bot-welcome-icon::after {
    content: '';
    color: #FEFEFD;
    font-size: 55px;
    line-height: 1;
}

/* Pulsing ring effect */
.wp-bot-welcome-icon::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid rgba(37, 54, 100, 0.18);
    animation: botPulse 2.6s ease-out infinite;
}

@keyframes botFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes botPulse {
    0% { opacity: 0.35; transform: scale(1); }
    70% { opacity: 0; transform: scale(1.25); }
    100% { opacity: 0; transform: scale(1.35); }
}

/* Enhanced Responsive Design */
@media (max-width: 1024px) {
    .wp-bot-widget { 
        width: calc(100vw - 40px); 
        height: calc(100vh - 140px);
        max-height: 650px;
        left: auto;
        right: 20px;
        bottom: calc(85px + env(safe-area-inset-bottom, 0px));
        border-radius: 20px;
    }
}

@media (max-width: 768px) {
    .wp-bot-widget { 
        width: calc(100vw - 30px); 
        height: calc(100vh - 120px);
        max-height: 600px;
        left: auto;
        right: 15px;
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        border-radius: 18px;
    }
    
    .wp-bot-toggle {
        width: 60px;
        height: 60px;
    }
    
    .wp-bot-toggle-icon {
        width: 54px;
        height: 54px;
    }
    
    .wp-bot-header {
        padding: 16px 22px 12px;
    }
    
    .wp-bot-title {
        font-size: 14px;
    }
    
    /* Mobile-specific improvements */
    .wp-bot-messages {
        -webkit-overflow-scrolling: touch;
    }
    
    .wp-bot-input {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 999px !important;
    }
}

@media (max-width: 480px) {
    .wp-bot-widget { 
        left: 10px;
        right: 10px;
        width: auto;
        height: calc(100vh - 90px);
        max-height: calc(100vh - 90px);
        bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        border-radius: 16px;
    }
    
    .wp-bot-toggle {
        width: 56px;
        height: 56px;
    }
    
    .wp-bot-toggle-icon {
        width: 50px;
        height: 50px;
    }
    
    .wp-bot-messages {
        padding: 16px 15px;
        -webkit-overflow-scrolling: touch;
    }
    
    .wp-bot-form {
        padding: 12px 15px;
    }
    
    .wp-bot-header {
        padding: 15px 20px 12px;
    }

    .wp-bot-message {
        max-width: 90%;
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .wp-bot-input {
        font-size: 13px;
        padding: 10px 14px;
        min-height: 40px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 999px !important;
    }
    
    .wp-bot-send {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }
    
    /* Mobile touch optimizations */
    .wp-bot-close {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    /* Prevent zoom on input focus */
    @supports (-webkit-touch-callout: none) {
        .wp-bot-input {
            font-size: 16px;
        }
    }
}

@media (max-width: 360px) {
    .wp-bot-widget {
        left: 8px;
        right: 8px;
        width: auto;
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        border-radius: 12px;
    }
    
    .wp-bot-toggle {
        width: 52px;
        height: 52px;
    }
    
    .wp-bot-toggle-icon {
        width: 46px;
        height: 46px;
    }
    
    .wp-bot-messages {
        padding: 12px 10px;
        -webkit-overflow-scrolling: touch;
    }
    
    .wp-bot-form {
        padding: 10px;
        gap: 8px;
    }

    .wp-bot-header {
        padding: 12px 15px 10px;
    }

    .wp-bot-title {
        font-size: 13px;
    }
    
    .wp-bot-message {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .wp-bot-input {
        font-size: 12px;
        padding: 8px 12px;
        min-height: 36px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 999px !important;
    }
    
    .wp-bot-send {
        width: 36px;
        height: 36px;
        font-size: 11px;
    }
    
    .wp-bot-close {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }
}

/* Ultra-small screens */
@media (max-width: 320px) {
    .wp-bot-widget {
        left: 5px;
        right: 5px;
        width: auto;
        height: calc(100vh - 75px);
        max-height: calc(100vh - 75px);
        border-radius: 10px;
    }
    
    .wp-bot-toggle {
        width: 48px;
        height: 48px;
    }
    
    .wp-bot-toggle-icon {
        width: 42px;
        height: 42px;
    }
    
    .wp-bot-header {
        padding: 10px 12px 8px;
    }
    
    .wp-bot-title {
        font-size: 12px;
    }
    
    .wp-bot-messages {
        padding: 10px 8px;
        gap: 12px;
        -webkit-overflow-scrolling: touch;
    }
    
    .wp-bot-form {
        padding: 8px;
        gap: 6px;
    }
    
    .wp-bot-message {
        font-size: 11px;
        padding: 6px 10px;
        max-width: 95%;
    }
    
    .wp-bot-input {
        font-size: 11px;
        padding: 6px 10px;
        min-height: 32px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 999px !important;
    }
    
    .wp-bot-send {
        width: 32px;
        height: 32px;
        font-size: 10px;
    }
    
    .wp-bot-close {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* Landscape mobile optimizations */
@media (max-width: 896px) and (max-height: 414px) and (orientation: landscape) {
    .wp-bot-widget {
        height: calc(100vh - 40px);
        max-height: calc(100vh - 40px);
        bottom: calc(50px + env(safe-area-inset-bottom, 0px));
    }
    
    .wp-bot-messages {
        padding: 8px 12px;
    }
    
    .wp-bot-form {
        padding: 8px 12px;
    }
    
    .wp-bot-header {
        padding: 8px 16px 6px;
    }
    
    .wp-bot-title {
        font-size: 12px;
    }
    
    .wp-bot-message {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .wp-bot-input {
        min-height: 30px;
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Mobile-specific fixes */
@media (hover: none) and (pointer: coarse) {
    .wp-bot-toggle:hover {
        transform: none;
    }
    
    .wp-bot-close:hover {
        transform: none;
    }
    
    .wp-bot-send:hover {
        transform: none;
    }
    
    /* Touch feedback */
    .wp-bot-toggle:active {
        transform: scale(0.95);
    }
    
    .wp-bot-close:active {
        transform: scale(0.9);
    }
    
    .wp-bot-send:active {
        transform: scale(0.95);
    }
}

/* Additional z-index protection for child elements (excluding main wrapper and toggle) */
.wp-bot-wrapper *:not(.wp-bot-toggle):not(.wp-bot-widget),
.wp-bot-header,
.wp-bot-messages,
.wp-bot-form,
.wp-bot-input,
.wp-bot-send,
.wp-bot-close {
    z-index: inherit !important;
}

/* Ensure proper stacking context */

/* Force hardware acceleration for better performance and layering */
.wp-bot-toggle,
.wp-bot-widget {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Dark mode support (align with theme variables) */
@media (prefers-color-scheme: dark) {
    .wp-bot-widget {
        background: #1f1f1d !important;
        box-shadow: 
            0 20px 60px rgba(0, 0, 0, 0.4),
            0 8px 32px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(0, 0, 0, 0.1) !important;
    }
    .wp-bot-messages {
        background: transparent !important;
    }
    .wp-bot-message.from-bot {
        background: rgba(255,255,255,0.08) !important;
        color: #f5f5f5 !important;
        border: none !important;
    }
    .wp-bot-message.from-user {
        background: #FEFEFD !important;
        color: #241F21 !important;
        border: none !important;
    }
    .wp-bot-form {
        background: transparent !important;
        border-top-color: rgba(255, 255, 255, 0.08) !important;
    }
    .wp-bot-input::placeholder {
        color: #b5b5b5 !important;
    }
    .wp-bot-send {
        background-color: #B02827 !important;
        color: #FEFEFD !important;
        text-shadow: none !important;
    }
    .wp-bot-close {
        background: rgba(255, 255, 255, 0.2) !important;
        color: white !important;
    }
}


