/* ==========================================================================
   HD WEB AI CHAT ASSISTANT STYLES
   ========================================================================== */

:root {
    --chat-primary: #64ffda;
    --chat-gold: #ffb703;
    --chat-bg: #0a192f;
    --chat-surface: #112240;
    --chat-border: rgba(100, 255, 218, 0.2);
    --chat-text: #ccd6f6;
    --chat-text-muted: #8892b0;
}

/* Floating Trigger Button */
.ai-chat-trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #112240 0%, #0a192f 100%);
    border: 2px solid var(--chat-primary);
    padding: 8px 18px 8px 10px;
    border-radius: 50px;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(100, 255, 218, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-trigger:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 30px rgba(100, 255, 218, 0.5);
    border-color: #ffffff;
}

.ai-trigger-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #020c1b;
    border: 2px solid var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.ai-trigger-avatar img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

.ai-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #00f59b;
    border: 2px solid #0a192f;
    border-radius: 50%;
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 245, 155, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(0, 245, 155, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 245, 155, 0); }
}

.ai-trigger-label {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.ai-trigger-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-trigger-sub {
    font-size: 0.75rem;
    color: var(--chat-primary);
    font-family: 'Fira Code', monospace;
}

/* Chat Window Box */
.ai-chat-window {
    position: fixed;
    bottom: 95px;
    right: 28px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #0a192f;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(100, 255, 218, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(16px);
}

.ai-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.ai-chat-header {
    background: linear-gradient(135deg, #112240 0%, #0d1e38 100%);
    padding: 16px 20px;
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-header-info h4 {
    font-size: 1.05rem;
    color: #ffffff;
    margin: 0;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-header-info p {
    font-size: 0.78rem;
    color: var(--chat-primary);
    margin: 2px 0 0 0;
    font-family: 'Fira Code', monospace;
}

.ai-header-actions {
    display: flex;
    gap: 8px;
}

.ai-header-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--chat-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-header-btn:hover {
    background: var(--chat-primary);
    color: #0a192f;
    border-color: var(--chat-primary);
}

/* Chat Body / Messages Area */
.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.ai-chat-body::-webkit-scrollbar {
    width: 5px;
}

.ai-chat-body::-webkit-scrollbar-thumb {
    background: rgba(100, 255, 218, 0.2);
    border-radius: 4px;
}

/* Chat Bubble Messages */
.ai-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: fadeInMsg 0.3s ease;
}

@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-msg.bot {
    align-self: flex-start;
}

.ai-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #020c1b;
    border: 1px solid var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-msg-avatar img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.ai-msg-content {
    background: #112240;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 16px;
    border-radius: 16px;
    color: var(--chat-text);
    font-size: 0.9rem;
    line-height: 1.5;
}

.ai-msg.bot .ai-msg-content {
    border-top-left-radius: 4px;
    background: #112240;
}

.ai-msg.user .ai-msg-content {
    border-top-right-radius: 4px;
    background: linear-gradient(135deg, #1d3557 0%, #152a48 100%);
    border-color: rgba(100, 255, 218, 0.3);
    color: #ffffff;
}

.ai-msg-content p {
    margin: 0 0 8px 0;
}

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

.ai-msg-content ul {
    margin: 6px 0 6px 18px;
    padding: 0;
}

.ai-msg-content li {
    margin-bottom: 4px;
}

.ai-msg-content strong {
    color: #ffffff;
}

.ai-msg-content a {
    color: var(--chat-primary);
    text-decoration: underline;
}

.ai-msg-time {
    font-size: 0.68rem;
    color: var(--chat-text-muted);
    margin-top: 4px;
    text-align: right;
    font-family: 'Fira Code', monospace;
}

/* Quick Suggestion Chips */
.ai-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(17, 34, 64, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.ai-chip {
    background: rgba(100, 255, 218, 0.08);
    border: 1px solid rgba(100, 255, 218, 0.25);
    color: var(--chat-primary);
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-chip:hover {
    background: var(--chat-primary);
    color: #0a192f;
    transform: translateY(-2px);
}

/* Chat Input Bar */
.ai-chat-footer {
    padding: 12px 16px;
    background: #0d1e38;
    border-top: 1px solid var(--chat-border);
}

.ai-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #112240;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 25px;
    padding: 4px 6px 4px 16px;
    transition: border-color 0.2s ease;
}

.ai-input-form:focus-within {
    border-color: var(--chat-primary);
    box-shadow: 0 0 10px rgba(100, 255, 218, 0.2);
}

.ai-input-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 0.9rem;
    font-family: inherit;
}

.ai-input-field::placeholder {
    color: var(--chat-text-muted);
}

.ai-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    color: #0a192f;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.ai-send-btn:hover {
    transform: scale(1.08);
    background: #00f59b;
}

.ai-send-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

/* Typing Indicator Animation */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.ai-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--chat-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Settings Modal for API Key */
.ai-settings-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 25, 47, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10005;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.ai-settings-modal.active {
    opacity: 1;
    visibility: visible;
}

.ai-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.ai-settings-title {
    font-size: 1.1rem;
    color: #ffffff;
    font-weight: 700;
}

.ai-settings-body {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.ai-settings-label {
    font-size: 0.85rem;
    color: var(--chat-text);
    margin-bottom: 6px;
    display: block;
}

.ai-settings-input {
    width: 100%;
    background: #112240;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px 12px;
    color: #ffffff;
    font-size: 0.85rem;
    font-family: 'Fira Code', monospace;
    box-sizing: border-box;
    margin-bottom: 14px;
}

.ai-settings-input:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.ai-settings-hint {
    font-size: 0.78rem;
    color: var(--chat-text-muted);
    line-height: 1.4;
}

@media (max-width: 480px) {
    .ai-chat-trigger {
        bottom: 16px;
        right: 16px;
        padding: 6px 14px 6px 8px;
    }
    .ai-chat-window {
        bottom: 80px;
        right: 12px;
        left: 12px;
        width: auto;
        height: calc(100vh - 100px);
    }
}
