/* DeepSeek AI Chat - Design Fixes and Improvements */

/* ===========================
   Settings Panel Fixes
   =========================== */
.ds-settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100%;
    background: var(--ds-surface-primary);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transition: right var(--ds-transition-base);
    z-index: var(--ds-z-modal);
    display: flex;
    flex-direction: column;
}

.ds-settings-panel.active {
    right: 0;
}

.ds-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ds-spacing-lg);
    border-bottom: 1px solid var(--ds-border-light);
    background: var(--ds-surface-secondary);
}

.ds-settings-title {
    font-size: var(--ds-text-lg);
    font-weight: var(--ds-font-semibold);
    color: var(--ds-text-primary);
    margin: 0;
}

.ds-settings-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--ds-spacing-lg);
}

.ds-setting-group {
    margin-bottom: var(--ds-spacing-lg);
}

.ds-setting-label {
    display: block;
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-font-medium);
    color: var(--ds-text-secondary);
    margin-bottom: var(--ds-spacing-sm);
}

/* Toggle Switch */
.ds-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    background: var(--ds-gray-300);
    border-radius: var(--ds-radius-full);
    cursor: pointer;
    transition: background var(--ds-transition-fast);
}

.ds-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--ds-transition-fast);
    box-shadow: var(--ds-shadow-sm);
}

.ds-toggle.active {
    background: var(--ds-brand-primary);
}

.ds-toggle.active::after {
    transform: translateX(24px);
}

/* ===========================
   Admin Tabs Fixes
   =========================== */
.deepseek-tab-content {
    display: none;
    animation: fadeIn var(--ds-transition-base);
}

.deepseek-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.nav-tab-wrapper {
    margin-bottom: var(--ds-spacing-lg);
    border-bottom: 1px solid var(--ds-border-light);
}

.nav-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: var(--ds-spacing-sm) var(--ds-spacing-md);
    margin: 0 var(--ds-spacing-xs);
    color: var(--ds-text-secondary);
    font-weight: var(--ds-font-medium);
    transition: all var(--ds-transition-fast);
    cursor: pointer;
}

.nav-tab:hover {
    color: var(--ds-text-primary);
    background: var(--ds-surface-secondary);
}

.nav-tab.nav-tab-active {
    color: var(--ds-brand-primary);
    border-bottom-color: var(--ds-brand-primary);
    background: transparent;
}

/* ===========================
   Chat Interface Improvements
   =========================== */
.deepseek-chat-wrapper {
    font-family: var(--ds-font-sans);
    font-size: var(--ds-text-base);
    line-height: 1.6;
}

.ds-chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    max-height: 90vh;
    background: var(--ds-surface-primary);
    border-radius: var(--ds-radius-xl);
    overflow: hidden;
    box-shadow: var(--ds-shadow-xl);
}

/* Header Improvements */
.ds-chat-header {
    background: linear-gradient(135deg, var(--ds-brand-primary), var(--ds-brand-secondary));
    color: white;
    padding: var(--ds-spacing-md) var(--ds-spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ds-header-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: var(--ds-spacing-sm);
    border-radius: var(--ds-radius-md);
    cursor: pointer;
    transition: all var(--ds-transition-fast);
}

.ds-header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Messages Area */
.ds-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--ds-spacing-lg);
    background: var(--ds-surface-secondary);
}

.ds-message {
    margin-bottom: var(--ds-spacing-md);
    animation: slideUp var(--ds-transition-base);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ds-message-bubble {
    padding: var(--ds-spacing-md);
    border-radius: var(--ds-radius-lg);
    max-width: 70%;
    word-wrap: break-word;
}

.ds-user .ds-message-bubble {
    background: var(--ds-brand-primary);
    color: white;
    margin-left: auto;
}

.ds-assistant .ds-message-bubble {
    background: white;
    color: var(--ds-text-primary);
    box-shadow: var(--ds-shadow-sm);
}

/* Input Area */
.ds-input-wrapper {
    padding: var(--ds-spacing-lg);
    background: white;
    border-top: 1px solid var(--ds-border-light);
}

.ds-input-group {
    display: flex;
    gap: var(--ds-spacing-sm);
    align-items: flex-end;
}

.ds-input-field {
    flex: 1;
    padding: var(--ds-spacing-md);
    border: 2px solid var(--ds-border-light);
    border-radius: var(--ds-radius-lg);
    font-size: var(--ds-text-base);
    font-family: var(--ds-font-sans);
    resize: none;
    transition: border-color var(--ds-transition-fast);
}

.ds-input-field:focus {
    outline: none;
    border-color: var(--ds-brand-primary);
}

.ds-send-btn {
    padding: var(--ds-spacing-md);
    background: var(--ds-brand-primary);
    color: white;
    border: none;
    border-radius: var(--ds-radius-lg);
    cursor: pointer;
    transition: all var(--ds-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ds-send-btn:hover:not(:disabled) {
    background: var(--ds-brand-primary-dark);
    transform: scale(1.05);
}

.ds-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Typing Indicator */
.ds-typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: var(--ds-spacing-sm) var(--ds-spacing-md);
    background: white;
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-sm);
}

.ds-typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background: var(--ds-gray-400);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ds-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ds-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Dark Theme */
[data-theme="dark"] {
    --ds-surface-primary: #1a1a1a;
    --ds-surface-secondary: #2a2a2a;
    --ds-surface-tertiary: #3a3a3a;
    --ds-text-primary: #f0f0f0;
    --ds-text-secondary: #b0b0b0;
    --ds-text-tertiary: #808080;
    --ds-border-light: #404040;
    --ds-border-default: #505050;
    --ds-border-dark: #606060;
}

[data-theme="dark"] .ds-assistant .ds-message-bubble {
    background: var(--ds-surface-tertiary);
    color: var(--ds-text-primary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ds-settings-panel {
        width: 100%;
        right: -100%;
    }
    
    .ds-chat-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .ds-message-bubble {
        max-width: 85%;
    }
}

/* Loading States */
.ds-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--ds-gray-300);
    border-top-color: var(--ds-brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error States */
.ds-error {
    padding: var(--ds-spacing-md);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--ds-radius-md);
    color: #991b1b;
    margin-bottom: var(--ds-spacing-md);
}

/* Success States */
.ds-success {
    padding: var(--ds-spacing-md);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--ds-radius-md);
    color: #166534;
    margin-bottom: var(--ds-spacing-md);
}