/* ==========================================================================
   KMCH Enquiry Chatbot – Front-end Styles
   ========================================================================== */

/* ── Launcher button ──────────────────────────────────────────────────────── */
#kmch-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 62px;
    height: 62px;
    background: #1a3c8f;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(26, 60, 143, .45);
    z-index: 99999;
    transition: transform .2s ease, box-shadow .2s ease;
    outline: none;
}

#kmch-launcher:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 24px rgba(26, 60, 143, .55);
}

#kmch-launcher img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 4px;
}

/* Unread badge */
#kmch-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 20px;
    height: 20px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    align-items: center;
    justify-content: center;
}

/* ── Chat window ──────────────────────────────────────────────────────────── */
#kmch-chatbot {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 360px;
    max-height: 580px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    z-index: 99998;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    transition: opacity .25s ease, transform .25s ease;
}

#kmch-chatbot.kmch-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px) scale(.97);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#kmch-header {
    background: #1a3c8f;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#kmch-header .kmch-logo {
    height: 40px;
    width: auto;
    border-radius: 6px;
    background: #fff;
    padding: 3px;
    flex-shrink: 0;
}

.kmch-header-info {
    flex: 1;
    min-width: 0;
}

.kmch-hname {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kmch-hstatus {
    color: rgba(255, 255, 255, .75);
    font-size: 11px;
    margin-top: 2px;
}

.kmch-hstatus::before {
    content: '●';
    color: #4ade80;
    margin-right: 4px;
    font-size: 9px;
}

#kmch-minimize {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, .75);
    font-size: 22px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}

#kmch-minimize:hover {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

/* ── Chat body ────────────────────────────────────────────────────────────── */
#kmch-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f7fb;
    scroll-behavior: smooth;
}

#kmch-body::-webkit-scrollbar {
    width: 4px;
}

#kmch-body::-webkit-scrollbar-track {
    background: transparent;
}

#kmch-body::-webkit-scrollbar-thumb {
    background: #d0d5e0;
    border-radius: 4px;
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.kmch-msg {
    display: flex;
    flex-direction: column;
    max-width: 84%;
    animation: kmchFadeUp .2s ease;
}

@keyframes kmchFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.kmch-msg.bot  { align-self: flex-start; }
.kmch-msg.user { align-self: flex-end;   }

.kmch-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.55;
    word-break: break-word;
}

.bot .kmch-bubble {
    background: #fff;
    color: #222;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, .08);
}

.user .kmch-bubble {
    background: #1a3c8f;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.kmch-meta {
    font-size: 10px;
    color: #b0b8c8;
    margin-top: 4px;
    line-height: 1;
}

.bot  .kmch-meta { padding-left: 4px; }
.user .kmch-meta { align-self: flex-end; padding-right: 4px; }

/* ── Typing indicator ─────────────────────────────────────────────────────── */
.kmch-typing .kmch-bubble {
    padding: 12px 18px;
}

.kmch-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.kmch-dots span {
    width: 7px;
    height: 7px;
    background: #b0bec5;
    border-radius: 50%;
    animation: kmchBounce 1.2s infinite;
}

.kmch-dots span:nth-child(2) { animation-delay: .18s; }
.kmch-dots span:nth-child(3) { animation-delay: .36s; }

@keyframes kmchBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-7px); }
}

/* ── Option buttons ───────────────────────────────────────────────────────── */
.kmch-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: flex-start;
    width: 100%;
    max-width: 290px;
    animation: kmchFadeUp .2s ease;
}

.kmch-opt-btn {
    background: #fff;
    border: 1.5px solid #1a3c8f;
    color: #1a3c8f;
    border-radius: 24px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    text-align: center;
    transition: background .15s ease, color .15s ease;
    width: 100%;
    line-height: 1.3;
}

.kmch-opt-btn:hover,
.kmch-opt-btn.kmch-selected {
    background: #1a3c8f;
    color: #fff;
}

.kmch-opt-btn:disabled {
    cursor: default;
    opacity: .7;
}

/* ── Footer / input ───────────────────────────────────────────────────────── */
#kmch-footer {
    border-top: 1px solid #e8ecf2;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    background: #fff;
}

#kmch-input {
    flex: 1;
    border: 1.5px solid #dce1ea;
    border-radius: 24px;
    padding: 9px 14px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
    color: #222;
    background: #f9fafc;
}

#kmch-input:focus {
    border-color: #1a3c8f;
    background: #fff;
}

#kmch-input::placeholder {
    color: #aab0bf;
}

#kmch-send {
    background: #1a3c8f;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    flex-shrink: 0;
    outline: none;
}

#kmch-send:hover   { background: #0f2a6b; }
#kmch-send:disabled { background: #b0bec5; cursor: default; }

#kmch-send svg {
    width: 15px;
    height: 15px;
    display: block;
}

/* ── Powered-by strip ─────────────────────────────────────────────────────── */
#kmch-powered {
    background: #fff;
    text-align: center;
    font-size: 10px;
    color: #c5cbd8;
    padding: 4px 0 8px;
    flex-shrink: 0;
}

/* ── Mobile adjustments ───────────────────────────────────────────────────── */
@media (max-width: 420px) {
    #kmch-chatbot {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 90px;
        border-radius: 14px;
    }

    #kmch-launcher {
        right: 16px;
        bottom: 16px;
        width: 56px;
        height: 56px;
    }
}
