/* KuberPlus AI Advisor Free — Floating Popup */

/* ── Launcher ── */
#kpfai-launcher {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    left: auto !important;
    z-index: 2147483646 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: linear-gradient(135deg, #1a7a4a 0%, #155f39 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 12px 20px 12px 14px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    cursor: pointer !important;
    box-shadow: 0 4px 20px rgba(26,122,74,0.40) !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    line-height: 1 !important;
    margin: 0 !important;
    top: auto !important;
}
#kpfai-launcher:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 28px rgba(26,122,74,0.50) !important;
}
.kpfai-launcher-badge {
    position: absolute;
    top: -3px; right: -3px;
    width: 11px; height: 11px;
    background: #f0c040;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: kpfai-pulse 2s ease-in-out infinite;
}
@keyframes kpfai-pulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.35); opacity: 0.7; }
}
.kpfai-launcher-icon  { font-size: 19px; line-height: 1; }
.kpfai-launcher-label { font-size: 14px; font-weight: 600; color: #fff; }

/* ── Popup window ── */
#kpfai-popup {
    position: fixed !important;
    bottom: 84px !important;
    right: 24px !important;
    left: auto !important;
    z-index: 2147483647 !important;
    width: 360px !important;
    max-width: calc(100vw - 32px) !important;
    height: 520px !important;
    max-height: calc(100vh - 120px) !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18) !important;
    border: 1.5px solid #d0e8da !important;
    background: #ffffff !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(16px) scale(0.96) !important;
    transition: opacity 0.22s ease, transform 0.22s ease !important;
    margin: 0 !important;
    padding: 0 !important;
    top: auto !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}
#kpfai-popup.kpfai-open {
    opacity: 1 !important;
    pointer-events: all !important;
    transform: translateY(0) scale(1) !important;
}

/* ── Header ── */
.kpfai-header {
    background: linear-gradient(135deg, #1a7a4a 0%, #155f39 100%);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}
.kpfai-logo { font-size: 22px; line-height: 1; }
.kpfai-header-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.kpfai-header-text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpfai-header-text span   { font-size: 10px; opacity: 0.75; margin-top: 1px; }
.kpfai-status  { font-size: 10px; color: #f0c040; font-weight: 600; white-space: nowrap; }
.kpfai-close-btn {
    background: rgba(255,255,255,0.18);
    border: none; color: #fff;
    width: 26px; height: 26px;
    border-radius: 50%; cursor: pointer;
    font-size: 14px; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s; flex-shrink: 0;
}
.kpfai-close-btn:hover { background: rgba(255,255,255,0.30); }

/* ── Messages ── */
.kpfai-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 11px;
    background: #f7faf8;
    display: flex;
    flex-direction: column;
    gap: 9px;
    scroll-behavior: smooth;
}
.kpfai-messages::-webkit-scrollbar       { width: 3px; }
.kpfai-messages::-webkit-scrollbar-track { background: transparent; }
.kpfai-messages::-webkit-scrollbar-thumb { background: #d0e8da; border-radius: 3px; }

.kpfai-msg { display: flex; animation: kpfai-fadein 0.2s ease; }
.kpfai-msg--user { justify-content: flex-end; }
.kpfai-msg--assistant { justify-content: flex-start; }

@keyframes kpfai-fadein {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.kpfai-bubble {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}
.kpfai-msg--assistant .kpfai-bubble {
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid #d0e8da;
    border-bottom-left-radius: 4px;
}
.kpfai-msg--user .kpfai-bubble {
    background: #1a7a4a;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Quick reply chips */
.kpfai-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.kpfai-chip {
    background: #e8f5e9;
    color: #1a5c35;
    border: 1px solid #b2dfce;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.kpfai-chip:hover { background: #c8e6c9; }

/* Table inside bubble */
.kpfai-table { border-collapse: collapse; width: 100%; font-size: 11px; margin: 6px 0; }
.kpfai-table th, .kpfai-table td {
    border: 1px solid #d0e8da;
    padding: 4px 7px;
    text-align: left;
}
.kpfai-table th { background: #e8f5e9; font-weight: 600; }

/* Bullet / numbered spans */
.kpfai-bullet, .kpfai-num { display: block; padding-left: 8px; }

/* ── Typing ── */
.kpfai-typing {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 5px 12px 2px;
    background: #f7faf8;
    flex-shrink: 0;
}
.kpfai-typing.kpfai-visible { display: flex; }
.kpfai-typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #1a7a4a;
    opacity: 0.4;
    animation: kpfai-bounce 1.2s ease-in-out infinite;
}
.kpfai-typing span:nth-child(2) { animation-delay: 0.18s; }
.kpfai-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes kpfai-bounce {
    0%,60%,100% { transform: translateY(0); opacity: 0.4; }
    30%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Input ── */
.kpfai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    padding: 9px 10px;
    border-top: 1px solid #d0e8da;
    background: #fff;
    flex-shrink: 0;
}
.kpfai-input {
    flex: 1;
    border: 1.5px solid #d0e8da;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 80px;
    overflow-y: auto;
    transition: border-color 0.2s;
    line-height: 1.45;
    color: #1a1a1a;
    background: #f7faf8;
    box-sizing: border-box;
}
.kpfai-input:focus { border-color: #1a7a4a; background: #fff; }
.kpfai-input::placeholder { color: #5a6a62; font-size: 12px; }

.kpfai-send-btn {
    background: #1a7a4a;
    color: #fff;
    border: none;
    border-radius: 9px;
    width: 36px; height: 36px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}
.kpfai-send-btn:hover  { background: #155f39; }
.kpfai-send-btn:active { transform: scale(0.93); }
.kpfai-send-btn:disabled { background: #a0bba8; cursor: not-allowed; }

/* ── Footer ── */
.kpfai-footer {
    background: #fffbea;
    border-top: 1px solid #f0d980;
    padding: 5px 11px;
    text-align: center;
    flex-shrink: 0;
}
.kpfai-footer small { font-size: 10px; color: #7a6010; }

/* ── Mobile ── */
@media (max-width: 420px) {
    #kpfai-popup   { width: calc(100vw - 16px) !important; right: 8px !important; bottom: 76px !important; }
    #kpfai-launcher { right: 12px !important; bottom: 12px !important; }
}

/* ── Language toggle button ── */
.kpfai-lang-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.30);
    color: #fff;
    border-radius: 20px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
}
.kpfai-lang-btn:hover { background: rgba(255,255,255,0.28); }

/* ── Lang switching fade ── */
.kpfai-messages.kpfai-fade { opacity: 0.4; transition: opacity 0.15s; }
.kpfai-messages { transition: opacity 0.15s; }
