/* ITT Chatbot Widget Styles */
#itt-chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Position variants */
.itt-chatbot-pos-bottom-right {
    bottom: 20px;
    right: 20px;
}

.itt-chatbot-pos-bottom-left {
    bottom: 20px;
    left: 20px;
}

.itt-chatbot-pos-top-right {
    top: 20px;
    right: 20px;
}

.itt-chatbot-pos-top-left {
    top: 20px;
    left: 20px;
}

/* Admin Bar Compatibility */
body.admin-bar .itt-chatbot-pos-top-right {
    top: 52px;
}

body.admin-bar .itt-chatbot-pos-top-left {
    top: 52px;
}

@media screen and (min-width: 783px) {
    body.admin-bar .itt-chatbot-pos-top-right {
        top: 52px;
    }

    body.admin-bar .itt-chatbot-pos-top-left {
        top: 52px;
    }
}

#itt-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #00b2f0;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

#itt-chatbot-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#itt-chatbot-container {
    position: absolute;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ittChatbotSlideIn 0.3s ease-out;
}

/* Container positioning based on parent class */
.itt-chatbot-pos-bottom-right #itt-chatbot-container {
    bottom: 80px;
    right: 0;
}

.itt-chatbot-pos-bottom-left #itt-chatbot-container {
    bottom: 80px;
    left: 0;
}

.itt-chatbot-pos-top-right #itt-chatbot-container {
    top: 80px;
    right: 0;
}

.itt-chatbot-pos-top-left #itt-chatbot-container {
    top: 80px;
    left: 0;
}

@keyframes ittChatbotSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes ittChatbotSlideInTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.itt-chatbot-pos-top-right #itt-chatbot-container,
.itt-chatbot-pos-top-left #itt-chatbot-container {
    animation: ittChatbotSlideInTop 0.3s ease-out;
}

#itt-chatbot-header {
    background: #00b2f0;
    color: white;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}

#itt-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

#itt-chatbot-maximize {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 2px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

#itt-chatbot-maximize:hover {
    background: rgba(255, 255, 255, 0.2);
}

#itt-chatbot-maximize svg {
    width: 16px;
    height: 16px;
}

#itt-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

#itt-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Maximized state */
.itt-chatbot-maximized {
    position: fixed !important;
    inset: 0 !important;
    bottom: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    animation: ittChatbotFadeIn 0.2s ease-out;
}

.itt-chatbot-maximized #itt-chatbot-button {
    display: none;
}

.itt-chatbot-maximized #itt-chatbot-container,
.itt-chatbot-container-maximized {
    position: relative !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 90vw !important;
    max-width: 600px;
    height: 85vh !important;
    max-height: 700px;
}

#itt-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7f8fa;
}

.itt-chatbot-message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: ittChatbotFadeIn 0.3s ease-out;
}

@keyframes ittChatbotFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

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

.itt-chatbot-message.user .itt-chatbot-message-content {
    order: 1;
}

/* Bot avatar icon */
.itt-chatbot-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #00b2f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.itt-chatbot-message.user .itt-chatbot-avatar {
    display: none;
}

.itt-chatbot-avatar-svg {
    width: 20px;
    height: 20px;
}

.itt-chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.5;
}

.itt-chatbot-message.bot .itt-chatbot-message-content {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.itt-chatbot-message.bot .itt-chatbot-message-content a {
    color: #00b2f0;
    font-weight: 500;
}

.itt-chatbot-message-content strong { font-weight: 700; }
.itt-chatbot-message-content em { font-style: italic; }
.itt-chatbot-message-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}
.itt-chatbot-message-content h3, .itt-chatbot-message-content h4 {
    margin: 12px 0 6px;
    font-size: 1.1em;
    font-weight: 600;
}
.itt-chatbot-message-content h3:first-child, .itt-chatbot-message-content h4:first-child { margin-top: 0; }
.itt-chatbot-message-content ul, .itt-chatbot-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}
.itt-chatbot-message-content li {
    margin-bottom: 4px;
}

/* Question box – user's ask bubble */
.itt-chatbot-message.user .itt-chatbot-message-content {
    background: #00b2f0;
    color: white;
    border-bottom-right-radius: 4px;
    font-size: 15px;
}

.itt-chatbot-message.user .itt-chatbot-message-content a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: underline;
}

.itt-chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.itt-chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00b2f0;
    animation: ittChatbotTyping 1.4s infinite;
}

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

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

@keyframes ittChatbotTyping {

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

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

#itt-chatbot-input-area {
    padding: 16px;
    background: #f7f8fa;
    border-top: 1px solid #e5e7eb;
}

/* Question box – single unified rounded input with sparkle + send */
#itt-chatbot-input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 6px 6px 6px 18px;
    gap: 10px;
}

.itt-chatbot-input-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.itt-chatbot-input-icon svg {
    width: 18px;
    height: 22px;
}

.itt-chatbot-sparkle-bottom {
    transform-origin: 4px 6.67px;
    animation: ittChatbotSparkleFlip 2s ease-in-out infinite;
}

.itt-chatbot-sparkle-top {
    /* no animation */
}

@keyframes ittChatbotSparkleFlip {
    0%, 100% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(180deg);
    }
}

#itt-chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 15px;
    outline: none;
    min-width: 0;
}

#itt-chatbot-input::placeholder {
    color: #9ca3af;
}

#itt-chatbot-input:focus {
    outline: none;
}

#itt-chatbot-send {
    background: #00b2f0;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    flex-shrink: 0;
}

#itt-chatbot-send svg {
    display: block;
    width: 18px;
    height: 18px;
    color: white;
    pointer-events: none;
}

#itt-chatbot-send:hover {
    background: #0099d6;
}

#itt-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar styling */
#itt-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#itt-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#itt-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#itt-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Admin Test Connection result */
.itt-chatbot-test-result {
    margin-left: 8px;
}

.itt-chatbot-test-result.success {
    color: #00a32a;
}

.itt-chatbot-test-result.error {
    color: #d63638;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    #itt-chatbot-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
    }
}
