/* =============================================
   AI CHAT WIDGET STYLES
============================================= */
:root {
    --chat-primary: #2563eb;
    --chat-accent: #ffc94d;
    --chat-bg: rgba(15, 23, 42, 0.9);
    --chat-text: #f8fafc;
    --chat-muted: #94a3b8;
    --chat-glass: blur(16px) saturate(180%);
}

.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    font-family: 'Inter', sans-serif;
}

.chat-bubble {
    width: 65px;
    height: 65px;
    background: var(--chat-primary);
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.chat-bubble i {
    color: white;
    font-size: 28px;
}

.chat-bubble:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(37, 99, 235, 0.5);
}

.notification-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    border: 3px solid #0f172a;
    border-radius: 50%;
    display: none;
}

.chat-container {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 400px;
    height: 600px;
    background: var(--chat-bg);
    backdrop-filter: var(--chat-glass);
    -webkit-backdrop-filter: var(--chat-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-container.hidden {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
    pointer-events: none;
}

.chat-header {
    padding: 24px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-avatar-container {
    position: relative;
    width: 50px;
    height: 50px;
}

.chat-avatar-container img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: white;
    padding: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 3px solid #0f172a;
    border-radius: 50%;
}

.chat-header-text h4 {
    margin: 0;
    color: var(--chat-text);
    font-size: 18px;
    font-weight: 700;
}

.chat-header-text p {
    margin: 0;
    color: var(--chat-muted);
    font-size: 13px;
    letter-spacing: 0.5px;
}

.close-chat {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--chat-muted);
    cursor: pointer;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-chat:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.05), transparent);
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.message.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.message.user {
    align-self: flex-end;
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--chat-muted);
    margin-top: 6px;
    opacity: 0.6;
}

.chat-input-container {
    padding: 20px 24px 24px;
    background: rgba(255, 255, 255, 0.02);
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 6px 6px 6px 18px;
    transition: all 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--chat-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--chat-text);
    padding: 10px 0;
    outline: none;
    font-size: 15px;
}

.send-message {
    width: 42px;
    height: 42px;
    background: var(--chat-primary);
    border: none;
    border-radius: 14px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.send-message:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.send-message i {
    font-size: 18px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    margin-left: 8px;
}

.typing-indicator.hidden {
    display: none;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--chat-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
    opacity: 0.6;
}

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

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

@media (max-width: 480px) {
    .chat-container {
        width: calc(100vw - 40px);
        height: 550px;
        bottom: 80px;
        right: -10px;
    }
    .chat-widget {
        bottom: 20px;
        right: 20px;
    }
}

/* =============================================
   CHAT SETTINGS & OVERLAY STYLES
   ============================================= */
.chat-settings-panel {
    position: absolute;
    top: 99px; /* under header */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    padding: 24px;
    color: var(--chat-text);
}

.chat-settings-panel.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

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

.settings-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--chat-text);
}

.close-settings {
    background: transparent;
    border: none;
    color: var(--chat-muted);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-settings:hover {
    color: #ef4444;
}

.settings-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-section label {
    font-size: 13px;
    font-weight: 500;
    color: var(--chat-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.key-input-wrapper {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2px 6px 2px 12px;
    align-items: center;
}

.key-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--chat-text);
    padding: 10px 0;
    font-size: 14px;
    outline: none;
}

.key-input-wrapper button {
    background: transparent;
    border: none;
    color: var(--chat-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 14px;
    transition: color 0.2s;
}

.key-input-wrapper button:hover {
    color: var(--chat-text);
}

.settings-hint {
    font-size: 11px;
    color: var(--chat-muted);
    line-height: 1.4;
    margin: 0;
}

.settings-hint a {
    color: #3b82f6;
    text-decoration: underline;
}

.mode-status {
    display: flex;
    align-items: center;
}

.badge-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-status.online {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-status.offline {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.settings-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.settings-btn.primary-btn {
    background: var(--chat-primary);
    border: none;
    color: white;
}

.settings-btn.primary-btn:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.settings-btn.outline-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--chat-text);
}

.settings-btn.outline-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.settings-btn.danger-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.settings-btn.danger-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.settings-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 0;
}

/* Chat banner alert */
.api-warning-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 13px;
    color: #fca5a5;
    line-height: 1.5;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
}

.api-warning-banner a {
    color: #f87171;
    text-decoration: underline;
    font-weight: 500;
}

.api-warning-banner .banner-settings-link {
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
    color: #fca5a5;
}

/* Quick Chips styling */
.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    animation: slideIn 0.3s ease;
    align-self: flex-start;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--chat-accent);
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--chat-accent);
    transform: translateY(-2px);
}

