/* Notification styles */
.notification {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10000;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.success {
    border-color: #28a745;
}

.notification.success i {
    color: #28a745;
}

.notification.error {
    border-color: #dc3545;
}

.notification.error i {
    color: #dc3545;
}

.notification.warning {
    border-color: var(--accent-color);
}

.notification.warning i {
    color: var(--accent-color);
}

.notification.info {
    border-color: var(--primary-color);
}

.notification.info i {
    color: var(--primary-color);
}

/* Notification close button */
.notification-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.notification-close i {
    font-size: 0.75rem;
}

/* History record modal */
.history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.history-modal.show {
    opacity: 1;
    visibility: visible;
}

.history-modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.history-modal.show .history-modal-content {
    transform: scale(1);
}

.history-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-header h3 {
    margin: 0;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    max-height: 50vh;
}

.history-item {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.history-tokens {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.history-query {
    color: var(--text-color);
    font-weight: 500;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.history-preview {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.8;
}

.history-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

.clear-history-btn {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), rgba(220, 53, 69, 0.15));
    border: 1px solid rgba(220, 53, 69, 0.4);
    color: #dc3545;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.1);
}

.clear-history-btn:hover {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.2), rgba(220, 53, 69, 0.25));
    border-color: rgba(220, 53, 69, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

.export-history-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-left: 12px;
}

.export-history-btn:hover {
    background: #218838;
}

/* Chat history record styles */
.chat-history-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chat-message-pair {
    margin-bottom: 24px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 20px;
}

.chat-message-pair:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.chat-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.chat-message.user-message {
    align-items: flex-end;
}

.chat-message.ai-message {
    align-items: flex-start;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
}

.user-avatar {
    background: #007bff;
}

.ai-avatar {
    background: #28a745;
}

.message-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
    color: #495057;
}

.message-time {
    font-size: 12px;
    color: #6c757d;
}

.message-tokens {
    font-size: 11px;
    color: #6c757d;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.message-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.message-action-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 12px;
}

.message-action-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
}

.user-message .message-content {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.ai-message .message-content {
    background: white;
    color: #495057;
}

.session-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 0 16px;
}

.session-user-id {
    font-size: 12px;
    color: #6c757d;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
}

.session-message-count {
    font-size: 11px;
    color: #6c757d;
}

/* Responsive design */
@media (max-width: 768px) {
    .notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100%);
    }
    
    .notification.show {
        transform: translateY(0);
    }
    
    .history-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .history-header {
        padding: 1rem;
    }
    
    .history-list {
        padding: 0.5rem;
    }
    
    .history-item {
        padding: 0.75rem;
    }
    
    .chat-history-container {
        padding: 10px;
    }
    
    .message-content {
        max-width: 90%;
    }
}