/* ═══════════════════════════════════════════════════════════════════════════
   KsSeed AI Chatbot — Premium Widget Styles
   File: public/css/chatbot.css
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --ks-green: #2E7D32;
    --ks-green-dark: #1B5E20;
    --ks-green-light: #66BB6A;
    --ks-green-pale: #E8F5E9;
    --ks-green-mid: #A5D6A7;
    --ks-green-border: #C8E6C9;
    --ks-radius: 20px;
    --ks-radius-sm: 14px;
    --ks-radius-xs: 8px;
    --ks-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    --ks-shadow-fab: 0 4px 20px rgba(46, 125, 50, 0.40);
}

/* ── Reset inside widget ─────────────────────────────────────────────────── */
.chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   FAB — Floating Action Button
   ══════════════════════════════════════════════════════════════════════════ */
.chat-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* Tooltip */
.chat-widget-tooltip {
    background: #1B5E20;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
    align-self: center;
}

.chat-widget:not(.active):hover .chat-widget-tooltip {
    opacity: 1;
    transform: translateY(0);
}

/* FAB button */
.chat-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--ks-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--ks-shadow-fab);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.22s ease,
        background 0.2s;
    flex-shrink: 0;
}

.chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(46, 125, 50, 0.55);
}

/* Pulse ring — only when widget is closed */
.chat-button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--ks-green-light);
    animation: ksPulse 2.2s ease-out infinite;
}

.chat-widget.active .chat-button::before {
    display: none;
}

@keyframes ksPulse {
    0% {
        transform: scale(1);
        opacity: 0.75;
    }

    100% {
        transform: scale(1.7);
        opacity: 0;
    }
}

/* Notification badge */
.chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #E53935;
    border-radius: 50%;
    border: 2.5px solid #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}

.chat-widget.active .chat-badge {
    opacity: 0;
    transform: scale(0);
}

/* Bot icon SVG inside FAB */
.chat-icon-svg,
.chat-close-icon {
    position: absolute;
    transition: opacity 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-icon-svg {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.chat-close-icon {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

.chat-widget.active .chat-icon-svg {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.chat-widget.active .chat-close-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* ══════════════════════════════════════════════════════════════════════════
   Chat Window
   ══════════════════════════════════════════════════════════════════════════ */
.chat-box {
    width: 380px;
    background: #fff;
    border-radius: var(--ks-radius);
    border: 0.5px solid var(--ks-green-border);
    box-shadow: var(--ks-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(0.97);
    transform-origin: bottom right;
    transition: height 0s 0.3s, opacity 0.28s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
    max-height: 620px;
}

.chat-widget.active .chat-box {
    height: 620px;
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
    transition: height 0s, opacity 0.28s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* ── Chat Header ────────────────────────────────────────────────────────── */
.chat-header {
    background: var(--ks-green);
    padding: 15px 16px 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-avatar-circle {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: #69F0AE;
    border-radius: 50%;
    border: 2px solid var(--ks-green);
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-info h4 {
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
}

.chat-header-info p {
    color: rgba(255, 255, 255, 0.72);
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    margin: 2px 0 0;
}

.chat-header-actions {
    display: flex;
    gap: 6px;
}

.chat-hdr-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.88);
    font-size: 16px;
    transition: background 0.15s;
    line-height: 1;
}

.chat-hdr-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* ── Messages Area ──────────────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #FAFAFA;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--ks-green-border);
    border-radius: 4px;
}

/* ── Welcome Card ───────────────────────────────────────────────────────── */
.chat-welcome-card {
    background: #fff;
    border: 0.5px solid var(--ks-green-border);
    border-radius: var(--ks-radius-sm);
    padding: 15px;
    animation: ksMsgIn 0.3s ease;
}

.chat-welcome-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.chat-welcome-emoji {
    font-size: 19px;
}

.chat-welcome-title {
    font-family: 'Poppins', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ks-green-dark);
}

.chat-welcome-body {
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    color: #444;
    line-height: 1.7;
    margin-bottom: 0;
}

/* ── Message bubbles ────────────────────────────────────────────────────── */
.chat-message-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    animation: ksMsgIn 0.25s ease;
}

.chat-message-wrap.user {
    align-items: flex-end;
}

.chat-message-wrap.bot {
    align-items: flex-start;
}

@keyframes ksMsgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.chat-message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ks-green);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message p {
    padding: 10px 14px;
    border-radius: 16px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
    max-width: 240px;
    margin: 0;
}

.chat-message.bot p {
    background: #fff;
    color: #2a2a2a;
    border: 0.5px solid #E0E0E0;
    border-bottom-left-radius: 4px;
}

.chat-message.user p {
    background: var(--ks-green);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Bold in messages */
.chat-message p strong {
    font-weight: 600;
}

/* Timestamp — always outside the bubble, no background */
.chat-msg-time {
    font-family: 'Poppins', sans-serif;
    font-size: 10px;
    color: #BDBDBD;
    background: transparent !important;
    padding: 0 4px;
    line-height: 1;
    display: block;
}

.chat-msg-time.bot {
    padding-left: 38px;
}

.chat-msg-time.user {
    padding-right: 4px;
}

/* ── Typing indicator ───────────────────────────────────────────────────── */
.chat-typing p {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 14px;
    margin: 0;
}

.chat-typing .dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ks-green-mid);
    animation: ksDotBounce 1.2s infinite ease-in-out;
}

.chat-typing .dot:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-typing .dot:nth-child(3) {
    animation-delay: 0.30s;
}

@keyframes ksDotBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Suggestion chips (follow-ups) ─────────────────────────────────────── */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 2px 2px;
}

.chat-chip {
    background: #fff;
    color: var(--ks-green-dark);
    border: 0.5px solid var(--ks-green-mid);
    border-radius: 14px;
    padding: 5px 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    line-height: 1.3;
}

.chat-chip:hover {
    background: var(--ks-green-pale);
    border-color: var(--ks-green);
    transform: translateY(-1px);
}

/* ── Input Area ─────────────────────────────────────────────────────────── */
.chat-input {
    padding: 12px 12px 14px;
    border-top: 0.5px solid #E8F5E9;
    background: #fff;
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #F5F5F5;
    border-radius: 26px;
    padding: 7px 7px 7px 15px;
    border: 1px solid #E0E0E0;
    transition: border-color 0.2s, background 0.2s;
    width: 100%;
}

.chat-input-row:focus-within {
    border-color: var(--ks-green-mid);
    background: #fff;
}

.chat-input input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    color: #2a2a2a;
}

.chat-input input::placeholder {
    color: #BDBDBD;
}

.chat-input input:disabled {
    opacity: 0.6;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ks-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--ks-green-dark);
    transform: scale(1.06);
}

.chat-send-btn:active {
    transform: scale(0.96);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}



/* ══════════════════════════════════════════════════════════════════════════
   Mobile
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-box {
        width: calc(100vw - 32px);
        max-height: 80vh;
    }

    .chat-widget.active .chat-box {
        height: 80vh;
    }
}