/* =============================================================================
   HoopPixels AI — Public / Frontend Styles
   Version: 2.0.0
   ============================================================================= */

:root {
    --hpai-primary: #6366f1;
    --hpai-primary-dark: #4f46e5;
    --hpai-primary-light: #e0e7ff;
    --hpai-bg: #ffffff;
    --hpai-surface: #f8fafc;
    --hpai-border: #e2e8f0;
    --hpai-text: #1e293b;
    --hpai-text-muted: #64748b;
    --hpai-radius: 20px;
    --hpai-radius-bubble: 18px;
    --hpai-shadow: 0 4px 24px rgba(0,0,0,.12);
    --hpai-shadow-bubble: 0 8px 32px rgba(99,102,241,.30);
    --hpai-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --hpai-z: 99999;
    --hpai-chat-width: 400px;
    --hpai-chat-height: 580px;
}

/* ── Floating bubble ─────────────────────────────────────────────────────── */

.hpai-chatbot-container {
    position: fixed;
    z-index: var(--hpai-z);
    font-family: var(--hpai-font);
}
.hpai-pos-bottom-right { bottom: 24px; right: 24px; }
.hpai-pos-bottom-left  { bottom: 24px; left:  24px; }

/* Toggle button */
.hpai-toggle-btn {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--hpai-shadow-bubble);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    position: relative;
    z-index: 2;
}
.hpai-toggle-btn:hover { transform: scale(1.08); box-shadow: 0 10px 36px rgba(99,102,241,.40); }
.hpai-toggle-btn svg { width: 28px; height: 28px; fill: #fff; transition: opacity .2s, transform .2s; }
.hpai-toggle-btn .hpai-icon-chat  { opacity: 1; transform: scale(1); }
.hpai-toggle-btn .hpai-icon-close { opacity: 0; transform: scale(.5); position: absolute; }
.hpai-chatbot-container.hpai-open .hpai-icon-chat  { opacity: 0; transform: scale(.5); }
.hpai-chatbot-container.hpai-open .hpai-icon-close { opacity: 1; transform: scale(1);  }

/* Unread badge */
.hpai-badge {
    position: absolute;
    top: -2px; right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity .2s;
}
.hpai-badge.hpai-visible { opacity: 1; animation: hpai-pulse 2s infinite; }

@keyframes hpai-pulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* ── Chat Window ─────────────────────────────────────────────────────────── */

.hpai-chat-window {
    position: absolute;
    bottom: 72px;
    width: var(--hpai-chat-width);
    height: var(--hpai-chat-height);
    background: var(--hpai-bg);
    border-radius: var(--hpai-radius);
    box-shadow: var(--hpai-shadow);
    border: 1px solid var(--hpai-border);
    display: flex; flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(.92) translateY(12px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s cubic-bezier(.34,1.56,.64,1);
}
.hpai-pos-bottom-right .hpai-chat-window { right: 0; }
.hpai-pos-bottom-left  .hpai-chat-window { left:  0; }
.hpai-chatbot-container.hpai-open .hpai-chat-window {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.hpai-chat-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.hpai-chat-avatar {
    width: 40px; height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.hpai-chat-header-info { flex: 1; }
.hpai-chat-header-name { font-weight: 700; font-size: 15px; }
.hpai-chat-header-status {
    font-size: 12px; opacity: .85;
    display: flex; align-items: center; gap: 5px;
}
.hpai-status-dot {
    width: 7px; height: 7px;
    background: #4ade80; border-radius: 50%;
    animation: hpai-pulse 2s infinite;
}
.hpai-chat-header-actions { display: flex; gap: 6px; }
.hpai-header-btn {
    background: rgba(255,255,255,.15);
    border: none; border-radius: 8px;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #fff; font-size: 14px;
    transition: background .2s;
}
.hpai-header-btn:hover { background: rgba(255,255,255,.25); }

/* Mode tabs */
.hpai-mode-tabs {
    display: flex;
    padding: 10px 12px;
    gap: 6px;
    background: var(--hpai-surface);
    border-bottom: 1px solid var(--hpai-border);
    flex-shrink: 0;
}
.hpai-mode-tab {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 50px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--hpai-text-muted);
    cursor: pointer;
    transition: all .2s;
    font-family: var(--hpai-font);
}
.hpai-mode-tab.hpai-active {
    background: var(--hpai-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,.30);
}
.hpai-mode-tab:hover:not(.hpai-active) { background: #e2e8f0; color: var(--hpai-text); }

/* Messages area */
.hpai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.hpai-messages::-webkit-scrollbar { width: 4px; }
.hpai-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* Message bubbles */
.hpai-message { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.hpai-message.hpai-user  { flex-direction: row-reverse; }
.hpai-message-avatar {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    background: var(--hpai-primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.hpai-message.hpai-user .hpai-message-avatar { background: #dbeafe; }
.hpai-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--hpai-radius-bubble);
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}
.hpai-message.hpai-assistant .hpai-message-bubble {
    background: var(--hpai-surface);
    border: 1px solid var(--hpai-border);
    color: var(--hpai-text);
    border-bottom-left-radius: 4px;
}
.hpai-message.hpai-user .hpai-message-bubble {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.hpai-message-time { font-size: 10px; opacity: .6; margin-top: 4px; }
.hpai-message.hpai-user .hpai-message-time { text-align: right; }

/* Image messages */
.hpai-image-message img {
    max-width: 100%;
    border-radius: 12px;
    display: block;
    margin-top: 4px;
    cursor: zoom-in;
}
.hpai-image-caption { font-size: 12px; opacity: .7; margin-top: 6px; font-style: italic; }

/* Typing indicator */
.hpai-typing .hpai-message-bubble {
    background: var(--hpai-surface);
    border: 1px solid var(--hpai-border);
    padding: 14px 18px;
}
.hpai-typing-dots { display: flex; gap: 4px; align-items: center; }
.hpai-typing-dots span {
    width: 7px; height: 7px;
    background: var(--hpai-text-muted);
    border-radius: 50%;
    animation: hpai-typing .8s infinite;
}
.hpai-typing-dots span:nth-child(2) { animation-delay: .15s; }
.hpai-typing-dots span:nth-child(3) { animation-delay: .30s; }

@keyframes hpai-typing {
    0%,60%,100% { transform: translateY(0);    opacity: .4; }
    30%          { transform: translateY(-5px); opacity: 1;  }
}

/* Welcome card */
.hpai-welcome {
    background: linear-gradient(135deg, #f0f0ff, #e8e4ff);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 4px;
}
.hpai-welcome h3 { margin: 0 0 6px; font-size: 15px; color: var(--hpai-primary); }
.hpai-welcome p  { margin: 0 0 12px; font-size: 13px; color: var(--hpai-text-muted); }
.hpai-suggestions { display: flex; flex-direction: column; gap: 6px; }
.hpai-suggestion {
    background: #fff;
    border: 1px solid var(--hpai-border);
    border-radius: 50px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: all .2s;
    color: var(--hpai-text);
    font-family: var(--hpai-font);
}
.hpai-suggestion:hover { background: var(--hpai-primary-light); border-color: var(--hpai-primary); color: var(--hpai-primary); }

/* Markdown styling inside bubbles */
.hpai-message-bubble strong { font-weight: 700; }
.hpai-message-bubble em     { font-style: italic; }
.hpai-message-bubble code   {
    background: rgba(0,0,0,.07);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}
.hpai-message.hpai-user .hpai-message-bubble code { background: rgba(255,255,255,.2); }
.hpai-message-bubble ul, .hpai-message-bubble ol { margin: 6px 0; padding-left: 20px; }
.hpai-message-bubble li { margin-bottom: 3px; }
.hpai-message-bubble p  { margin: 0 0 6px; }
.hpai-message-bubble p:last-child { margin-bottom: 0; }

/* Image generator panel */
.hpai-image-panel { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.hpai-image-panel label { font-size: 12px; font-weight: 600; color: var(--hpai-text-muted); }
.hpai-image-panel select {
    border: 1.5px solid var(--hpai-border);
    border-radius: 50px;
    padding: 8px 14px;
    font-size: 13px;
    background: #fff;
    color: var(--hpai-text);
    font-family: var(--hpai-font);
    width: 100%;
}
.hpai-image-preview {
    background: var(--hpai-surface);
    border-radius: 12px;
    border: 2px dashed var(--hpai-border);
    min-height: 160px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: var(--hpai-text-muted);
    overflow: hidden;
}
.hpai-image-preview img { width: 100%; border-radius: 10px; }

/* Input area */
.hpai-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--hpai-border);
    background: var(--hpai-bg);
    flex-shrink: 0;
}
.hpai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--hpai-surface);
    border: 1.5px solid var(--hpai-border);
    border-radius: 16px;
    padding: 8px 8px 8px 14px;
    transition: border-color .2s;
}
.hpai-input-row:focus-within { border-color: var(--hpai-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.hpai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    font-family: var(--hpai-font);
    color: var(--hpai-text);
    resize: none;
    max-height: 100px;
    min-height: 22px;
    outline: none;
    line-height: 1.5;
}
.hpai-chat-input::placeholder { color: #94a3b8; }
.hpai-send-btn {
    width: 36px; height: 36px;
    border-radius: 12px;
    background: var(--hpai-primary);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}
.hpai-send-btn:hover { background: var(--hpai-primary-dark); transform: scale(1.05); }
.hpai-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.hpai-send-btn svg { width: 16px; height: 16px; fill: #fff; }
.hpai-input-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 6px; padding: 0 2px;
}
.hpai-input-hint { font-size: 11px; color: #94a3b8; }
.hpai-powered { font-size: 11px; color: #94a3b8; }
.hpai-powered a { color: #94a3b8; text-decoration: none; font-weight: 600; }
.hpai-powered a:hover { color: var(--hpai-primary); }

/* Embed mode */
.hooppixels-ai-embed {
    font-family: var(--hpai-font);
    border-radius: var(--hpai-radius);
    border: 1px solid var(--hpai-border);
    overflow: hidden;
    box-shadow: var(--hpai-shadow);
    display: flex; flex-direction: column;
}
.hooppixels-ai-embed .hpai-chat-window {
    position: static;
    width: 100%;
    height: 100%;
    opacity: 1;
    transform: none;
    pointer-events: all;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Toast notifications */
.hpai-toast {
    position: fixed;
    bottom: 100px; right: 24px;
    background: #1e293b;
    color: #fff;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    z-index: calc(var(--hpai-z) + 1);
    animation: hpai-slide-up .3s ease;
}
@keyframes hpai-slide-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Lightbox */
.hpai-lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.85);
    z-index: calc(var(--hpai-z) + 10);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
    animation: hpai-fade-in .2s ease;
}
.hpai-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 12px; }
@keyframes hpai-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Responsive */
@media (max-width: 480px) {
    :root { --hpai-chat-width: calc(100vw - 32px); --hpai-chat-height: 70vh; }
    .hpai-chatbot-container { right: 16px !important; left: auto !important; bottom: 16px !important; }
}
