/* ════════════════════════════════════════════════
   PKA CHATBOT — chatbot.css
   Design đồng bộ với style.css + manager.css
   White + Blue Gradient · Be Vietnam Pro
════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=Be+Vietnam+Pro:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ══════════════════════════════════════════════
   HERO
══════════════════════════════════════════════ */
.chatbot-hero {
    position: relative;
    padding: 130px 0 60px;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 55% at 65% -10%, rgba(96, 165, 250, .20) 0%, transparent 58%),
        radial-gradient(ellipse 50% 45% at 5% 90%, rgba(14, 165, 233, .12) 0%, transparent 55%),
        linear-gradient(170deg, #f0f7ff 0%, #ffffff 55%, #f8faff 100%);
}

.chatbot-hero-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(37, 99, 235, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, .04) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 25%, transparent 78%);
    pointer-events: none;
}

.chatbot-hero-orb-1 {
    position: absolute;
    width: 420px;
    height: 420px;
    right: -80px;
    top: -90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(96, 165, 250, .17) 0%, rgba(37, 99, 235, .06) 50%, transparent 70%);
    animation: floatA 14s ease-in-out infinite;
    pointer-events: none;
}

.chatbot-hero-orb-2 {
    position: absolute;
    width: 240px;
    height: 240px;
    left: -60px;
    bottom: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14, 165, 233, .11) 0%, transparent 65%);
    animation: floatB 18s ease-in-out infinite 2s;
    pointer-events: none;
}

.chatbot-hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.chatbot-hero h1 {
    font-size: clamp(2rem, 4.5vw, 3rem);
    font-weight: 900;
    color: var(--text);
    letter-spacing: -.03em;
    line-height: 1.13;
    margin-bottom: 14px;
}

.chatbot-hero h1 .grad {
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chatbot-hero-sub {
    color: var(--muted);
    font-size: .95rem;
    max-width: 500px;
    margin: 0 auto 0;
    line-height: 1.75;
}

/* ══════════════════════════════════════════════
   CHAT SECTION
══════════════════════════════════════════════ */
.chat-section {
    padding: 40px 0 80px;
    background: var(--bg2);
    min-height: 60vh;
}

.chat-wrapper {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── CHAT WINDOW ── */
.chat-window {
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
    box-shadow: 0 4px 32px rgba(37, 99, 235, .10);
}

.chat-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(37, 99, 235, .06) 0%, rgba(14, 165, 233, .03) 100%);
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.chat-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-bot-avatar {
    width: 40px;
    height: 40px;
    background: var(--grad);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .28);
}

.chat-bot-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-bot-name {
    font-size: .92rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.01em;
}

.chat-bot-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    color: var(--muted);
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, .22);
    animation: pulseDot 2s ease-in-out infinite;
}

.status-dot.thinking {
    background: var(--orange);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, .22);
}

@keyframes pulseDot {

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

    50% {
        transform: scale(1.3);
        opacity: .7;
    }
}

.chat-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-action-btn {
    width: 32px;
    height: 32px;
    background: var(--bg2);
    border: 1.5px solid var(--border2);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .18s;
    font-family: inherit;
}

.chat-action-btn:hover {
    background: var(--bg3);
    border-color: var(--border3);
    color: var(--primary);
}

/* ── MESSAGES AREA ── */
.chat-messages {
    height: 480px;
    overflow-y: auto;
    padding: 20px 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

/* ── MESSAGE BUBBLE ── */
.msg {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: msgIn .28s cubic-bezier(.4, 0, .2, 1) both;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.msg.user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .72rem;
    font-weight: 800;
}

.msg.bot .msg-avatar {
    background: var(--grad);
    color: #fff;
    box-shadow: 0 3px 10px rgba(37, 99, 235, .22);
}

.msg.user .msg-avatar {
    background: var(--bg3);
    border: 1.5px solid var(--border2);
    color: var(--muted);
}

.msg-bubble {
    max-width: 72%;
    border-radius: 16px;
    padding: 11px 16px;
    font-size: .88rem;
    line-height: 1.7;
    position: relative;
}

.msg.bot .msg-bubble {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text2);
    border-bottom-left-radius: 4px;
}

.msg.user .msg-bubble {
    background: var(--grad);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(37, 99, 235, .22);
}

/* Markdown-like rendering */
.msg-bubble p {
    margin: 0 0 8px;
}

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

.msg-bubble strong {
    font-weight: 700;
}

.msg-bubble em {
    font-style: italic;
}

.msg-bubble code {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8em;
    background: rgba(37, 99, 235, .08);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(37, 99, 235, .14);
}

.msg.user .msg-bubble code {
    background: rgba(255, 255, 255, .2);
    border-color: rgba(255, 255, 255, .25);
}

.msg-bubble pre {
    background: rgba(15, 23, 42, .06);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: .78rem;
    line-height: 1.6;
}

.msg-bubble ul,
.msg-bubble ol {
    padding-left: 20px;
    margin: 6px 0;
}

.msg-bubble li {
    margin-bottom: 3px;
}

.msg-time {
    font-size: .65rem;
    color: var(--faint);
    margin-top: 5px;
    padding: 0 2px;
    text-align: left;
}

.msg.user .msg-time {
    text-align: right;
}

/* ── TYPING INDICATOR ── */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.typing-dots {
    display: flex;
    gap: 5px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--faint);
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}

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

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

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
        background: var(--primary);
    }
}

/* ── WELCOME STATE ── */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 32px 20px;
    text-align: center;
    flex: 1;
}

.chat-welcome-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(37, 99, 235, .08) 0%, rgba(14, 165, 233, .06) 100%);
    border: 1.5px solid var(--border2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.chat-welcome h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.01em;
}

.chat-welcome p {
    font-size: .83rem;
    color: var(--muted);
    max-width: 380px;
    line-height: 1.65;
    margin: 0;
}

/* Suggestion chips */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: center;
    margin-top: 6px;
}

.suggestion-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .77rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(37, 99, 235, .07);
    border: 1px solid rgba(37, 99, 235, .18);
    border-radius: 20px;
    padding: 6px 13px;
    cursor: pointer;
    font-family: inherit;
    transition: all .18s;
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--grad);
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, .22);
}

/* ── CHAT INPUT BAR ── */
.chat-input-bar {
    background: var(--card);
    border: 1px solid var(--border2);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 14px 16px 16px;
    box-shadow: 0 4px 32px rgba(37, 99, 235, .10);
}

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg2);
    border: 1.5px solid var(--border2);
    border-radius: 12px;
    padding: 10px 12px;
    transition: border-color .2s, box-shadow .2s;
}

.chat-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
    background: var(--card);
}

#chatInput {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: .9rem;
    color: var(--text);
    line-height: 1.6;
    resize: none;
    max-height: 160px;
    min-height: 24px;
    overflow-y: auto;
}

#chatInput::placeholder {
    color: var(--faint);
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    background: var(--grad);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .18s, transform .18s, box-shadow .18s;
    box-shadow: 0 3px 12px rgba(37, 99, 235, .28);
}

.chat-send-btn:hover:not(:disabled) {
    opacity: .9;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, .32);
}

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

.chat-input-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding: 0 4px;
}

.hint-text {
    font-size: .69rem;
    color: var(--faint);
}

.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .68rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 20px;
    padding: 3px 9px;
    font-family: 'JetBrains Mono', monospace;
}

/* ── ERROR BANNER ── */
.chat-error {
    background: rgba(239, 68, 68, .06);
    border: 1px solid rgba(239, 68, 68, .18);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: .82rem;
    color: #b91c1c;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 20px 12px;
    animation: msgIn .2s ease both;
}

/* ── STREAMING CURSOR ── */
.stream-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary);
    border-radius: 1px;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink .7s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ── INFO CARDS ── */
.chatbot-info-section {
    padding: 60px 0 80px;
    background: var(--bg);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.info-card {
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    padding: 24px 22px;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}

.info-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(37, 99, 235, .10);
    border-color: var(--border3, rgba(37, 99, 235, .35));
}

.info-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.info-icon-blue {
    background: rgba(37, 99, 235, .09);
    color: var(--primary);
}

.info-icon-teal {
    background: rgba(14, 165, 233, .09);
    color: var(--teal);
}

.info-icon-green {
    background: rgba(16, 185, 129, .09);
    color: var(--green);
}

.info-card h3 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.info-card p {
    font-size: .82rem;
    color: var(--muted);
    line-height: 1.7;
    margin: 0;
}

/* ── ANIMATIONS ── */
@keyframes floatA {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    33% {
        transform: translateY(-12px) rotate(1deg);
    }

    66% {
        transform: translateY(-5px) rotate(-1deg);
    }
}

@keyframes floatB {

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

    40% {
        transform: translateY(-16px) rotate(-1deg);
    }

    75% {
        transform: translateY(-7px) rotate(1deg);
    }
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .chatbot-hero {
        padding: 110px 0 40px;
    }

    .chat-section {
        padding: 24px 0 60px;
    }

    .chat-wrapper {
        margin: 0 12px;
    }

    .chat-messages {
        height: 420px;
        padding: 16px 14px 10px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .msg-bubble {
        max-width: 82%;
    }

    .chat-input-hint {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .chatbot-hero h1 {
        font-size: 1.75rem;
        text-align: left;
    }

    .chatbot-hero-sub {
        text-align: left;
        margin-left: 0;
        margin-right: 0;
    }

    /* Chat window sát viền, bỏ margin để fullwidth */
    .chat-wrapper {
        margin: 0;
    }

    .chat-window {
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-right: none;
    }

    .chat-input-bar {
        border-left: none;
        border-right: none;
        border-radius: 0 0 16px 16px;
        padding: 10px 12px 16px;
    }

    /* Messages area */
    .chat-messages {
        height: calc(100svh - 420px);
        min-height: 260px;
        max-height: 400px;
        padding: 12px 10px 8px;
        gap: 12px;
    }

    /* Topbar gọn hơn */
    .chat-topbar {
        padding: 10px 12px;
    }

    .chat-bot-avatar {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .chat-bot-name {
        font-size: .85rem;
    }

    /* Bubble width cân với avatar 32px + gap 10px */
    .msg-bubble {
        max-width: 78%;
        padding: 9px 13px;
        font-size: .85rem;
    }

    /* Avatar nhỏ hơn chút */
    .msg-avatar {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        font-size: .65rem;
    }

    /* Input wrap */
    .chat-input-wrap {
        padding: 8px 10px;
        gap: 8px;
    }

    #chatInput {
        font-size: .85rem;
    }

    .chat-send-btn {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }

    /* Hint bar — ẩn text gợi ý, chỉ giữ badge model */
    .hint-text {
        display: none;
    }

    .chat-input-hint {
        justify-content: flex-end;
        margin-top: 6px;
    }

    /* Suggestion chips — scroll ngang thay vì wrap */
    .chat-suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        gap: 6px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .chat-suggestions::-webkit-scrollbar {
        display: none;
    }

    .suggestion-chip {
        font-size: .72rem;
        padding: 5px 11px;
        flex-shrink: 0;
    }

    /* Info grid */
    .info-grid {
        grid-template-columns: 1fr;
    }
}