/* =========================
   AI Chatbot Widget Styles
   Professional & Standard UI
   ========================= */

/* Scope and reset inside widget to avoid theme/plugin style collisions */
#ai-chatbot-widget,
#ai-chatbot-widget * {
    box-sizing: border-box;
}

#ai-chatbot-widget button,
#ai-chatbot-widget textarea,
#ai-chatbot-widget img,
#ai-chatbot-widget svg {
    max-width: none;
}

#ai-chatbot-widget button,
#ai-chatbot-widget textarea {
    font: inherit;
    margin: 0;
}

/* Chat Button */
.aicw-chat-button {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    border-radius: 999px;
    padding: 0;
    border: none;
    appearance: none;
    -webkit-appearance: none;
    background-clip: padding-box;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: #ffffff;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
        system-ui, sans-serif;
    box-sizing: border-box;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.aicw-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.aicw-chat-button:active {
    transform: scale(0.95);
}

.aicw-chat-button img {
    width: 54px;
    height: 54px;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.aicw-chat-button svg {
    width: 32px;
    height: 32px;
    display: block;
    pointer-events: none;
}

/* Closed-state Label */
.aicw-chat-label {
    position: fixed;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #ffffff;
    background: rgba(17, 24, 39, 0.92);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    z-index: 9997;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

/* Chat Window */
.aicw-chat-window {
    position: fixed !important;
    right: 20px !important;
    bottom: 90px !important;
    left: auto !important;
    top: auto !important;
    width: 380px !important;
    max-width: calc(100vw - 40px) !important;
    height: 600px !important;
    max-height: calc(100vh - 120px) !important;
    border-radius: 16px;
    background: transparent;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.aicw-chat-window.aicw-open {
    display: flex !important;
}

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

/* Chat Header */
.aicw-chat-header {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.aicw-profile-avatar {
    position: relative;
    flex-shrink: 0;
}

.aicw-chat-header img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: block;
}

.aicw-header-info {
    flex: 1;
    min-width: 0;
}

.aicw-bot-name {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.3;
    margin: 0 0 1px 0;
}

.aicw-bot-status {
    font-size: 12px;
    color: #31b900;
    display: flex;
    align-items: center;
    gap: 6px;
}

.aicw-online-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}
/* Close Button */
.aicw-close {
    position: absolute;
    top: 8px;
    right: 12px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    opacity: 1;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.aicw-close:hover {
    opacity: 0.9;
    background: transparent;
}

.aicw-close svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* Chat Body */
.aicw-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.aicw-chat-body::-webkit-scrollbar {
    width: 6px;
}

.aicw-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.aicw-chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.aicw-chat-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Messages */
.aicw-msg {
    padding: 8px 14px;
    border-radius: 18px;
    max-width: 75%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    animation: messageSlide 0.2s ease;
}

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

.aicw-msg.aicw-bot {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.aicw-msg.aicw-user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.aicw-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 60px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.aicw-typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
    animation: typingDot 1.4s infinite ease-in-out;
}

.aicw-typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.aicw-typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.15);
    }
}

/* Chat Footer */
.aicw-chat-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

/* Input Field */
.aicw-input {
    flex: 1;
    min-height: 38px;
    height: 38px;
    max-height: 120px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 19px;
    padding: 8px 14px;
    font-size: 14px;
    line-height: 20px;
    resize: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    outline: none;
    transition: all 0.2s ease;
    overflow-y: auto;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.aicw-input:focus {
    border-color: rgba(0, 0, 0, 0.25);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.aicw-input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.aicw-input::-webkit-scrollbar {
    width: 4px;
}

.aicw-input::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Send Button */
.aicw-send-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
    border: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Defensive overrides against aggressive theme selectors */
#ai-chatbot-widget .aicw-chat-button {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

#ai-chatbot-widget .aicw-chat-button img {
    width: 100% !important;
    height: 100% !important;
    padding: 3px !important;
    object-fit: cover !important;
    object-position: center !important;
    border-radius: inherit !important;
}

#ai-chatbot-widget .aicw-chat-label {
    border: none !important;
    box-sizing: border-box !important;
}

#ai-chatbot-widget .aicw-close {
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
}

#ai-chatbot-widget .aicw-close:hover,
#ai-chatbot-widget .aicw-close:focus,
#ai-chatbot-widget .aicw-close:active {
    background: transparent !important;
    box-shadow: none !important;
}

#ai-chatbot-widget .aicw-send-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

#ai-chatbot-widget .aicw-input {
    min-height: 38px !important;
    height: 38px !important;
    border-radius: 19px !important;
    padding: 8px 14px !important;
    line-height: 20px !important;
    display: block !important;
    overflow-y: hidden !important;
    resize: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    scrollbar-width: none;
}

#ai-chatbot-widget .aicw-input::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
}

#ai-chatbot-widget .aicw-send-btn::before,
#ai-chatbot-widget .aicw-send-btn::after,
#ai-chatbot-widget .aicw-close::before,
#ai-chatbot-widget .aicw-close::after {
    content: none !important;
    display: none !important;
}

#ai-chatbot-widget .aicw-chat-body {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

.aicw-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.aicw-send-btn svg {
    display: block;
    width: 20px;
    height: 20px;
    transform: none;
    pointer-events: none;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .aicw-chat-window {
        width: calc(100% - 20px);
        height: calc(100% - 100px);
        left: 10px;
        right: 10px;
        bottom: 80px;
        border-radius: 12px;
    }

    .aicw-chat-button {
        bottom: 10px;
        right: 10px;
        width: 56px;
        height: 56px;
    }

    .aicw-chat-label {
        display: none !important;
    }

    .aicw-chat-header {
        padding: 14px 16px;
    }

    .aicw-chat-body {
        padding: 16px;
    }

    .aicw-chat-footer {
        padding: 12px 16px;
    }

    .aicw-msg {
        max-width: 85%;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .aicw-chat-window {
        width: calc(100% - 16px);
        left: 8px !important;
    }

    .aicw-chat-header img {
        width: 40px;
        height: 40px;
    }

    .aicw-bot-name {
        font-size: 15px;
    }
}
