/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #a8e6cf 0%, #dcedc1 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* 容器 */
.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* 顶部导航栏 */
.header {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px 32px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mode-switch {
    display: flex;
    gap: 12px;
    background: var(--background);
    padding: 6px;
    border-radius: 12px;
}

.mode-btn {
    padding: 10px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.settings-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--background);
    color: var(--text-secondary);
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
    transform: rotate(90deg);
}

/* 主内容区域 */
.main-content {
    display: grid;
    grid-template-columns: 380px 1fr 360px;
    gap: 20px;
    min-height: calc(100vh - 140px);
}

/* 输入面板 */
.input-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}

.input-panel::-webkit-scrollbar {
    width: 6px;
}

.input-panel::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

.panel-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.mode-content {
    display: block;
}

.mode-content.hidden {
    display: none;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-textarea {
    width: 100%;
    padding: 12px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.input-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.input-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 上传区域 */
.upload-area {
    margin-bottom: 20px;
    position: relative;
}

.upload-placeholder {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-placeholder:hover {
    border-color: var(--primary-color);
    background: var(--background);
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: var(--text-secondary);
}

.upload-placeholder p {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.upload-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.upload-preview img {
    width: 100%;
    display: block;
    border-radius: 12px;
}

.remove-image-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.remove-image-btn:hover {
    background: var(--danger-color);
}

/* 按钮 */
.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-loading {
    display: inline-block;
}

/* 图片展示区域 */
.display-area {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
}

.image-display {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-display img {
    max-width: 100%;
    max-height: calc(100vh - 300px);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.image-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    background: var(--background);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

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

/* 加载状态 */
.loading-state {
    text-align: center;
}

.loader {
    width: 60px;
    height: 60px;
    border: 5px solid var(--surface-light);
    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-text {
    font-size: 16px;
    color: var(--text-secondary);
}

/* 历史记录面板 */
.history-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.btn-clear {
    padding: 6px 14px;
    border: none;
    background: var(--background);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-clear:hover {
    background: var(--danger-color);
    color: white;
}

.history-list {
    overflow-y: auto;
    flex: 1;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

.empty-history {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.history-item {
    background: var(--background);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.history-item:hover {
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.history-item img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
}

.history-info {
    font-size: 13px;
}

.history-prompt {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

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

.history-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 16px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.history-item:hover .history-delete {
    display: flex;
}

.history-delete:hover {
    background: var(--danger-color);
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.hidden {
    display: none;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 340px 1fr 320px;
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .history-panel {
        max-height: 400px;
    }

    .input-panel {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }

    .title {
        font-size: 24px;
    }

    .container {
        padding: 12px;
    }

    .main-content {
        gap: 12px;
    }

    .input-panel,
    .display-area,
    .history-panel {
        padding: 16px;
    }
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 聊天绘图模式 */
.chat-mode {
    grid-column: 1 / -1;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
    height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 24px;
}

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

.chat-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    background: var(--background);
    border-radius: 12px;
}

.welcome-message p {
    margin: 8px 0;
    font-size: 15px;
}

.welcome-message p:first-child {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.message.assistant .message-avatar {
    background: var(--background);
    color: var(--text-secondary);
}

.message-content {
    background: var(--background);
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-primary);
    word-wrap: break-word;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

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

.message-image {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 400px;
}

.message-image img {
    width: 100%;
    display: block;
    border-radius: 8px;
}

.message-image-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.message-image-actions button {
    padding: 6px 12px;
    border: none;
    background: var(--surface-light);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.message-image-actions button:hover {
    background: var(--primary-color);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: right;
}

.chat-input-area {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
    align-items: flex-end;
}

.btn-upload {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--background);
    color: var(--text-secondary);
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-upload:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.chat-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

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

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

.remove-chat-image:hover {
    background: var(--danger-color);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s ease;
    max-height: 120px;
    min-height: 40px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-send {
    padding: 10px 16px;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    height: 40px;
    flex-shrink: 0;
    min-width: 70px;
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 标准模式容器 */
.standard-mode {
    display: contents;
}

.standard-mode.hidden {
    display: none;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
}

.input-text {
    width: 100%;
    padding: 10px 12px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.input-text:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.settings-info {
    margin-top: 20px;
    padding: 16px;
    background: var(--background);
    border-radius: 10px;
}

.settings-info p {
    margin: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-info strong {
    color: var(--text-primary);
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 10px 20px;
    border: none;
    background: var(--background);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.modal-footer .btn-primary {
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}
