:root {
    --primary-color: #0093fd;
    --primary-hover: #0077cc;
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #262626;
    --bg-hover: #333333;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-tertiary: #666666;
    --border-color: #333333;
    --accent-color: #0093fd;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --sidebar-width: 280px;
    --header-height: 60px;
    --input-height: 120px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.logo svg {
    width: 28px;
    height: 28px;
    color: var(--primary-color);
}

.logo span {
    font-size: 16px;
    font-weight: 600;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: var(--primary-hover);
}

.new-chat-btn svg {
    width: 16px;
    height: 16px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-tertiary);
}

.chat-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.chat-item span {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.mode-toggle span {
    font-size: 14px;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: 24px;
    transition: 0.3s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider {
    background: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.settings-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: var(--bg-hover);
}

.settings-btn svg {
    width: 16px;
    height: 16px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* Header */
.header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

.menu-toggle svg {
    width: 20px;
    height: 20px;
}

.header-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title h1 {
    font-size: 16px;
    font-weight: 600;
}

.model-badge {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--primary-color), #00c6ff);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

.welcome-content h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
}

.welcome-content > p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.quick-prompts h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 500;
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.prompt-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    text-align: left;
}

.prompt-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.prompt-icon {
    font-size: 24px;
}

.prompt-card span:last-child {
    font-size: 14px;
    color: var(--text-primary);
}

/* Messages */
.messages {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.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: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.message.user .message-avatar {
    background: var(--primary-color);
}

.message.user .message-avatar svg {
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

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

.message-author {
    font-size: 14px;
    font-weight: 500;
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.message-body {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-body p {
    margin-bottom: 12px;
}

.message-body p:last-child {
    margin-bottom: 0;
}

/* Generated Image */
.generated-image {
    margin-top: 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.generated-image img {
    width: 100%;
    height: auto;
    display: block;
}

.image-actions {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.image-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.image-btn:hover {
    background: var(--bg-hover);
}

.image-btn svg {
    width: 14px;
    height: 14px;
}

/* Loading State */
.message-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.input-area {
    border-top: 1px solid var(--border-color);
    padding: 20px;
    background: var(--bg-primary);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px 14px;
    display: flex;
    gap: 12px;
    transition: border-color 0.2s;
    min-height: 80px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* 分辨率选择器 */
.resolution-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.resolution-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.resolution-options {
    display: flex;
    gap: 6px;
}

.resolution-btn {
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.resolution-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.resolution-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.resolution-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.input-wrapper.drag-over {
    border-color: var(--primary-color);
    background: rgba(0, 147, 253, 0.1);
}

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 147, 253, 0.95);
    border-radius: var(--radius-lg);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    z-index: 10;
}

.drop-overlay.active {
    display: flex;
}

.drop-overlay svg {
    width: 48px;
    height: 48px;
}

.upload-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    flex-shrink: 0;
}

.upload-btn:hover {
    color: var(--primary-color);
    background: var(--bg-hover);
}

.upload-btn svg {
    width: 20px;
    height: 20px;
}

.image-preview-container {
    margin-bottom: 12px;
}

.image-preview-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s;
}

.image-preview-remove:hover {
    background: var(--error-color);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 200px;
    min-height: 24px;
}

.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

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

.input-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.input-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.input-btn svg {
    width: 18px;
    height: 18px;
}

.send-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.send-btn:hover {
    background: var(--primary-hover);
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 4px;
}

.mode-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.mode-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.mode-indicator .dot.active {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.close-btn:hover {
    color: var(--text-primary);
}

.close-btn svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.setting-group input,
.setting-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.setting-group input:focus,
.setting-group select:focus {
    border-color: var(--primary-color);
}

.setting-hint {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.btn-secondary {
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-primary {
    padding: 10px 16px;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 16px;
    margin-bottom: 8px;
}

.loading-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: block;
    }
    
    .prompt-grid {
        grid-template-columns: 1fr;
    }
    
    .welcome-content h2 {
        font-size: 22px;
    }
    
    .input-footer {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}
