/*
 * ITWS Chat Bot Widget Stylesheet
 * Premium, glassmorphic, responsive floating chat assistant.
 */

:root {
    --itws-chat-primary: #4364F7;
    --itws-chat-primary-hover: #3451db;
    --itws-chat-primary-rgb: 67, 100, 247;
    --itws-chat-bg: rgba(255, 255, 255, 0.95);
    --itws-chat-card-bg: #ffffff;
    --itws-chat-text: #1e293b;
    --itws-chat-text-muted: #64748b;
    --itws-chat-border: rgba(0, 0, 0, 0.1);
    --itws-chat-bot-bubble: #f1f5f9;
    --itws-chat-bot-text: #0f172a;
    --itws-chat-user-bubble: var(--itws-chat-primary, #4364F7);
    --itws-chat-user-text: #ffffff;
    --itws-chat-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.2), 0 4px 16px -2px rgba(0, 0, 0, 0.08);
    --itws-chat-radius: 20px;
    --itws-chat-transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Floating Launcher Button */
.itws-chat-launcher {
    position: fixed !important;
    bottom: 24px;
    right: 24px;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: var(--itws-chat-primary, #4364F7) !important;
    color: #ffffff !important;
    box-shadow: 0 8px 24px rgba(var(--itws-chat-primary-rgb, 67, 100, 247), 0.4), 0 1px 10px rgb(255 255 255 / 35%) !important;
    cursor: pointer !important;
    z-index: 2147483640 !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: var(--itws-chat-transition) !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    overflow: hidden !important;
}

.itws-chat-launcher:hover {
    transform: scale(1.08) translateY(-2px) !important;
    box-shadow: 0 12px 30px rgba(67, 100, 247, 0.5) !important;
}

.itws-chat-launcher:active {
    transform: scale(0.95) !important;
}

.itws-chat-launcher svg {
    width: 28px !important;
    height: 28px !important;
    fill: currentColor !important;
    transition: transform 0.3s ease !important;
}

.itws-chat-launcher-avatar {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
}

.itws-chat-launcher .itws-chat-icon-close {
    display: none !important;
}

.itws-chat-launcher.is-active .itws-chat-icon-chat,
.itws-chat-launcher.is-active .itws-chat-launcher-avatar {
    display: none !important;
}

.itws-chat-launcher.is-active .itws-chat-icon-close {
    display: block !important;
    transform: rotate(90deg) !important;
}

/* Unread Badge / Pulse */
.itws-chat-badge {
    position: absolute !important;
    top: 2px !important;
    right: 2px !important;
    width: 14px !important;
    height: 14px !important;
    background-color: #10b981 !important;
    border: 2.5px solid #ffffff !important;
    border-radius: 50% !important;
    display: block !important;
    z-index: 2 !important;
}

.itws-chat-badge::after {
    content: '' !important;
    position: absolute !important;
    top: -2.5px !important;
    left: -2.5px !important;
    width: 14px !important;
    height: 14px !important;
    border-radius: 50% !important;
    background-color: inherit !important;
    animation: itws-chat-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite !important;
}

@keyframes itws-chat-ping {
    75%, 100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* Chat Panel */
.itws-chat-panel {
    position: fixed !important;
    bottom: 96px;
    right: 24px;
    width: 380px !important;
    max-width: calc(100vw - 32px) !important;
    height: 580px !important;
    max-height: calc(100vh - 120px) !important;
    background: var(--itws-chat-bg, #ffffff) !important;
    color: var(--itws-chat-text, #1e293b) !important;
    border: 1px solid var(--itws-chat-border, rgba(0,0,0,0.1)) !important;
    border-radius: var(--itws-chat-radius, 20px) !important;
    box-shadow: var(--itws-chat-shadow) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    z-index: 2147483645 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    opacity: 0 !important;
    transform: translateY(24px) scale(0.96) !important;
    pointer-events: none !important;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    box-sizing: border-box !important;
}

.itws-chat-panel.is-open {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

/* Chat Header */
.itws-chat-header {
    padding: 16px 20px !important;
    background: var(--itws-chat-primary, #4364F7) !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05) !important;
}

.itws-chat-header-info {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.itws-chat-avatar {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-weight: bold !important;
    font-size: 18px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
}

.itws-chat-avatar svg {
    width: 22px !important;
    height: 22px !important;
    fill: currentColor !important;
}

.itws-chat-header-avatar-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
}

.itws-chat-title-group h3 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    line-height: 1.2 !important;
}

.itws-chat-status {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    margin-top: 2px !important;
}

.itws-chat-status-dot {
    width: 8px !important;
    height: 8px !important;
    background: #10b981 !important;
    border-radius: 50% !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) !important;
}

.itws-chat-header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.itws-chat-header-btn {
    background: transparent !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.85) !important;
    cursor: pointer !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s, color 0.2s !important;
    padding: 0 !important;
    margin: 0 !important;
}

.itws-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

.itws-chat-header-btn svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
}

/* Chat Messages Container */
.itws-chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    background: #f8fafc !important;
    scroll-behavior: smooth !important;
}

.itws-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.itws-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

/* Individual Message Items */
.itws-chat-msg {
    display: flex !important;
    flex-direction: column !important;
    max-width: 85% !important;
    animation: itws-chat-fade-in 0.25s ease forwards !important;
}

@keyframes itws-chat-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.itws-chat-msg.bot {
    align-self: flex-start !important;
}

.itws-chat-msg.user {
    align-self: flex-end !important;
}

.itws-chat-msg-row {
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
}

.itws-chat-msg-avatar {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0 !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
}

.itws-chat-bubble {
    padding: 12px 16px !important;
    border-radius: 16px !important;
    font-size: 14px !important;
    line-height: 1.45 !important;
    word-break: break-word !important;
}

.itws-chat-msg.bot .itws-chat-bubble {
    background: #ffffff !important;
    color: #0f172a !important;
    border-bottom-left-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

.itws-chat-msg.user .itws-chat-bubble {
    background: var(--itws-chat-primary, #4364F7) !important;
    color: #ffffff !important;
    border-bottom-right-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(67, 100, 247, 0.3) !important;
}

.itws-chat-bubble p {
    margin: 0 0 8px 0 !important;
}

.itws-chat-bubble p:last-child {
    margin-bottom: 0 !important;
}

.itws-chat-bubble a {
    color: inherit !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
}

.itws-chat-bubble code {
    background: rgba(0, 0, 0, 0.08) !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-family: monospace !important;
    font-size: 0.9em !important;
}

.itws-chat-msg.user .itws-chat-bubble code {
    background: rgba(255, 255, 255, 0.25) !important;
}

.itws-chat-time {
    font-size: 11px !important;
    color: #64748b !important;
    margin-top: 4px !important;
    padding: 0 4px !important;
}

.itws-chat-msg.user .itws-chat-time {
    text-align: right !important;
}

/* Typing Indicator Animation */
.itws-chat-typing {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 12px 16px !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    border-bottom-left-radius: 4px !important;
    width: fit-content !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    margin-bottom: 4px !important;
}

.itws-chat-typing span {
    width: 6px !important;
    height: 6px !important;
    background: #64748b !important;
    border-radius: 50% !important;
    animation: itws-chat-bounce 1.4s infinite ease-in-out both !important;
}

.itws-chat-typing span:nth-child(1) {
    animation-delay: -0.32s !important;
}

.itws-chat-typing span:nth-child(2) {
    animation-delay: -0.16s !important;
}

@keyframes itws-chat-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Quick Prompts Suggestions Carousel */
.itws-chat-prompts {
    padding: 8px 16px !important;
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    background: #ffffff !important;
    border-top: 1px solid var(--itws-chat-border, rgba(0,0,0,0.1)) !important;
    scrollbar-width: none !important;
}

.itws-chat-prompts::-webkit-scrollbar {
    display: none;
}

.itws-chat-prompt-btn {
    white-space: nowrap !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 14px !important;
    padding: 6px 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
}

.itws-chat-prompt-btn:hover {
    background: var(--itws-chat-primary, #4364F7) !important;
    color: #ffffff !important;
    border-color: var(--itws-chat-primary, #4364F7) !important;
    transform: translateY(-1px) !important;
}

/* Input Footer */
.itws-chat-footer {
    padding: 12px 16px !important;
    background: #ffffff !important;
    border-top: 1px solid var(--itws-chat-border, rgba(0,0,0,0.1)) !important;
}

.itws-chat-form {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: #f1f5f9 !important;
    border-radius: 24px !important;
    padding: 4px 6px 4px 14px !important;
    border: 1px solid transparent !important;
    transition: border-color 0.2s, background 0.2s !important;
}

.itws-chat-form:focus-within {
    border-color: var(--itws-chat-primary, #4364F7) !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(67, 100, 247, 0.15) !important;
}

.itws-chat-input {
    flex: 1 !important;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    font-size: 14px !important;
    color: #1e293b !important;
    padding: 8px 0 !important;
    min-height: 20px !important;
    max-height: 80px !important;
    resize: none !important;
    font-family: inherit !important;
    line-height: 1.4 !important;
}

.itws-chat-input::placeholder {
    color: #94a3b8 !important;
}

.itws-chat-send-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: var(--itws-chat-primary, #4364F7) !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 0.2s, background 0.2s, opacity 0.2s !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}

.itws-chat-send-btn:disabled {
    background: #cbd5e1 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.itws-chat-send-btn:not(:disabled):hover {
    background: var(--itws-chat-primary-hover, #3451db) !important;
    transform: scale(1.05) !important;
}

.itws-chat-send-btn svg {
    width: 16px !important;
    height: 16px !important;
    fill: currentColor !important;
}

.itws-chat-branding {
    font-size: 11px !important;
    text-align: center !important;
    color: #64748b !important;
    margin-top: 6px !important;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .itws-chat-launcher {
        bottom: 16px !important;
        right: 16px !important;
        width: 54px !important;
        height: 54px !important;
    }

    .itws-chat-panel {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
    }
}

/* Inline Chatbot Contact Form */
.itws-chat-contact-form {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 12px !important;
    padding: 14px !important;
    margin-top: 6px !important;
    margin-bottom: 2px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04) !important;
    width: 250px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.itws-chat-contact-form input,
.itws-chat-contact-form textarea {
    box-sizing: border-box !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    outline: none !important;
    font-size: 13px !important;
    color: #1e293b !important;
    background: #ffffff !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}

.itws-chat-contact-form input:focus,
.itws-chat-contact-form textarea:focus {
    border-color: var(--itws-chat-primary, #4364F7) !important;
    box-shadow: 0 0 0 3px rgba(67, 100, 247, 0.12) !important;
}

.itws-chat-contact-submit-btn {
    transition: opacity 0.2s, background 0.2s, transform 0.2s !important;
}

.itws-chat-contact-submit-btn:not(:disabled):hover {
    filter: brightness(1.05);
    transform: translateY(-0.5px);
}

.itws-chat-contact-submit-btn:disabled {
    background: #cbd5e1 !important;
    cursor: not-allowed !important;
    transform: none !important;
}
