/* Keneng Consulting AI Chatbot — Turkstech Innovations */
.kc-chatbot {
    --kc-primary: #0B2545;
    --kc-accent: #C9A227;
    --kc-wa: #25D366;
    --kc-wa-dark: #128C7E;
    --kc-bg: #F6F7F9;
    --kc-text: #1B2430;
    --kc-muted: #6B7483;
    --kc-border: #E3E6EB;
    --kc-radius: 16px;
    --kc-inline-h: 600px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--kc-text);
    box-sizing: border-box;
}
.kc-chatbot *, .kc-chatbot *::before, .kc-chatbot *::after { box-sizing: border-box; }
.kc-chatbot svg { width: 20px; height: 20px; display: block; }
.kc-chatbot button { font: inherit; cursor: pointer; }

/* Launcher */
.kc-mode-float { position: fixed; bottom: 22px; z-index: 2147483000; }
.kc-pos-right { right: 22px; }
.kc-pos-left { left: 22px; }

.kc-launcher {
    width: 60px; height: 60px; border-radius: 50%; border: 0;
    background: var(--kc-primary); color: #fff;
    box-shadow: 0 10px 28px rgba(11, 37, 69, .35);
    display: grid; place-items: center; position: relative;
    transition: transform .2s ease, box-shadow .2s ease;
}
.kc-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(11, 37, 69, .42); }
.kc-launcher::after {
    content: ""; position: absolute; top: 4px; right: 4px; width: 12px; height: 12px;
    border-radius: 50%; background: var(--kc-accent); border: 2px solid #fff;
}
.kc-open .kc-launcher::after { display: none; }
.kc-launcher .kc-ico { position: absolute; display: grid; place-items: center; transition: opacity .2s, transform .25s; }
.kc-launcher svg { width: 28px; height: 28px; }
.kc-ico-close { opacity: 0; transform: rotate(-90deg); }
.kc-open .kc-ico-open { opacity: 0; transform: rotate(90deg); }
.kc-open .kc-ico-close { opacity: 1; transform: rotate(0); }

/* Window */
.kc-window {
    display: flex; flex-direction: column; overflow: hidden;
    background: #fff; border-radius: var(--kc-radius);
    box-shadow: 0 24px 60px rgba(16, 24, 40, .22);
}
.kc-mode-float .kc-window {
    position: absolute; bottom: 76px; width: 380px;
    height: min(620px, calc(100vh - 120px));
    opacity: 0; visibility: hidden; transform: translateY(14px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.kc-pos-right .kc-window { right: 0; }
.kc-pos-left .kc-window { left: 0; transform-origin: bottom left; }
.kc-open .kc-window { opacity: 1; visibility: visible; transform: none; }

.kc-mode-inline { position: relative; }
.kc-mode-inline .kc-window { height: var(--kc-inline-h); border: 1px solid var(--kc-border); box-shadow: 0 8px 30px rgba(16, 24, 40, .08); }

/* Header */
.kc-header {
    display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 16px;
    background: var(--kc-primary); color: #fff; flex-shrink: 0;
    border-bottom: 3px solid var(--kc-accent);
}
.kc-avatar {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    background: var(--kc-accent); color: var(--kc-primary);
    display: grid; place-items: center; font-weight: 800; font-size: 18px; letter-spacing: -.5px;
}
.kc-title { flex: 1; min-width: 0; }
.kc-title strong { display: block; font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kc-title span { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kc-dot { width: 7px; height: 7px; border-radius: 50%; background: #3DDC84; flex-shrink: 0; }
.kc-hactions { display: flex; gap: 4px; }
.kc-hbtn {
    width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent;
    color: #fff; display: grid; place-items: center; text-decoration: none; transition: background .15s;
}
.kc-hbtn:hover, .kc-hbtn:focus-visible { background: rgba(255, 255, 255, .14); color: #fff; }
.kc-hbtn svg { width: 19px; height: 19px; }
.kc-header .kc-wa-link svg { width: 21px; height: 21px; color: var(--kc-wa); }
.kc-back { display: none; }

/* Messages */
.kc-messages {
    flex: 1; overflow-y: auto; padding: 18px 14px 8px; background: var(--kc-bg);
    display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.kc-msg { max-width: 86%; padding: 10px 14px; border-radius: 14px; word-wrap: break-word; animation: kcIn .2s ease; }
.kc-msg p { margin: 0 0 8px; }
.kc-msg p:last-child { margin-bottom: 0; }
.kc-msg ul, .kc-msg ol { margin: 4px 0 8px; padding-left: 20px; }
.kc-msg li { margin: 2px 0; }
.kc-msg a { color: inherit; text-decoration: underline; }
.kc-bot { align-self: flex-start; background: #fff; border: 1px solid var(--kc-border); border-bottom-left-radius: 4px; }
.kc-bot a { color: var(--kc-primary); font-weight: 600; }
.kc-user { align-self: flex-end; background: var(--kc-primary); color: #fff; border-bottom-right-radius: 4px; }
.kc-error { border-color: #F2C4C4; background: #FFF6F6; }

.kc-typing { display: flex; gap: 5px; padding: 14px 16px; }
.kc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--kc-muted); opacity: .4; animation: kcDot 1.2s infinite; }
.kc-typing span:nth-child(2) { animation-delay: .15s; }
.kc-typing span:nth-child(3) { animation-delay: .3s; }

/* WhatsApp hand-off */
.kc-handoff { align-self: flex-start; animation: kcIn .25s ease; }
.kc-wa-btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
    background: var(--kc-wa); color: #fff !important; font-weight: 600; font-size: 14px; text-decoration: none !important;
    transition: background .15s;
}
.kc-wa-btn:hover { background: var(--kc-wa-dark); }
.kc-wa-btn svg { width: 18px; height: 18px; }

/* Chips */
.kc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; background: var(--kc-bg); }
.kc-chips[hidden] { display: none; }
.kc-chip {
    border: 1px solid var(--kc-primary); background: #fff; color: var(--kc-primary);
    border-radius: 999px; padding: 6px 12px; font-size: 13px; line-height: 1.3; transition: all .15s;
}
.kc-chip:hover { background: var(--kc-primary); color: #fff; }

/* Input */
.kc-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--kc-border); background: #fff; flex-shrink: 0; margin: 0; }
.kc-input textarea {
    flex: 1; resize: none; border: 1px solid var(--kc-border); border-radius: 12px;
    padding: 10px 12px; font: inherit; font-size: 16px; /* 16px prevents iOS zoom */
    line-height: 1.4; max-height: 120px; min-height: 42px; outline: none; background: var(--kc-bg); color: var(--kc-text);
    box-shadow: none; margin: 0;
}
.kc-input textarea:focus { border-color: var(--kc-primary); background: #fff; }
.kc-send {
    width: 42px; height: 42px; border-radius: 12px; border: 0; flex-shrink: 0;
    background: var(--kc-primary); color: #fff; display: grid; place-items: center; transition: opacity .15s;
}
.kc-send:disabled { opacity: .45; cursor: default; }

/* Footer */
.kc-footer { padding: 0 12px 10px; background: #fff; text-align: center; flex-shrink: 0; }
.kc-wa-bar {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px; margin-bottom: 6px; border-radius: 10px; background: #EAF9F0;
    color: var(--kc-wa-dark) !important; font-size: 13px; font-weight: 600; text-decoration: none !important;
}
.kc-wa-bar:hover { background: #D9F4E4; }
.kc-wa-bar svg { width: 18px; height: 18px; color: var(--kc-wa); }
.kc-footer small { display: block; font-size: 11px; color: var(--kc-muted); }

@keyframes kcIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes kcDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Mobile: full-screen takeover */
@media (max-width: 600px) {
    .kc-mode-float { bottom: 16px; }
    .kc-pos-right { right: 16px; }
    .kc-pos-left { left: 16px; }
    .kc-launcher { width: 56px; height: 56px; }
    .kc-open .kc-launcher { display: none; }

    .kc-mode-float .kc-window {
        position: fixed; inset: 0; top: 0; left: 0; right: 0; bottom: auto;
        width: 100vw; height: 100vh; height: 100dvh; border-radius: 0;
        transform: translateY(100%); transform-origin: bottom center;
        transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility .28s, opacity .1s;
        box-shadow: none;
    }
    .kc-open .kc-window { transform: translateY(0); }
    .kc-mode-float .kc-header { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-left: 8px; }
    .kc-mode-float .kc-back { display: grid; }
    .kc-mode-float .kc-close { display: none; }
    .kc-mode-float .kc-footer { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .kc-msg, .kc-handoff { max-width: 90%; }
}
html.kc-lock, html.kc-lock body { overflow: hidden !important; height: 100% !important; overscroll-behavior: none; }

@media (prefers-reduced-motion: reduce) {
    .kc-chatbot * { animation: none !important; transition: none !important; }
}
