/* 9OSTech LLM Search — Dark Chat UI Redesign */

:root {
    --ostech-primary: #20B24B;
    --ostech-primary-hover: #1a9a3f;
    --ostech-primary-light: rgba(32,178,75,0.12);
    --ostech-primary-dark: #177e35;
    --ostech-dark: #0d0d1a;
    --ostech-dark-2: #13131f;
    --ostech-dark-3: #1a1a2e;
    --ostech-dark-4: #1e1e32;
    --ostech-border: rgba(255,255,255,0.08);
    --ostech-border-bright: rgba(255,255,255,0.14);
    --ostech-text: rgba(255,255,255,0.82);
    --ostech-text-muted: rgba(255,255,255,0.45);
    --ostech-white: #ffffff;
    --ostech-radius: 14px;
    --ostech-radius-lg: 18px;
    --ostech-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ============================================================
   INLINE SHORTCODE: DARK CHAT WIDGET
   ============================================================ */

.ostech-chat-widget {
    width: 100%;
    max-width: 560px;
    background: rgba(13,13,26,0.92);
    border: 1px solid var(--ostech-border-bright);
    border-radius: var(--ostech-radius-lg);
    box-shadow:
        0 32px 80px rgba(0,0,0,0.6),
        0 0 0 1px rgba(255,255,255,0.04),
        inset 0 1px 0 rgba(255,255,255,0.07);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--ostech-font);
    position: relative;
}

/* green ambient top glow */
.ostech-chat-widget::before {
    content: '';
    position: absolute;
    top: -1px; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--ostech-primary) 50%, transparent 100%);
    opacity: 0.6;
    pointer-events: none;
}

/* ── Header ── */
.ostech-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ostech-border);
    flex-shrink: 0;
}

.ostech-chat-agent {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ostech-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a2e, #252540);
    border: 1.5px solid var(--ostech-border-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.ostech-chat-avatar img,
.ostech-chat-avatar svg {
    width: 22px;
    height: 22px;
    color: rgba(255,255,255,0.5);
}

.ostech-chat-agent-name {
    font-size: 0.87rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.ostech-chat-agent-sub {
    font-size: 0.7rem;
    color: var(--ostech-text-muted);
    margin-top: 1px;
}

.ostech-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ostech-primary);
    letter-spacing: 0.04em;
}

.ostech-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ostech-primary);
    box-shadow: 0 0 6px var(--ostech-primary);
    animation: ostechDotPulse 2s ease-in-out infinite;
}

@keyframes ostechDotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ── Chat Body: message thread ── */
.ostech-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    /* Fixed height — answers scroll within */
    min-height: 320px;
    max-height: 420px;
    scroll-behavior: smooth;
}

.ostech-chat-body::-webkit-scrollbar {
    width: 4px;
}
.ostech-chat-body::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.03);
}
.ostech-chat-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

/* AI Message row */
.ostech-msg-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

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

.ostech-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a2e, #252540);
    border: 1px solid var(--ostech-border-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.ostech-msg-avatar svg {
    width: 15px;
    height: 15px;
    color: rgba(255,255,255,0.45);
}

.ostech-msg-bubble {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--ostech-border);
    border-radius: 4px 14px 14px 14px;
    padding: 12px 16px;
    max-width: calc(100% - 50px);
    font-size: 0.87rem;
    line-height: 1.7;
    color: var(--ostech-text);
}

.ostech-msg-row.user-row .ostech-msg-bubble {
    background: rgba(32,178,75,0.12);
    border-color: rgba(32,178,75,0.25);
    border-radius: 14px 4px 14px 14px;
    color: rgba(255,255,255,0.9);
}

/* Response content formatting */
.ostech-msg-bubble h3 {
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: #fff !important;
    margin: 16px 0 8px !important;
}
.ostech-msg-bubble h3:first-child { margin-top: 0; }
.ostech-msg-bubble h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    margin: 12px 0 6px;
}
.ostech-msg-bubble p { margin: 8px 0; }
.ostech-msg-bubble p:first-child { margin-top: 0; }
.ostech-msg-bubble p:last-child { margin-bottom: 0; }
.ostech-msg-bubble ul, .ostech-msg-bubble ol {
    margin: 8px 0;
    padding-left: 18px;
}
.ostech-msg-bubble li {
    margin: 6px 0;
    line-height: 1.6;
}
.ostech-msg-bubble li::marker { color: var(--ostech-primary); }
.ostech-msg-bubble strong { color: #fff; font-weight: 600; }
.ostech-msg-bubble a {
    color: var(--ostech-primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(32,178,75,0.3);
    transition: border-color 0.2s;
}
.ostech-msg-bubble a:hover { border-color: var(--ostech-primary); }

/* Typing / streaming cursor */
.ostech-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--ostech-primary);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: ostechBlink 0.9s ease-in-out infinite;
}
@keyframes ostechBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Loading dots */
.ostech-typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 2px;
}
.ostech-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ostech-primary);
    opacity: 0.4;
    animation: ostechDot 1.2s ease-in-out infinite;
}
.ostech-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ostech-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ostechDot {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* ── Suggestion chips ── */
.ostech-chat-suggestions {
    padding: 0 16px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    border-top: 1px solid var(--ostech-border);
    padding-top: 12px;
}

.ostech-sug-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 20px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--ostech-border);
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: var(--ostech-font);
    white-space: nowrap;
}
.ostech-sug-chip svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: rgba(255,255,255,0.3);
}
.ostech-sug-chip:hover {
    background: rgba(32,178,75,0.12);
    border-color: rgba(32,178,75,0.3);
    color: rgba(255,255,255,0.9);
}
.ostech-sug-chip:hover svg { color: var(--ostech-primary); }

/* ── Input row ── */
.ostech-chat-input-row {
    padding: 12px 14px;
    border-top: 1px solid var(--ostech-border);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.25);
    flex-shrink: 0;
}

.ostech-chat-input {
    flex: 1;
    background: none;
    border: none !important;
    outline: none !important;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    font-family: var(--ostech-font);
    padding: 4px 0 !important;
    box-shadow: none !important;
}
.ostech-chat-input::placeholder { color: rgba(255,255,255,0.28); }

.ostech-chat-send {
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    background: rgba(32,178,75,0.15) !important;
    border: 1px solid rgba(32,178,75,0.3) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #20B24B !important;
    transition: all 0.18s ease !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
}
.ostech-chat-send:hover {
    background: #20B24B !important;
    border-color: #20B24B !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(32,178,75,0.35) !important;
}
.ostech-chat-send svg { width: 15px !important; height: 15px !important; stroke: currentColor !important; fill: none !important; }

/* ── Footer ── */
.ostech-chat-footer {
    padding: 9px 20px 12px;
    border-top: 1px solid var(--ostech-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ostech-chat-footer-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}
.ostech-chat-footer-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.18s ease;
    font-family: var(--ostech-font);
    padding: 0;
}
.ostech-chat-footer-btn:hover,
.ostech-chat-footer-btn:focus,
.ostech-chat-footer-btn:focus-visible,
.ostech-chat-footer-btn:active,
.ostech-chat-footer-btn:visited {
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    color: rgba(255,255,255,0.75) !important;
}
.ostech-chat-footer-btn svg { width: 12px; height: 12px; }
.ostech-chat-powered {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    gap: 5px;
}
.ostech-chat-powered svg { width: 10px; height: 10px; color: var(--ostech-primary); }

/* ============================================================
   POPUP MODAL (triggered from floating button)
   ============================================================ */

.ostech-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ostechFadeIn 0.25s ease;
}

.ostech-popup-overlay.active { display: flex; }

@keyframes ostechFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ostech-popup-chat {
    width: 520px;           /* wider */
    max-height: 85vh;
    animation: ostechSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ostechSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ostech-popup-chat .ostech-chat-widget {
    max-width: 100%;
    max-height: 85vh;
}

.ostech-popup-chat .ostech-chat-body {
    min-height: 280px;
    max-height: 55vh;
}

/* Close button on popup */
.ostech-popup-close {
    display: none; /* handled by header close */
}

/* ============================================================
   FLOATING BUTTON (site-wide)
   ============================================================ */

.ostech-float-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.ostech-float-btn-canvas-wrap {
    width: 62px;
    height: 62px;
    position: relative;
    transition: transform 0.3s ease;
}

.ostech-float-btn-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50%;
}

.ostech-float-btn:hover .ostech-float-btn-canvas-wrap {
    transform: scale(1.08);
}

.ostech-float-btn-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: var(--ostech-font);
    transition: color 0.2s ease;
    user-select: none;
}

.ostech-float-btn:hover .ostech-float-btn-label {
    color: rgba(255,255,255,0.75);
}

/* Sources in popup */
.ostech-sources-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--ostech-border);
}
.ostech-sources-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ostech-source-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    margin: 4px 4px 0 0;
    font-size: 0.77rem;
    color: var(--ostech-primary);
    background: rgba(32,178,75,0.08);
    border: 1px solid rgba(32,178,75,0.2);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}
.ostech-source-item:hover {
    background: rgba(32,178,75,0.18);
    border-color: rgba(32,178,75,0.4);
}

/* Error state in chat */
.ostech-chat-error {
    padding: 10px 14px;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 10px;
    color: rgba(255,150,150,0.9);
    font-size: 0.83rem;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 600px) {
    .ostech-popup-overlay {
        padding: 0 0 90px 0;
        align-items: flex-end;
        justify-content: center;
    }
    .ostech-popup-chat {
        width: 100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
    .ostech-chat-body { max-height: 45vh; }
    .ostech-float-btn { bottom: 20px; right: 18px; }
}
