/* ===== CHAT WIDGET ===== */
#chat-fab {
    position: fixed;
    bottom: 2rem; right: 2rem;
    width: 58px; height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg,#00d4ff,#0096cc);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #050e1d;
    box-shadow: 0 4px 20px rgba(0,212,255,.45);
    z-index: 2000;
    transition: transform .2s, box-shadow .2s;
}
#chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,212,255,.6); }
#chat-fab .chat-badge {
    position: absolute; top: -4px; right: -4px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #22c55e; border: 2px solid #050e1d;
    font-size: .6rem; font-weight: 700; color: #fff;
    display: flex; align-items: center; justify-content: center;
}

/* ── Panel — default (compact) ── */
#chat-panel {
    position: fixed;
    bottom: 6.5rem; right: 2rem;
    width: 380px;
    height: 540px;
    background: #0a1628;
    border: 1px solid rgba(0,212,255,.2);
    border-radius: 16px;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 40px rgba(0,212,255,.08);
    z-index: 1999;
    transform: translateY(20px) scale(.96);
    opacity: 0;
    pointer-events: none;
    transition: all .28s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
#chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ── Panel — expanded ── */
#chat-panel.expanded {
    width: min(720px, 92vw);
    height: min(82vh, 780px);
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%) scale(1);
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0,0,0,.75), 0 0 60px rgba(0,212,255,.12);
}
#chat-panel.expanded.open {
    transform: translate(50%, 50%) scale(1);
}

/* Backdrop overlay for expanded mode */
#chat-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(5,14,29,.7);
    backdrop-filter: blur(4px);
    z-index: 1998;
    animation: fadeIn .25s ease;
}
#chat-backdrop.visible { display: block; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* ── Header ── */
.chat-header {
    padding: 1rem 1.25rem;
    background: #0f2240;
    border-bottom: 1px solid rgba(0,212,255,.14);
    display: flex; align-items: center; gap: .75rem;
    flex-shrink: 0;
}
.chat-header-icon {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg,#00d4ff,#0096cc);
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem; color: #050e1d; flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-title { font-size: .88rem; font-weight: 700; color: #fff; }
.chat-header-sub { font-size: .72rem; color: #94a3b8; display: flex; align-items: center; gap: .35rem; }
.chat-header-sub .dot { width:7px; height:7px; border-radius:50%; background:#22c55e; box-shadow:0 0 6px #22c55e; }

.chat-header-actions { display: flex; align-items: center; gap: .25rem; flex-shrink: 0; }
.chat-expand,
.chat-close {
    background: none; border: none; color: #64748b;
    font-size: 1rem; cursor: pointer; padding: .3rem .35rem;
    line-height: 1; border-radius: 6px; transition: color .2s, background .2s;
}
.chat-expand:hover,
.chat-close:hover { color: #fff; background: rgba(255,255,255,.06); }

/* ── Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(0,212,255,.25); border-radius:2px; }

.msg {
    max-width: 88%;
    padding: .7rem 1rem;
    border-radius: 12px;
    font-size: .85rem;
    line-height: 1.6;
    animation: msgIn .2s ease;
    word-break: break-word;
}
@keyframes msgIn { from { opacity:0; transform:translateY(6px); } }

.msg.assistant {
    align-self: flex-start;
    background: #0f2240;
    border: 1px solid rgba(0,212,255,.14);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}
.msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg,#00d4ff,#0096cc);
    color: #050e1d;
    font-weight: 500;
    border-bottom-right-radius: 4px;
}

/* ── Markdown elements inside assistant messages ── */
.msg.assistant strong { color: #fff; font-weight: 700; }
.msg.assistant em { color: #94a3b8; font-style: italic; }

.msg-heading {
    display: block;
    color: #fff;
    font-weight: 700;
    font-size: .87rem;
    margin: .5rem 0 .25rem;
    padding-bottom: .25rem;
    border-bottom: 1px solid rgba(0,212,255,.15);
}

.msg-bullet {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: .3rem;
    margin: .2rem 0;
    align-items: baseline;
}
.msg-bdot {
    color: #00d4ff;
    font-size: .7rem;
    padding-top: .15rem;
    line-height: 1.6;
    user-select: none;
}
.msg-bnum {
    font-size: .78rem;
    font-weight: 600;
    color: #00d4ff;
    white-space: nowrap;
}

/* ── Typing indicator ── */
.typing-indicator {
    align-self: flex-start;
    background: #0f2240;
    border: 1px solid rgba(0,212,255,.14);
    border-radius: 12px; border-bottom-left-radius: 4px;
    padding: .65rem .9rem;
    display: flex; gap: .35rem; align-items: center;
}
.typing-indicator span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #00d4ff; opacity: .5;
    animation: bounce .9s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100%{transform:scale(.8);opacity:.4} 40%{transform:scale(1.1);opacity:1} }

/* ── Contact form ── */
.chat-contact-form {
    padding: .75rem 1rem;
    background: #0f2240;
    border-top: 1px solid rgba(0,212,255,.14);
    flex-shrink: 0;
}
.chat-contact-form p {
    font-size: .75rem; color: #94a3b8; margin-bottom: .6rem; text-align:center;
}
.chat-contact-form .cf-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-bottom: .4rem;
}
.chat-contact-form input {
    width: 100%; padding: .4rem .65rem;
    background: #162d4a; border: 1px solid rgba(0,212,255,.2);
    border-radius: 6px; color: #e2e8f0; font-size: .78rem;
    outline: none; transition: border-color .2s;
    font-family: 'Inter', sans-serif;
}
.chat-contact-form input:focus { border-color: rgba(0,212,255,.5); }
.chat-contact-form input::placeholder { color: #64748b; }
.chat-contact-form .cf-full { grid-column: 1/-1; }
.cf-submit {
    width: 100%; padding: .45rem;
    background: linear-gradient(135deg,#00d4ff,#0096cc);
    border: none; border-radius: 6px;
    color: #050e1d; font-weight: 700; font-size: .8rem;
    cursor: pointer; transition: opacity .2s;
    font-family: 'Inter', sans-serif;
}
.cf-submit:hover { opacity: .88; }
.cf-thanks { text-align:center; font-size:.8rem; color:#22c55e; padding:.35rem 0; }

/* ── Input area ── */
.chat-input-area {
    padding: .75rem 1rem;
    background: #0f2240;
    border-top: 1px solid rgba(0,212,255,.14);
    display: flex; gap: .5rem; align-items: center;
    flex-shrink: 0;
}
#chat-input {
    flex: 1; padding: .55rem .85rem;
    background: #162d4a; border: 1px solid rgba(0,212,255,.2);
    border-radius: 8px; color: #e2e8f0; font-size: .85rem;
    outline: none; resize: none; height: 38px;
    transition: border-color .2s;
    font-family: 'Inter', sans-serif;
}
#chat-input:focus { border-color: rgba(0,212,255,.5); }
#chat-input::placeholder { color: #64748b; }
#chat-send {
    width: 38px; height: 38px; border-radius: 8px; flex-shrink:0;
    background: linear-gradient(135deg,#00d4ff,#0096cc);
    border: none; cursor: pointer; color: #050e1d; font-size: .95rem;
    display: flex; align-items: center; justify-content: center;
    transition: opacity .2s, transform .2s;
}
#chat-send:hover { opacity:.88; transform:scale(1.05); }
#chat-send:disabled { opacity:.4; cursor:not-allowed; transform:none; }

/* ── Footer note ── */
.chat-footer-note {
    text-align: center; font-size: .65rem; color: #64748b;
    padding: .3rem 1rem .5rem;
    background: #0f2240;
    flex-shrink: 0;
}
.chat-footer-note a { color: #00d4ff; text-decoration:none; }

/* ── Responsive ── */
@media(max-width:480px){
    #chat-panel {
        width: calc(100vw - 2rem);
        right: 1rem;
        bottom: 5.5rem;
        height: 480px;
    }
    #chat-panel.expanded {
        width: 100vw; height: 100dvh;
        bottom: 0; right: 0;
        border-radius: 0;
        transform: none !important;
    }
    #chat-fab { bottom:1rem; right:1rem; }
}
