/**
 * IMTA AI Chatbot - Frontend CSS
 * Giao diện chatbot premium: glassmorphism, glow effects, micro-animations.
 */

/* =========================================================
   CSS Variables (được override bởi inline style từ PHP)
   ========================================================= */
:root {
    --imta-cb-primary: #28bdbf;
    --imta-cb-primary-dark: #1fa3a5;
    --imta-cb-primary-light: #e8f8f8;
    --imta-cb-bg: #ffffff;
    --imta-cb-text: #1a1a2e;
    --imta-cb-text-light: #6b7280;
    --imta-cb-border: #e5e7eb;
    --imta-cb-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08);
    --imta-cb-radius: 24px;
    --imta-cb-msg-bot-bg: rgba(255, 255, 255, 0.85);
    --imta-cb-msg-user-bg: var(--imta-cb-primary);
    --imta-cb-msg-user-text: #ffffff;
    --imta-cb-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --imta-cb-glow: rgba(40, 189, 191, 0.35);
}

/* =========================================================
   Reset cứng - tránh bị theme override
   ========================================================= */
#imta-chatbot-container,
#imta-chatbot-container *,
#imta-chatbot-container *::before,
#imta-chatbot-container *::after {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
    border: none !important;
    outline: none !important;
    text-decoration: none !important;
    list-style: none !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* =========================================================
   Container & Positioning
   ========================================================= */
#imta-chatbot-container {
    position: fixed !important;
    bottom: 24px !important;
    z-index: 999999 !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: var(--imta-cb-text) !important;
    direction: ltr !important;
    text-align: left !important;
}

#imta-chatbot-container.imta-chatbot-right {
    right: 24px !important;
}

#imta-chatbot-container.imta-chatbot-left {
    left: 24px !important;
}

/* =========================================================
   Toggle Button — Premium Glow
   ========================================================= */
.imta-chatbot-toggle {
    width: 62px !important;
    height: 62px !important;
    min-width: 62px !important;
    min-height: 62px !important;
    border-radius: 50% !important;
    border: none !important;
    background: linear-gradient(135deg, var(--imta-cb-primary) 0%, var(--imta-cb-primary-dark) 60%, #178385 100%) !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    box-shadow:
        0 4px 20px rgba(40, 189, 191, 0.4),
        0 8px 32px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    transition: var(--imta-cb-transition) !important;
    animation: imta-cb-pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    overflow: visible !important;
}

.imta-chatbot-toggle::before {
    content: '';
    position: absolute !important;
    inset: -3px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, rgba(40, 189, 191, 0.6), rgba(23, 131, 133, 0.3)) !important;
    z-index: -1 !important;
    opacity: 0 !important;
    transition: opacity 0.4s ease !important;
}

.imta-chatbot-toggle:hover {
    transform: translateY(-3px) scale(1.08) !important;
    box-shadow:
        0 8px 30px rgba(40, 189, 191, 0.5),
        0 12px 40px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

.imta-chatbot-toggle:hover::before {
    opacity: 1 !important;
}

.imta-chatbot-toggle:active {
    transform: translateY(0) scale(0.95) !important;
}

.imta-chatbot-toggle svg {
    width: 28px !important;
    height: 28px !important;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15)) !important;
}

.imta-chatbot-icon-chat {
    width: 40px !important;
    height: 40px !important;
    object-fit: contain !important;
    border-radius: 0 !important;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2)) !important;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease !important;
}

.imta-chatbot-icon-close {
    display: none !important;
}

.imta-chatbot-toggle.active .imta-chatbot-icon-chat {
    display: none !important;
}

.imta-chatbot-toggle.active .imta-chatbot-icon-close {
    display: block !important;
}

.imta-chatbot-toggle.active {
    animation: none !important;
    box-shadow:
        0 4px 20px rgba(40, 189, 191, 0.35),
        0 8px 32px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

.imta-chatbot-toggle.active svg {
    transform: rotate(90deg) !important;
}

/* Notification badge */
.imta-chatbot-badge {
    position: absolute !important;
    top: -5px !important;
    right: -5px !important;
    width: 22px !important;
    height: 22px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2.5px solid #fff !important;
    animation: imta-cb-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    line-height: 1 !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4) !important;
}

@keyframes imta-cb-pulse {
    0% { box-shadow: 0 4px 20px rgba(40,189,191,0.4), 0 8px 32px rgba(0,0,0,0.15), 0 0 0 0 rgba(40,189,191,0.35); }
    70% { box-shadow: 0 4px 20px rgba(40,189,191,0.4), 0 8px 32px rgba(0,0,0,0.15), 0 0 0 16px rgba(40,189,191,0); }
    100% { box-shadow: 0 4px 20px rgba(40,189,191,0.4), 0 8px 32px rgba(0,0,0,0.15), 0 0 0 0 rgba(40,189,191,0); }
}

@keyframes imta-cb-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* =========================================================
   Chat Window — Glassmorphism & Depth
   ========================================================= */
.imta-chatbot-window {
    position: absolute !important;
    bottom: 80px !important;
    width: 390px !important;
    height: 540px !important;
    max-height: calc(100vh - 120px) !important;
    background: var(--imta-cb-bg) !important;
    border-radius: var(--imta-cb-radius) !important;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.14),
        0 8px 24px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.04) !important;
    display: none !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    opacity: 0 !important;
    transform: translateY(20px) scale(0.92) !important;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    pointer-events: none !important;
}

.imta-chatbot-window.active {
    display: flex !important;
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

.imta-chatbot-right .imta-chatbot-window {
    right: 0 !important;
}

.imta-chatbot-left .imta-chatbot-window {
    left: 0 !important;
}

/* =========================================================
   Header — Premium Gradient + Glow
   ========================================================= */
.imta-chatbot-header {
    background: linear-gradient(135deg, var(--imta-cb-primary) 0%, var(--imta-cb-primary-dark) 50%, #178385 100%) !important;
    color: #fff !important;
    padding: 16px 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
    min-height: 68px !important;
    position: relative !important;
    overflow: hidden !important;
}

/* Decorative shine overlay */
.imta-chatbot-header::before {
    content: '';
    position: absolute !important;
    top: -50% !important;
    right: -30% !important;
    width: 120px !important;
    height: 200% !important;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent) !important;
    transform: rotate(25deg) !important;
    pointer-events: none !important;
}

.imta-chatbot-header::after {
    content: '';
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 1px !important;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent) !important;
    pointer-events: none !important;
}

.imta-chatbot-header-info {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    min-width: 0 !important;
}

.imta-chatbot-avatar {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 2.5px solid rgba(255,255,255,0.35) !important;
    flex-shrink: 0 !important;
    display: block !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
    transition: border-color 0.3s ease !important;
}

.imta-chatbot-avatar:hover {
    border-color: rgba(255,255,255,0.6) !important;
}

.imta-chatbot-avatar-default {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255,255,255,0.15) !important;
    color: #fff !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

.imta-chatbot-avatar-default svg {
    width: 22px !important;
    height: 22px !important;
    fill: currentColor !important;
    stroke: none !important;
}

.imta-chatbot-name {
    font-weight: 700 !important;
    font-size: 15px !important;
    letter-spacing: 0.3px !important;
    color: #fff !important;
    line-height: 1.3 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.imta-chatbot-status {
    font-size: 12px !important;
    opacity: 0.92 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    color: #fff !important;
    line-height: 1.3 !important;
    font-weight: 400 !important;
}

.imta-chatbot-status-dot {
    width: 8px !important;
    height: 8px !important;
    min-width: 8px !important;
    border-radius: 50% !important;
    background: #4ade80 !important;
    display: inline-block !important;
    animation: imta-cb-blink 1.8s ease-in-out infinite !important;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6) !important;
}

@keyframes imta-cb-blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(74, 222, 128, 0.6); }
    50% { opacity: 0.4; box-shadow: 0 0 2px rgba(74, 222, 128, 0.2); }
}

.imta-chatbot-close-btn {
    background: rgba(255,255,255,0.12) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.25s, transform 0.2s !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
}

.imta-chatbot-close-btn:hover {
    background: rgba(255,255,255,0.25) !important;
    transform: rotate(90deg) !important;
}

.imta-chatbot-close-btn svg {
    width: 18px !important;
    height: 18px !important;
    stroke: #fff !important;
    fill: none !important;
}

/* =========================================================
   Messages Area — Elevated Design
   ========================================================= */
.imta-chatbot-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 18px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    scroll-behavior: smooth !important;
    background:
        radial-gradient(circle at 20% 80%, rgba(40, 189, 191, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(40, 189, 191, 0.02) 0%, transparent 50%),
        #f8f9fb !important;
    min-height: 0 !important;
}

/* Custom scrollbar — Premium */
.imta-chatbot-messages::-webkit-scrollbar {
    width: 4px !important;
}

.imta-chatbot-messages::-webkit-scrollbar-track {
    background: transparent !important;
}

.imta-chatbot-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #c5cad3, #a8aeb8) !important;
    border-radius: 10px !important;
}

.imta-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #9ca3af, #7d8694) !important;
}

/* Message bubbles */
.imta-chatbot-message {
    max-width: 82% !important;
    padding: 11px 15px !important;
    border-radius: 18px !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    position: relative !important;
    animation: imta-cb-fadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
    display: inline-block !important;
    width: fit-content !important;
    letter-spacing: 0.01em !important;
}

@keyframes imta-cb-fadeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.imta-chatbot-message.bot {
    align-self: flex-start !important;
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--imta-cb-text) !important;
    border-bottom-left-radius: 6px !important;
    margin-right: auto !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

.imta-chatbot-message.user {
    align-self: flex-end !important;
    background: linear-gradient(135deg, var(--imta-cb-primary) 0%, var(--imta-cb-primary-dark) 100%) !important;
    color: var(--imta-cb-msg-user-text) !important;
    border-bottom-right-radius: 6px !important;
    margin-left: auto !important;
    box-shadow: 0 2px 8px rgba(40, 189, 191, 0.25), 0 4px 16px rgba(0, 0, 0, 0.06) !important;
}

.imta-cb-msg-time {
    font-size: 10px !important;
    opacity: 0.5 !important;
    margin-top: 5px !important;
    display: block !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    letter-spacing: 0.3px !important;
}

.imta-chatbot-message.user .imta-cb-msg-time {
    text-align: right !important;
    color: rgba(255,255,255,0.65) !important;
}

/* =========================================================
   Typing Indicator — Neon Glow Dots
   ========================================================= */
.imta-chatbot-typing {
    padding: 2px 16px 8px !important;
    flex-shrink: 0 !important;
    background: transparent !important;
}

.imta-chatbot-typing-bubble {
    display: inline-flex !important;
    gap: 5px !important;
    background: rgba(255, 255, 255, 0.85) !important;
    padding: 12px 18px !important;
    border-radius: 18px !important;
    border-bottom-left-radius: 6px !important;
    border: 1px solid rgba(0, 0, 0, 0.04) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

.imta-chatbot-typing-bubble span {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: var(--imta-cb-primary) !important;
    display: block !important;
    animation: imta-cb-typing 1.4s ease-in-out infinite !important;
    opacity: 0.5 !important;
}

.imta-chatbot-typing-bubble span:nth-child(2) {
    animation-delay: 0.15s !important;
}

.imta-chatbot-typing-bubble span:nth-child(3) {
    animation-delay: 0.3s !important;
}

@keyframes imta-cb-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-8px); opacity: 1; box-shadow: 0 0 8px rgba(40, 189, 191, 0.4); }
}

/* =========================================================
   Input Area — Modern Focus Effects
   ========================================================= */
.imta-chatbot-input-area {
    display: flex !important;
    align-items: flex-end !important;
    gap: 10px !important;
    padding: 12px 14px !important;
    border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
    background: var(--imta-cb-bg) !important;
    flex-shrink: 0 !important;
}

.imta-chatbot-input {
    flex: 1 !important;
    min-width: 0 !important;
    border: 1.5px solid var(--imta-cb-border) !important;
    border-radius: 22px !important;
    padding: 10px 16px !important;
    font-size: 13.5px !important;
    font-family: inherit !important;
    resize: none !important;
    outline: none !important;
    max-height: 80px !important;
    min-height: 40px !important;
    height: 40px !important;
    line-height: 1.4 !important;
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s !important;
    background: #f4f5f7 !important;
    color: var(--imta-cb-text) !important;
    overflow-y: auto !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
}

.imta-chatbot-input:focus {
    border-color: var(--imta-cb-primary) !important;
    background: #fff !important;
    box-shadow: 0 0 0 4px var(--imta-cb-glow) !important;
}

.imta-chatbot-input::placeholder {
    color: #a0a7b4 !important;
    opacity: 1 !important;
    font-weight: 400 !important;
}

/* Ẩn spinner/resize trên textarea */
.imta-chatbot-input::-webkit-inner-spin-button,
.imta-chatbot-input::-webkit-outer-spin-button,
.imta-chatbot-input::-webkit-resizer {
    display: none !important;
    -webkit-appearance: none !important;
    margin: 0 !important;
}

.imta-chatbot-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: 50% !important;
    border: none !important;
    background: linear-gradient(135deg, var(--imta-cb-primary), var(--imta-cb-primary-dark)) !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s, opacity 0.3s !important;
    padding: 0 !important;
    box-shadow: 0 2px 8px rgba(40, 189, 191, 0.3) !important;
}

.imta-chatbot-send-btn svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
    stroke: none !important;
    transition: transform 0.2s ease !important;
}

.imta-chatbot-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--imta-cb-primary-dark), #178385) !important;
    transform: scale(1.12) !important;
    box-shadow: 0 4px 16px rgba(40, 189, 191, 0.45) !important;
}

.imta-chatbot-send-btn:hover:not(:disabled) svg {
    transform: translateX(1px) !important;
}

.imta-chatbot-send-btn:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* =========================================================
   Footer — Premium Branding
   ========================================================= */
.imta-chatbot-footer {
    text-align: center !important;
    padding: 6px 10px !important;
    font-size: 10px !important;
    color: #b0b7c3 !important;
    background: var(--imta-cb-bg) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.04) !important;
    flex-shrink: 0 !important;
    letter-spacing: 0.5px !important;
    font-weight: 500 !important;
}

/* =========================================================
   Welcome message special style
   ========================================================= */
.imta-chatbot-welcome {
    text-align: center !important;
    padding: 8px 0 !important;
}

.imta-chatbot-welcome .imta-chatbot-message {
    max-width: 90% !important;
    background: linear-gradient(135deg, var(--imta-cb-primary-light), rgba(240, 249, 255, 0.9)) !important;
    border: 1px solid rgba(40, 189, 191, 0.12) !important;
    box-shadow: 0 2px 8px rgba(40, 189, 191, 0.08) !important;
}

/* =========================================================
   Responsive Mobile
   ========================================================= */
@media (max-width: 480px) {
    #imta-chatbot-container {
        bottom: 16px !important;
    }

    #imta-chatbot-container.imta-chatbot-right {
        right: 16px !important;
    }

    #imta-chatbot-container.imta-chatbot-left {
        left: 16px !important;
    }

    .imta-chatbot-toggle {
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }

    .imta-chatbot-toggle svg {
        width: 24px !important;
        height: 24px !important;
    }

    .imta-chatbot-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-height: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        z-index: 9999999 !important;
    }
}
