/* ===== Shimko System — FAQ Chatbot Widget ===== */
/* Cross-browser: Chrome, Firefox, Safari, Edge, IE11, Android, iOS */

/* --- Bubble (floating button) --- */
.chatbot-bubble {
    position: fixed;
    bottom: 100px;
    right: 24px;
    height: auto;
    border-radius: 28px;
    background: #0071e3;
    background: -webkit-linear-gradient(315deg, #00d4ff, #0071e3);
    background: linear-gradient(135deg, #00d4ff, #0071e3);
    border: none;
    cursor: pointer;
    z-index: 9990;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 10px 20px;
    -webkit-box-shadow: 0 4px 20px rgba(0, 212, 255, .35);
    box-shadow: 0 4px 20px rgba(0, 212, 255, .35);
    -webkit-transition: -webkit-transform .25s ease, -webkit-box-shadow .25s ease;
    transition: transform .25s ease, box-shadow .25s ease;
    -webkit-tap-highlight-color: transparent;
}

.chatbot-bubble:hover {
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
    -webkit-box-shadow: 0 6px 28px rgba(0, 212, 255, .5);
    box-shadow: 0 6px 28px rgba(0, 212, 255, .5);
}

.chatbot-bubble-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    -o-object-fit: cover;
    object-fit: cover;
    -o-object-position: top;
    object-position: top;
    margin-right: 8px;
    border: 2px solid rgba(255,255,255,.3);
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.chatbot-bubble-label {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.chatbot-bubble svg {
    width: 22px;
    height: 22px;
    fill: #fff;
    -webkit-transition: opacity .2s ease;
    transition: opacity .2s ease;
}

.chatbot-bubble .chatbot-icon-chat {
    width: 20px;
    height: 20px;
    fill: #fff;
    margin-right: 6px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.chatbot-bubble .chatbot-icon-close {
    display: none;
}

.chatbot-bubble.active .chatbot-bubble-label,
.chatbot-bubble.active .chatbot-icon-chat {
    display: none;
}

.chatbot-bubble.active {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.chatbot-bubble.active .chatbot-icon-close {
    display: block;
}

/* --- Floating avatar behind bubble (closed state) --- */
.chatbot-bubble-avatar {
    position: fixed;
    bottom: 128px;
    right: 14px;
    z-index: 9989;
    pointer-events: none;
    -webkit-transition: opacity .3s ease;
    transition: opacity .3s ease;
}

.chatbot-bubble-avatar img {
    width: 140px;
    height: auto;
    border-radius: 22px;
    -webkit-border-radius: 22px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,.4));
    -webkit-filter: drop-shadow(0 4px 12px rgba(0,0,0,.4));
}

.chatbot-bubble-avatar.hidden {
    opacity: 0;
    pointer-events: none;
}

/* --- Chat window --- */
.chatbot-window {
    position: fixed;
    bottom: 164px;
    right: 24px;
    width: 370px;
    max-height: 420px;
    background: #161b25;
    background: var(--color-surface, #161b25);
    border: 1px solid #252d3a;
    border: 1px solid var(--color-border, #252d3a);
    border-radius: 16px;
    z-index: 9989;
    display: none;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    overflow: hidden;
    -webkit-box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}

.chatbot-window.open {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-animation: chatbotSlideUp .25s ease;
    animation: chatbotSlideUp .25s ease;
}

@-webkit-keyframes chatbotSlideUp {
    from {
        opacity: 0;
        -webkit-transform: translateY(16px);
        transform: translateY(16px);
    }

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

@keyframes chatbotSlideUp {
    from {
        opacity: 0;
        -webkit-transform: translateY(16px);
        transform: translateY(16px);
    }

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

/* --- Header --- */
.chatbot-header {
    padding: 14px 16px;
    background: #1c2333;
    background: var(--color-surface-2, #1c2333);
    border-bottom: none;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

.chatbot-header-text {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 0;
}

/* --- Language selector (inside header) --- */
.chatbot-lang-bar {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    margin-left: auto;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.chatbot-lang-btn {
    padding: 4px 6px;
    margin: 0 4px 0 0;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    -webkit-transition: all .2s ease;
    transition: all .2s ease;
    -webkit-tap-highlight-color: transparent;
    opacity: 0.5;
}

.chatbot-lang-btn:last-child {
    margin-right: 0;
}

.chatbot-lang-btn:hover {
    opacity: 1;
    border-color: rgba(0, 212, 255, .3);
}

.chatbot-lang-btn.active {
    opacity: 1;
    background: rgba(0, 212, 255, .15);
    border-color: #00d4ff;
    border-color: var(--color-accent, #00d4ff);
}

/* --- Floating avatar (above/behind chat window) --- */
.chatbot-avatar-float {
    position: fixed;
    display: none;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 9988;
    overflow: visible;
}

.chatbot-avatar-float.open {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-animation: chatbotAvatarIn .35s ease;
    animation: chatbotAvatarIn .35s ease;
}

@-webkit-keyframes chatbotAvatarIn {
    from {
        opacity: 0;
        -webkit-transform: translateY(30px);
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

@keyframes chatbotAvatarIn {
    from {
        opacity: 0;
        -webkit-transform: translateY(30px);
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

.chatbot-avatar-img {
    width: 180px;
    height: auto;
    -o-object-fit: contain;
    object-fit: contain;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    -webkit-transition: opacity .15s ease;
    transition: opacity .15s ease;
    opacity: 1;
    border-radius: 28px;
    -webkit-border-radius: 28px;
    margin-right: 16px;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,.4));
    -webkit-filter: drop-shadow(0 4px 16px rgba(0,0,0,.4));
}

.chatbot-avatar-img.fade {
    opacity: 0;
}

.chatbot-avatar-float.hidden-kb {
    display: none !important;
}

.chatbot-header-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #30d158;
    margin-right: 10px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.chatbot-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f0f2f5;
    color: var(--color-text, #f0f2f5);
}

.chatbot-header-sub {
    font-size: 0.75rem;
    color: #9ba4b0;
    color: var(--color-text-sec, #9ba4b0);
}

/* --- Messages area --- */
.chatbot-messages {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    min-height: 200px;
    max-height: 340px;
    -webkit-overflow-scrolling: touch;
    /* smooth scroll on iOS */
}

.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 10px;
    /* gap fallback */
}

.chatbot-msg:last-child {
    margin-bottom: 0;
}

.chatbot-msg.bot {
    -ms-flex-item-align: start;
    align-self: flex-start;
    background: #1c2333;
    background: var(--color-surface-2, #1c2333);
    color: #f0f2f5;
    color: var(--color-text, #f0f2f5);
    border-bottom-left-radius: 4px;
}

.chatbot-msg.user {
    -ms-flex-item-align: end;
    align-self: flex-end;
    background: #0071e3;
    background: -webkit-linear-gradient(315deg, #00d4ff, #0071e3);
    background: linear-gradient(135deg, #00d4ff, #0071e3);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-msg a {
    color: #00d4ff;
    text-decoration: underline;
}

.chatbot-msg.bot a {
    color: #00d4ff;
}

.chatbot-msg.user a {
    color: #fff;
}

/* --- Quick reply buttons --- */
.chatbot-quick-replies {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    padding: 0 16px 10px;
}

.chatbot-quick-btn {
    padding: 6px 12px;
    margin: 0 6px 6px 0;
    /* gap fallback */
    border-radius: 20px;
    border: 1px solid #252d3a;
    border: 1px solid var(--color-border, #252d3a);
    background: transparent;
    color: #f0f2f5;
    color: var(--color-text, #f0f2f5);
    font-size: 0.8rem;
    cursor: pointer;
    -webkit-transition: all .2s ease;
    transition: all .2s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.chatbot-quick-btn:hover,
.chatbot-quick-btn:active {
    background: #00d4ff;
    background: var(--color-accent, #00d4ff);
    color: #fff;
    border-color: #00d4ff;
    border-color: var(--color-accent, #00d4ff);
}

/* --- Input area --- */
.chatbot-input-area {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid #252d3a;
    border-top: 1px solid var(--color-border, #252d3a);
    background: #1c2333;
    background: var(--color-surface-2, #1c2333);
}

.chatbot-input {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    padding: 8px 14px;
    margin-right: 8px;
    /* gap fallback */
    border-radius: 20px;
    border: 1px solid #252d3a;
    border: 1px solid var(--color-border, #252d3a);
    background: #161b25;
    background: var(--color-surface, #161b25);
    color: #f0f2f5;
    color: var(--color-text, #f0f2f5);
    font-size: 0.88rem;
    outline: none;
    -webkit-transition: border-color .2s ease;
    transition: border-color .2s ease;
    -webkit-appearance: none;
    /* iOS fix */
    -moz-appearance: none;
    appearance: none;
}

.chatbot-input::-webkit-input-placeholder {
    color: #6b7688;
}

.chatbot-input::-moz-placeholder {
    color: #6b7688;
    opacity: 1;
}

.chatbot-input:-ms-input-placeholder {
    color: #6b7688;
}

.chatbot-input::placeholder {
    color: #6b7688;
}

.chatbot-input:focus {
    border-color: #00d4ff;
    border-color: var(--color-accent, #00d4ff);
}

.chatbot-send {
    width: 36px;
    height: 36px;
    min-width: 36px;
    /* prevent shrink */
    border-radius: 50%;
    border: none;
    background: #0071e3;
    background: -webkit-linear-gradient(315deg, #00d4ff, #0071e3);
    background: linear-gradient(135deg, #00d4ff, #0071e3);
    cursor: pointer;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    -webkit-transition: -webkit-transform .2s ease;
    transition: transform .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.chatbot-send:hover {
    -webkit-transform: scale(1.08);
    transform: scale(1.08);
}

.chatbot-send svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* --- Typing indicator --- */
.chatbot-typing {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    padding: 10px 14px;
    -ms-flex-item-align: start;
    align-self: flex-start;
    background: #1c2333;
    background: var(--color-surface-2, #1c2333);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    margin-bottom: 10px;
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    margin-right: 4px;
    /* gap fallback */
    border-radius: 50%;
    background: #9ba4b0;
    background: var(--color-text-sec, #9ba4b0);
    -webkit-animation: chatbotTyping .8s infinite;
    animation: chatbotTyping .8s infinite;
}

.chatbot-typing span:last-child {
    margin-right: 0;
}

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

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

@-webkit-keyframes chatbotTyping {

    0%,
    100% {
        opacity: .3;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        -webkit-transform: translateY(-3px);
        transform: translateY(-3px);
    }
}

@keyframes chatbotTyping {

    0%,
    100% {
        opacity: .3;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        -webkit-transform: translateY(-3px);
        transform: translateY(-3px);
    }
}

/* --- Scrollbar (WebKit/Blink) --- */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #252d3a;
    background: var(--color-border, #252d3a);
    border-radius: 4px;
}

/* --- Firefox scrollbar --- */
.chatbot-messages {
    scrollbar-width: thin;
    scrollbar-color: #252d3a transparent;
}

/* --- Tablet --- */
@media (max-width: 768px) {
    .chatbot-avatar-img {
        width: 140px;
    }
}

/* --- Mobile backdrop overlay --- */
.chatbot-overlay {
    display: none;
}

/* --- Mobile (phones) --- */
@media (max-width: 480px) {
    .chatbot-overlay.active {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 9987;
        -webkit-backdrop-filter: blur(6px);
        backdrop-filter: blur(6px);
        -webkit-animation: chatbotFadeIn .25s ease;
        animation: chatbotFadeIn .25s ease;
    }

    @-webkit-keyframes chatbotFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    @keyframes chatbotFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .chatbot-window {
        right: 16px;
        left: 16px;
        bottom: 156px;
        width: auto;
        max-height: 55vh;
    }

    .chatbot-bubble {
        bottom: 92px;
        right: 12px;
        padding: 5px 12px 5px 5px;
    }

    .chatbot-bubble-img {
        width: 52px;
        height: 52px;
    }

    .chatbot-bubble-avatar {
        bottom: 120px;
        right: 4px;
    }

    .chatbot-bubble-avatar img {
        width: 100px;
    }

    .chatbot-bubble-label {
        font-size: 0.78rem;
    }

    .chatbot-bubble.active {
        width: 44px;
        height: 44px;
    }

    .chatbot-messages {
        max-height: 45vh;
    }

    .chatbot-input {
        font-size: 16px;
        /* prevent iOS zoom on focus */
    }

    .chatbot-avatar-img {
        width: 110px;
    }
}

/* --- Tablet --- */
@media (min-width: 481px) and (max-width: 768px) {
    .chatbot-window {
        width: 340px;
    }
}

/* --- Safe area (iPhone X+ notch) --- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chatbot-bubble {
        bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .chatbot-input-area {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    @media (max-width: 480px) {
        .chatbot-bubble {
            bottom: calc(92px + env(safe-area-inset-bottom));
        }

        .chatbot-window {
            bottom: calc(156px + env(safe-area-inset-bottom));
        }
    }
}