/**
 * 赞掌柜AI智能Logo生成器 - 商务版样式
 * 专业的企业级设计风格
 */

/* ==================== CSS变量 ==================== */
:root {
    /* 主色调 */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #3b82f6;

    /* 辅助色 */
    --secondary-color: #f59e0b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;

    /* 背景色 - 深色主题 */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-elevated: #1e293b;

    /* 文字色 */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;

    /* 边框色 */
    --border-color: #334155;
    --border-hover: #475569;

    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);

    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* 过渡 */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* 浅色主题 */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==================== 顶部导航栏 ==================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
}

.header-center {
    flex: 1;
    justify-content: center;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-md);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

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

/* API状态 */
.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.api-status:hover {
    background: var(--border-hover);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.status-dot.valid {
    background: var(--success-color);
    animation: none;
}

.status-dot.invalid {
    background: var(--danger-color);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

/* 按钮通用样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-hover);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-block {
    width: 100%;
}

.btn-large {
    padding: 14px 24px;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
}

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

.theme-toggle-icon {
    font-size: 20px;
}

.header-right {
    gap: 12px;
}

/* ==================== 主容器 ==================== */
.main-container {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    gap: 20px;
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - 77px);
}

/* ==================== 面板通用样式 ==================== */
.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.title-icon {
    font-size: 18px;
}

/* ==================== 表单样式 ==================== */
.form-group {
    margin-bottom: 16px;
}

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

.required {
    color: var(--danger-color);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* 颜色选择器 */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-input {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
}

.color-label {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* 单选框组 */
.radio-group {
    display: flex;
    gap: 8px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex: 1;
    justify-content: center;
}

.radio-item:hover {
    border-color: var(--primary-color);
}

.radio-item input[type="radio"] {
    accent-color: var(--primary-color);
}

.radio-item span {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== 数量选择器 ==================== */
.quantity-selector {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.quantity-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

.quantity-input {
    flex: 1;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    height: 40px;
}

.quantity-input:focus {
    outline: none;
}

/* ==================== 中间面板 ==================== */
.center-panel {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

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

.result-count {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Logo网格 */
.logo-grid {
    flex: 1;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    overflow-y: auto;
    max-height: calc(100vh - 250px);
    align-items: start;
}

.logo-item {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.logo-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.logo-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.logo-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    background: white;
    display: block;
}

.logo-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.logo-item:hover .logo-item-overlay {
    opacity: 1;
}

.logo-action-btn {
    padding: 8px 16px;
    background: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logo-action-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* 空状态 */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

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

.empty-desc {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* ==================== 提示词容器 ==================== */
.prompt-container {
    min-height: 120px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.empty-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-style: italic;
}

/* ==================== 进度条 ==================== */
.progress-container {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
}

/* ==================== 操作按钮组 ==================== */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-icon {
    font-size: 16px;
}

/* ==================== 选中Logo操作 ==================== */
.selected-logo-preview {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.selected-logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.variant-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ==================== 使用提示 ==================== */
.tips-section {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-md);
    padding: 16px;
}

.tips-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.tips-list {
    list-style: none;
}

.tips-list li {
    font-size: 13px;
    color: var(--text-tertiary);
    padding-left: 16px;
    margin-bottom: 6px;
    position: relative;
}

.tips-list li:before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--primary-color);
}

.tips-list li:last-child {
    margin-bottom: 0;
}

/* ==================== 历史记录 ==================== */
.history-list {
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 8px;
}

.history-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.history-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.empty-history {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ==================== 弹窗 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
}

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

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

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

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

/* API配置区域 */
.api-section {
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.api-section:last-child {
    margin-bottom: 0;
}

.api-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.api-icon {
    font-size: 16px;
}

.password-input {
    display: flex;
    align-items: center;
}

.password-input .form-input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.visibility-toggle {
    width: 44px;
    height: 42px;
    border: 1px solid var(--border-color);
    border-left: none;
    background: var(--bg-secondary);
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.visibility-toggle:hover {
    background: var(--bg-tertiary);
}

.test-result {
    margin-top: 10px;
    font-size: 13px;
    min-height: 20px;
}

.test-result.success {
    color: var(--success-color);
}

.test-result.error {
    color: var(--danger-color);
}

.test-result.loading {
    color: var(--text-tertiary);
}

/* API状态信息 */
.api-status-info {
    display: flex;
    gap: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.status-label {
    color: var(--text-tertiary);
}

.status-value {
    color: var(--text-muted);
    font-weight: 500;
}

.status-value.configured {
    color: var(--success-color);
}

/* ==================== 图片查看器 ==================== */
.imageviewer-content {
    position: relative;
    background: transparent;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.imageviewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    font-size: 24px;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.imageviewer-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

#logoViewerImage {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

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

/* ==================== 响应式 ==================== */
@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 280px 1fr 260px;
    }
}

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

    .left-panel,
    .right-panel {
        order: 2;
    }

    .center-panel {
        order: 1;
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }

    .brand-tagline,
    .status-text {
        display: none;
    }

    .main-container {
        padding: 12px;
        gap: 12px;
    }

    .logo-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== 滚动条样式 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

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

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