/* Deepseek AI Chat - Professional CSS optimized for SEO */

:root {
    --ds-primary: #2563eb;
    --ds-primary-dark: #1d4ed8;
    --ds-primary-light: #dbeafe;
    --ds-secondary: #64748b;
    --ds-success: #10b981;
    --ds-danger: #ef4444;
    --ds-warning: #f59e0b;
    --ds-bg: #ffffff;
    --ds-surface: #f8fafc;
    --ds-text: #1e293b;
    --ds-text-secondary: #64748b;
    --ds-text-muted: #94a3b8;
    --ds-border: #e2e8f0;
    --ds-user-bg: #2563eb;
    --ds-user-text: #ffffff;
    --ds-ai-bg: #f1f5f9;
    --ds-ai-text: #1e293b;
    --ds-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --ds-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --ds-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --ds-radius: 12px;
    --ds-radius-lg: 16px;
    --ds-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ds-font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

[data-theme="dark"] {
    --ds-bg: #0f172a;
    --ds-surface: #1e293b;
    --ds-text: #f1f5f9;
    --ds-text-secondary: #cbd5e1;
    --ds-text-muted: #64748b;
    --ds-border: #334155;
    --ds-ai-bg: #1e293b;
    --ds-ai-text: #f1f5f9;
}

/* Base Styles */
.ds-ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    max-height: 90vh;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    background: var(--ds-bg);
    border-radius: var(--ds-radius-lg);
    overflow: hidden;
    box-shadow: var(--ds-shadow-lg);
    border: 1px solid var(--ds-border);
    font-family: var(--ds-font);
    position: relative;
}

/* Header */
.ds-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--ds-surface);
    border-bottom: 1px solid var(--ds-border);
    flex-shrink: 0;
}

.ds-ai-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ds-ai-brand h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ds-text);
    margin: 0;
}

.ds-header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ds-model-selector select {
    appearance: none;
    padding: 8px 36px 8px 12px;
    background: var(--ds-bg);
    border: 1px solid var(--ds-border);
    border-radius: 8px;
    color: var(--ds-text);
    font-size: 0.875rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: all 0.2s;
}

.ds-model-selector select:hover {
    border-color: var(--ds-primary);
}

.ds-model-selector select:focus {
    outline: none;
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px var(--ds-primary-light);
}

.ds-theme-toggle,
.ds-ai-reset {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--ds-border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ds-theme-toggle:hover,
.ds-ai-reset:hover {
    background: var(--ds-surface);
    border-color: var(--ds-primary);
}

.ds-theme-toggle svg,
.ds-ai-reset svg {
    width: 18px;
    height: 18px;
    color: var(--ds-text);
}

.ds-theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .ds-theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .ds-theme-toggle .moon-icon {
    display: block;
}

/* Messages Area */
.ds-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--ds-bg);
    scroll-behavior: smooth;
}

.ds-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ds-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ds-ai-messages::-webkit-scrollbar-thumb {
    background: var(--ds-border);
    border-radius: 3px;
}

.ds-ai-messages::-webkit-scrollbar-thumb:hover {
    background: var(--ds-secondary);
}

/* Empty State */
.ds-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.ds-empty-state-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
    color: var(--ds-primary);
    opacity: 0.2;
}

.ds-empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ds-text);
    margin: 0 0 12px;
}

.ds-empty-state-text {
    color: var(--ds-text-secondary);
    margin: 0 0 32px;
    max-width: 400px;
}

/* Quick Prompts */
.ds-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.ds-quick-prompt {
    padding: 8px 16px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 20px;
    color: var(--ds-text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ds-quick-prompt:hover {
    background: var(--ds-primary);
    color: white;
    border-color: var(--ds-primary);
    transform: translateY(-1px);
}

/* Messages */
.ds-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ds-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.ds-message.user {
    flex-direction: row-reverse;
}

.ds-message.user .ds-message-avatar {
    background: var(--ds-primary);
    color: white;
}

.ds-message.assistant .ds-message-avatar {
    background: var(--ds-surface);
    color: var(--ds-primary);
    border: 1px solid var(--ds-border);
}

.ds-message-content {
    flex: 1;
    max-width: 70%;
}

.ds-message.user .ds-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ds-message-bubble {
    padding: 12px 16px;
    border-radius: var(--ds-radius);
    word-wrap: break-word;
    position: relative;
}

.ds-message.user .ds-message-bubble {
    background: var(--ds-user-bg);
    color: var(--ds-user-text);
    border-bottom-right-radius: 4px;
}

.ds-message.assistant .ds-message-bubble {
    background: var(--ds-ai-bg);
    color: var(--ds-ai-text);
    border-bottom-left-radius: 4px;
}

/* Markdown Content */
.ds-message-bubble h1,
.ds-message-bubble h2,
.ds-message-bubble h3,
.ds-message-bubble h4,
.ds-message-bubble h5,
.ds-message-bubble h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.ds-message-bubble p {
    margin-bottom: 0.75em;
    line-height: 1.6;
}

.ds-message-bubble ul,
.ds-message-bubble ol {
    margin-bottom: 0.75em;
    padding-left: 1.5em;
}

.ds-message-bubble code {
    font-family: var(--ds-font-mono);
    font-size: 0.875em;
    padding: 0.2em 0.4em;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.ds-message-bubble pre {
    margin: 0.75em 0;
    padding: 1em;
    background-color: var(--ds-surface);
    border-radius: 8px;
    overflow-x: auto;
}

.ds-message-bubble pre code {
    display: block;
    padding: 0;
    background-color: transparent;
}

.ds-message-bubble a {
    color: var(--ds-primary);
    text-decoration: none;
}

.ds-message-bubble a:hover {
    text-decoration: underline;
}

/* Message Actions */
.ds-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.ds-message:hover .ds-message-actions {
    opacity: 1;
}

.ds-message-action-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ds-text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.ds-message-action-btn:hover {
    background: var(--ds-surface);
    border-color: var(--ds-border);
}

/* Typing Indicator */
.ds-typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.ds-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--ds-ai-bg);
    border-radius: var(--ds-radius);
    border-bottom-left-radius: 4px;
}

.ds-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--ds-text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.ds-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ds-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Section */
.ds-ai-input {
    padding: 16px 20px 20px;
    background: var(--ds-surface);
    border-top: 1px solid var(--ds-border);
    flex-shrink: 0;
}

.ds-input-wrapper {
    position: relative;
    background: var(--ds-bg);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    transition: all 0.2s;
}

.ds-input-wrapper:focus-within {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px var(--ds-primary-light);
}

#ds-ai-prompt {
    width: 100%;
    min-height: 48px;
    max-height: 120px;
    padding: 12px 52px 12px 16px;
    background: transparent;
    border: none;
    color: var(--ds-text);
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: none;
    font-family: var(--ds-font);
}

#ds-ai-prompt:focus {
    outline: none;
}

#ds-ai-prompt::placeholder {
    color: var(--ds-text-muted);
}

.ds-input-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
}

#ds-ai-submit {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--ds-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#ds-ai-submit:hover:not(:disabled) {
    background: var(--ds-primary-dark);
    transform: scale(1.05);
}

#ds-ai-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#ds-ai-submit svg {
    width: 18px;
    height: 18px;
}

.ds-input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 4px;
}

.ds-char-count {
    font-size: 0.75rem;
    color: var(--ds-text-muted);
}

.ds-char-count.warning {
    color: var(--ds-warning);
}

.ds-char-count.danger {
    color: var(--ds-danger);
}

.ds-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--ds-text-muted);
}

.ds-status-indicator::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ds-success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* Statistics Widget */
.ds-ai-stats-widget {
    padding: 30px 0;
    background: transparent;
}

.ds-ai-stats-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.5rem;
    color: var(--ds-text);
}

.ds-stats-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.ds-stat-card {
    background: var(--ds-bg);
    border-radius: 12px;
    padding: 20px 25px;
    text-align: center;
    box-shadow: var(--ds-shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--ds-border);
    flex: 1 1 200px;
    min-width: 180px;
    max-width: 280px;
}

.ds-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ds-shadow-lg);
    border-color: var(--ds-primary);
}

.ds-stat-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    background: linear-gradient(135deg, var(--ds-primary) 0%, var(--ds-primary-dark) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ds-stat-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.ds-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ds-text);
    line-height: 1;
    margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
}

.ds-stat-value.loading {
    color: var(--ds-text-muted);
    animation: pulse 1.5s infinite;
}

.ds-stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ds-text-secondary);
    margin: 0;
}

.ds-stats-update-time {
    text-align: center;
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--ds-text-muted);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ds-ai-chat-container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
        border: none;
    }
    
    .ds-ai-header {
        padding: 12px 16px;
    }
    
    .ds-ai-brand h1 {
        font-size: 1rem;
    }
    
    .ds-ai-messages {
        padding: 16px;
    }
    
    .ds-message-content {
        max-width: 85%;
    }
    
    .ds-model-selector select {
        font-size: 0.8125rem;
        padding: 6px 32px 6px 10px;
    }
    
    .ds-stats-container {
        gap: 10px;
    }
    
    .ds-stat-card {
        padding: 15px 20px;
        min-width: 140px;
    }
    
    .ds-stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .ds-stats-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .ds-stat-card {
        max-width: none;
    }
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* RTL Support */
[dir="rtl"] .ds-message {
    direction: rtl;
}

[dir="rtl"] .ds-message.user {
    flex-direction: row;
}

[dir="rtl"] .ds-message.assistant {
    flex-direction: row-reverse;
}

[dir="rtl"] .ds-message.user .ds-message-content {
    align-items: flex-start;
}

[dir="rtl"] .ds-message.user .ds-message-bubble {
    border-bottom-right-radius: var(--ds-radius);
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .ds-message.assistant .ds-message-bubble {
    border-bottom-left-radius: var(--ds-radius);
    border-bottom-right-radius: 4px;
}

/* Print Styles */
@media print {
    .ds-ai-header,
    .ds-ai-input,
    .ds-message-actions,
    .ds-quick-prompts {
        display: none !important;
    }
    
    .ds-ai-chat-container {
        height: auto;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .ds-message {
        page-break-inside: avoid;
    }
}

/* Animations */
[data-animation="true"] .ds-stat-card {
    opacity: 0;
    animation: fadeInUp 0.6s forwards;
}

[data-animation="true"] .ds-stat-card:nth-child(1) { animation-delay: 0.1s; }
[data-animation="true"] .ds-stat-card:nth-child(2) { animation-delay: 0.2s; }
[data-animation="true"] .ds-stat-card:nth-child(3) { animation-delay: 0.3s; }
[data-animation="true"] .ds-stat-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}