/* ============================================================================
   AI CHAT WIDGET STYLES
   ============================================================================ */

/* Floating Action Button */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.6);
}

.chat-fab.hidden {
    display: none;
}

/* Chat Panel */
.chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.chat-header-title {
    font-weight: 600;
    font-size: 1rem;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message Bubbles */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    animation: chatFadeIn 0.2s ease;
}

.chat-msg-user {
    align-self: flex-end;
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-agent {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat-msg-error {
    align-self: flex-start;
    background: #fff0f0;
    color: #c33;
    border: 1px solid #fcc;
    border-bottom-left-radius: 4px;
    font-size: 0.85rem;
}

.chat-error-icon {
    margin-right: 4px;
}

/* Action Badge */
.chat-action-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    background: rgba(102, 126, 234, 0.12);
    color: #667eea;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* Loading Dots */
.chat-msg-loading {
    align-self: flex-start;
    background: #f0f0f0;
    padding: 10px 18px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.chat-dots span {
    animation: chatBounce 1.2s infinite;
    display: inline-block;
    font-size: 1.4rem;
    color: #999;
    line-height: 1;
}

.chat-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

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

/* Empty State */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #888;
    padding: 20px;
}

.chat-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.chat-empty p {
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.chat-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.chat-example {
    background: #f5f5f5;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s ease;
    text-align: left;
}

.chat-example:hover {
    background: #e8e8ff;
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input-area input:focus {
    border-color: #667eea;
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #5568d3;
}

/* ============================================================================
   DARK THEME
   ============================================================================ */

body.dark-theme .chat-fab {
    background: linear-gradient(135deg, #00d4ff 0%, #0f3460 100%);
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.4);
}

body.dark-theme .chat-panel {
    background: #0f3460;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

body.dark-theme .chat-header {
    background: linear-gradient(135deg, #00d4ff 0%, #0f3460 100%);
}

body.dark-theme .chat-messages {
    background: #0a1e3d;
}

body.dark-theme .chat-msg-user {
    background: #00d4ff;
    color: #1a1a2e;
}

body.dark-theme .chat-msg-agent {
    background: #1a2332;
    color: #e0e0e0;
}

body.dark-theme .chat-msg-error {
    background: #2a1520;
    color: #ff8888;
    border-color: #5a2030;
}

body.dark-theme .chat-msg-loading {
    background: #1a2332;
}

body.dark-theme .chat-dots span {
    color: #667;
}

body.dark-theme .chat-action-badge {
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
}

body.dark-theme .chat-empty {
    color: #8899aa;
}

body.dark-theme .chat-example {
    background: #1a2332;
    color: #b0b0b0;
}

body.dark-theme .chat-example:hover {
    background: #1e3050;
}

body.dark-theme .chat-input-area {
    border-top-color: #1a2332;
    background: #0f3460;
}

body.dark-theme .chat-input-area input {
    background: #1a2332;
    border-color: #2a3a50;
    color: #e0e0e0;
}

body.dark-theme .chat-input-area input:focus {
    border-color: #00d4ff;
}

body.dark-theme .chat-send-btn {
    background: #00d4ff;
    color: #1a1a2e;
}

body.dark-theme .chat-send-btn:hover {
    background: #00b8e6;
}

/* ============================================================================
   CAT THEME
   ============================================================================ */

body.cat-theme .chat-fab {
    background: linear-gradient(135deg, #ff6b9d 0%, #ffeaa7 100%);
    box-shadow: 0 4px 16px rgba(255, 107, 157, 0.4);
}

body.cat-theme .chat-panel {
    background: #fff5f7;
}

body.cat-theme .chat-header {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff9a9e 100%);
}

body.cat-theme .chat-msg-user {
    background: #ff6b9d;
    color: white;
}

body.cat-theme .chat-msg-agent {
    background: #ffe8f0;
    color: #333;
}

body.cat-theme .chat-msg-error {
    background: #fff0f0;
}

body.cat-theme .chat-msg-loading {
    background: #ffe8f0;
}

body.cat-theme .chat-action-badge {
    background: rgba(255, 107, 157, 0.12);
    color: #ff6b9d;
}

body.cat-theme .chat-example {
    background: #fff0f6;
}

body.cat-theme .chat-example:hover {
    background: #ffe0ee;
}

body.cat-theme .chat-input-area {
    border-top-color: #ffb3d9;
    background: #fff5f7;
}

body.cat-theme .chat-input-area input {
    border-color: #ffb3d9;
}

body.cat-theme .chat-input-area input:focus {
    border-color: #ff6b9d;
}

body.cat-theme .chat-send-btn {
    background: #ff6b9d;
}

body.cat-theme .chat-send-btn:hover {
    background: #ff4d88;
}

/* ============================================================================
   MOBILE RESPONSIVE
   ============================================================================ */

@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .chat-panel {
        transition: none;
    }
    .chat-msg {
        animation: none;
    }
    .chat-dots span {
        animation: none;
    }
    .chat-fab {
        transition: none;
    }
}
