/**
 * General Chat Widget Styles
 *
 * Floating chat interface for context-aware AI assistant
 */

/* ============================================================================
   Floating Chat Button
   ============================================================================ */

.chat-widget-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(74, 144, 226, 0.3);
    transition: all 0.3s ease;
    z-index: 9998;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 12px 32px rgba(74, 144, 226, 0.4);
}

/* ============================================================================
   Chat Panel
   ============================================================================ */

.chat-widget-panel {
    position: fixed;
    bottom: 0;
    right: -450px;
    width: 450px;
    height: 650px;
    max-height: calc(100vh - 50px);
    background: white;
    border-radius: 12px 0 0 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    z-index: 9999;
}

.chat-widget-panel.open {
    right: 0;
}

/* ============================================================================
   Chat Header
   ============================================================================ */

.chat-widget-header {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 0 0 0;
}

.chat-widget-title {
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
}

.chat-widget-controls {
    display: flex;
    gap: 8px;
}

.chat-widget-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-widget-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================================
   Sessions Sidebar
   ============================================================================ */

.chat-sessions-sidebar {
    position: absolute;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background: white;
    border-right: 1px solid #e0e0e0;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.chat-sessions-header {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-sessions-header h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.chat-sessions-list {
    overflow-y: auto;
    height: calc(100% - 60px);
}

.chat-session-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
}

.chat-session-item:hover {
    background: #f8f9fa;
}

.chat-session-item.active {
    background: #e7f3ff;
    border-left: 3px solid #4A90E2;
}

.session-title {
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-meta {
    font-size: 11px;
    color: #95a5a6;
    display: flex;
    gap: 8px;
}

.session-delete-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: #dc3545;
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.chat-session-item:hover .session-delete-btn {
    opacity: 1;
}

/* ============================================================================
   Chat Body
   ============================================================================ */

.chat-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

/* Welcome Screen */
.chat-welcome {
    text-align: center;
    padding: 40px 20px;
}

.chat-welcome-icon {
    font-size: 64px;
    color: #4A90E2;
    margin-bottom: 16px;
}

.chat-welcome h5 {
    color: #2c3e50;
    margin-bottom: 12px;
}

.chat-welcome p {
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 24px;
}

.chat-welcome-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    font-size: 13px;
    color: #34495e;
}

.feature-item i {
    color: #4A90E2;
}

/* Messages */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #4A90E2;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-message-user .message-avatar {
    background: #34495e;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 48px);
}

.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #2c3e50;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chat-message-user .message-text {
    background: #4A90E2;
    color: white;
}

.message-text pre {
    background: #f4f4f4;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-text code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.message-time {
    font-size: 11px;
    color: #95a5a6;
    margin-top: 4px;
}

/* Tool Usage */
.chat-tools-used {
    margin-bottom: 8px;
    padding: 10px;
    background: #e7f3ff;
    border-radius: 8px;
    border-left: 3px solid #4A90E2;
}

.tools-header {
    font-size: 12px;
    font-weight: 600;
    color: #4A90E2;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tools-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: white;
    border-radius: 4px;
    font-size: 11px;
    color: #4A90E2;
    border: 1px solid #d0e1ff;
}

.tool-badge i {
    font-size: 10px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #4A90E2;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Error Message */
.chat-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fee;
    border-left: 3px solid #dc3545;
    border-radius: 6px;
    color: #dc3545;
    font-size: 13px;
}

/* ============================================================================
   Chat Footer
   ============================================================================ */

.chat-widget-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-context-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #e7f3ff;
    border-radius: 6px;
    font-size: 12px;
    color: #4A90E2;
    margin-bottom: 10px;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 150px;
    overflow-y: auto;
}

.chat-input:focus {
    border-color: #4A90E2;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: #4A90E2;
    border: none;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #357ABD;
    transform: translateY(-2px);
}

.chat-send-btn:active {
    transform: translateY(0);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    .chat-widget-panel {
        width: 100%;
        right: -100%;
        border-radius: 0;
    }

    .chat-widget-panel.open {
        right: 0;
    }

    .chat-widget-button {
        bottom: 20px;
        right: 20px;
    }

    .chat-sessions-sidebar {
        left: -100%;
        width: 100%;
    }
}

/* ============================================================================
   Dark Mode Support
   ============================================================================ */

/* Manual dark theme */
[data-bs-theme="dark"] .chat-widget-panel {
    background: #1e1e1e;
}

[data-bs-theme="dark"] .chat-widget-body {
    background: #2d2d2d;
}

[data-bs-theme="dark"] .message-text {
    background: #3a3a3a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .chat-input {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #4a4a4a;
}

[data-bs-theme="dark"] .chat-welcome p,
[data-bs-theme="dark"] .message-time {
    color: #a0a0a0;
}

[data-bs-theme="dark"] .feature-item {
    background: #3a3a3a;
    color: #e0e0e0;
}

/* Auto theme respects OS preference */
@media (prefers-color-scheme: dark) {
    html[data-bs-theme="auto"] .chat-widget-panel {
        background: #1e1e1e;
    }

    html[data-bs-theme="auto"] .chat-widget-body {
        background: #2d2d2d;
    }

    html[data-bs-theme="auto"] .message-text {
        background: #3a3a3a;
        color: #e0e0e0;
    }

    html[data-bs-theme="auto"] .chat-input {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #4a4a4a;
    }

    html[data-bs-theme="auto"] .chat-welcome p,
    html[data-bs-theme="auto"] .message-time {
        color: #a0a0a0;
    }

    html[data-bs-theme="auto"] .feature-item {
        background: #3a3a3a;
        color: #e0e0e0;
    }
}
