/**
 * AI Chat Panel Styles
 * Semantic document search interface
 */

/* Toggle Button */
.ai-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

.ai-chat-toggle.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.ai-chat-toggle .material-symbols-outlined {
    font-size: 28px;
}

/* Panel */
.ai-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 140px);
    background: var(--bg-primary, #ffffff);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition:
        opacity 0.2s,
        transform 0.2s;
}

.ai-chat-panel.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.ai-chat-title .material-symbols-outlined {
    font-size: 24px;
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Body */
.ai-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search Container */
.ai-chat-search-container {
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 12px;
    padding: 4px;
}

.ai-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary, #333);
    outline: none;
}

.ai-chat-input::placeholder {
    color: var(--text-secondary, #999);
}

.ai-chat-search-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.ai-chat-search-btn:hover {
    opacity: 0.9;
}

.ai-chat-search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Results */
.ai-chat-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Empty State */
.ai-chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary, #666);
}

.ai-chat-empty-state .material-symbols-outlined {
    font-size: 48px;
    opacity: 0.5;
    margin-bottom: 16px;
}

.ai-chat-empty-state p {
    margin: 0 0 8px;
    font-size: 14px;
}

.ai-chat-empty-state small {
    font-size: 12px;
    opacity: 0.7;
}

/* Loading */
.ai-chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
    color: var(--text-secondary, #666);
}

.ai-chat-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e0e0e0);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ai-chat-spin 0.8s linear infinite;
}

@keyframes ai-chat-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error */
.ai-chat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
    color: #e53935;
}

.ai-chat-error .material-symbols-outlined {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Results Header */
.ai-chat-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.ai-chat-results-query {
    font-size: 13px;
    color: var(--text-secondary, #666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-results-count {
    background: var(--bg-secondary, #f0f0f0);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #666);
}

/* Results List */
.ai-chat-results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Result Item */
.ai-chat-result-item {
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.ai-chat-result-item:hover {
    background: var(--bg-tertiary, #f0f0f0);
    border-color: var(--border-color, #e0e0e0);
    transform: translateX(4px);
}

.ai-chat-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ai-chat-result-file {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.ai-chat-result-file .material-symbols-outlined {
    font-size: 18px;
    color: #667eea;
    flex-shrink: 0;
}

.ai-chat-result-filename {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-result-page {
    font-size: 11px;
    color: var(--text-secondary, #888);
    background: var(--bg-primary, #fff);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Score Bar */
.ai-chat-result-score {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ai-chat-score-bar {
    width: 40px;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.ai-chat-score-text {
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    min-width: 32px;
    text-align: right;
}

/* Result Path */
.ai-chat-result-path {
    font-size: 11px;
    color: var(--text-secondary, #888);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-chat-result-path::before {
    content: 'folder';
    font-family: 'Material Symbols Outlined';
    font-size: 14px;
}

/* Result Text */
.ai-chat-result-text {
    font-size: 13px;
    color: var(--text-primary, #333);
    line-height: 1.5;
    margin-bottom: 10px;
}

/* Result Actions */
.ai-chat-result-actions {
    display: flex;
    gap: 8px;
}

.ai-chat-result-action {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid var(--border-color, #ddd);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chat-result-action:hover {
    background: var(--bg-primary, #fff);
    border-color: #667eea;
    color: #667eea;
}

.ai-chat-result-action .material-symbols-outlined {
    font-size: 16px;
}

/* Footer */
.ai-chat-footer {
    border-top: 1px solid var(--border-color, #e0e0e0);
}

/* History */
.ai-chat-history {
    padding: 12px 16px;
}

.ai-chat-history.hidden {
    display: none;
}

.ai-chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary, #888);
}

.ai-chat-clear-history {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary, #888);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s;
}

.ai-chat-clear-history:hover {
    color: #e53935;
}

.ai-chat-clear-history .material-symbols-outlined {
    font-size: 18px;
}

.ai-chat-history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-chat-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary, #333);
    transition: background 0.2s;
}

.ai-chat-history-item:hover {
    background: var(--bg-secondary, #f5f5f5);
}

.ai-chat-history-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-secondary, #888);
}

.ai-chat-history-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dark Theme Support */
[data-theme='dark'] .ai-chat-panel {
    background: var(--bg-primary, #1e1e1e);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

[data-theme='dark'] .ai-chat-input-wrapper {
    background: var(--bg-secondary, #2d2d2d);
}

[data-theme='dark'] .ai-chat-result-item {
    background: var(--bg-secondary, #2d2d2d);
}

[data-theme='dark'] .ai-chat-result-item:hover {
    background: var(--bg-tertiary, #3d3d3d);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
    }

    .ai-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .ai-chat-toggle .material-symbols-outlined {
        font-size: 24px;
    }
}

/* Keyboard shortcut hint */
.ai-chat-input::after {
    content: 'Ctrl+K';
}
