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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #F0F4F8 0%, #F8FBFF 50%, #EFF6FF 100%);
    min-height: 100vh;
    color: #333;
}

/* 顶部标题栏 */
.header-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid rgba(33, 150, 243, 0.2);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    width: 80px;
    height: auto;
}

.header-text {
    flex: 1;
}

.header-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #2196F3 0%, #E91E63 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.header-subtitle {
    font-size: 14px;
    color: #666;
}

/* API 状态指示器 */
.api-status-indicator {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    background-color: #f0f0f0;
    cursor: default;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: background-color 0.5s ease;
}

.status-dot.ok {
    background-color: #4CAF50;
}

.status-dot.error {
    background-color: #F44336;
}

.status-dot.checking {
    background-color: #FFC107;
}


.status-text {
    font-size: 14px;
    font-weight: 500;
}

.status-tooltip {
    visibility: hidden;
    opacity: 0;
    width: max-content;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    transition: opacity 0.3s;
    font-size: 12px;
}

.api-status-indicator:hover .status-tooltip {
    visibility: visible;
    opacity: 1;
}


/* 主内容区 */
.main-content {
    max-width: 1600px;
    margin: 30px auto;
    padding: 0 30px;
    display: grid;
    grid-template-columns: 4fr 5fr;
    /* 左右两列布局 */
    gap: 30px;
    align-items: start;
}

.control-column {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
    animation: slideIn 0.5s ease-out;
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.card-title-with-icon {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.card-description {
    margin-top: 8px;
    font-size: 13px;
    color: #666;
}

.card-content {
    padding: 20px;
    flex-grow: 1;
    /* 让内容区填充剩余空间 */
    display: flex;
    flex-direction: column;
}

/* 右下角结果卡片需要特殊处理高度 */
.right-column .result-card {
    height: 100%;
}


/* 图标 */
.gradient-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.gradient-icon-wrapper.blue {
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.gradient-icon-wrapper.green {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.gradient-icon-wrapper.orange {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.gradient-icon-wrapper.purple {
    background: linear-gradient(135deg, #9C27B0 0%, #6A1B9A 100%);
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3);
}

.gradient-icon-wrapper.pink {
    background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.3);
}

.icon {
    width: 24px;
    height: 24px;
    stroke: white;
}

/* 卡片背景 */
.api-key-card {
    background: linear-gradient(135deg, #E3F2FD 0%, #E8F4F8 50%, #E1F5FE 100%);
}

.usage-card {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFF8E1 50%, #FFECB3 100%);
}

.prompt-card {
    background: linear-gradient(135deg, #F3E5F5 0%, #F5E8F7 50%, #EDE7F6 100%);
}

.result-card {
    background: linear-gradient(135deg, #FCE4EC 0%, #FFF0F5 50%, #F8BBD0 100%);
}


/* 表单元素 */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background: white;
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #F44336 0%, #D32F2F 100%);
    color: white;
}

.btn-generate {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    font-size: 16px;
    padding: 14px 24px;
    flex-grow: 1;
    /* 填充更多空间 */
}

/* Prompt 卡片中的操作按钮区域 */
.prompt-actions {
    margin-top: auto;
    /* 将按钮推到底部 */
    padding-top: 16px;
    display: flex;
    gap: 10px;
}


/* 上传区域 */
.upload-zone {
    border: 2px dashed rgba(76, 175, 80, 0.3);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.5);
}

.upload-zone.dragover {
    border-color: rgba(76, 175, 80, 0.8);
    background: rgba(232, 245, 233, 0.8);
}

.upload-zone-text {
    font-size: 14px;
    color: #333;
    margin: 8px 0 4px;
}

.upload-zone-hint {
    font-size: 12px;
    color: #666;
}

/* 图片预览 */
.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(76, 175, 80, 0.2);
}

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

.preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(244, 67, 54, 0.9);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
}

.preview-remove:hover {
    background: #F44336;
    transform: scale(1.1);
}

.preview-item .file-size {
    position: absolute;
    bottom: 2px;
    right: 4px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
}

/* 结果展示 */
.result-display {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-display.grid-view {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 10px;
    align-items: center; /* 修改 */
    align-content: start;
}

.result-image-wrapper {
    width: 100%;
    height: 100%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* aspect-ratio: 1 / 1;  <-- 移除此行，不再强制正方形 */
}

.result-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* 统一使用 contain，保证图片完整显示 */
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: scaleIn 0.5s ease-out;
    cursor: zoom-in;
}

/* .grid-view .result-image-wrapper img { <-- 不再需要特殊的 grid 样式，可以直接移除
    object-fit: cover; 
    width: 100%;
    height: 100%;
} */


.empty-state,
.loading-state,
.error-state {
    text-align: center;
    padding: 20px;
}

.empty-icon,
.error-icon {
    font-size: 64px;
    margin-bottom: 20px;
    color: #E91E63;
    opacity: 0.7;
}

.empty-title,
.error-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.empty-text,
.error-text {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

/* 加载状态 */
.loading-spinner-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 30px;
}

.loading-text {
    font-size: 18px;
    font-weight: 600;
    color: #E91E63;
    animation: fade 2s ease-in-out infinite;
}

.loading-hint {
    font-size: 14px;
    color: #F06292;
    margin: 4px 0;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border: 8px solid rgba(233, 30, 99, 0.1);
    border-top-color: #E91E63;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

/* API Key 状态 */
.api-key-status {
    margin-top: 12px;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

.api-key-status.success {
    background: rgba(76, 175, 80, 0.1);
    color: #2E7D32;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.api-key-status.error {
    background: rgba(244, 67, 54, 0.1);
    color: #D32F2F;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* 额度查询卡片 */
.usage-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.usage-main-stats {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.usage-main-stats .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #FF6F00;
}

.usage-main-stats .stat-label {
    font-size: 16px;
    color: #8D6E63;
}

.details-toggle {
    font-size: 13px;
    color: #1976D2;
    cursor: pointer;
    border: none;
    background: none;
    padding: 4px;
}

.usage-details {
    display: none;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    font-size: 12px;
    color: #333;
}

.usage-details p {
    margin: 4px 0;
}

.progress-bar-container {
    width: 100%;
    height: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #FF5722 0%, #FFC107 50%, #4CAF50 100%);
    border-radius: 5px;
    transition: width 0.5s ease-in-out;
}

/* 预设选择器容器 */
.preset-selectors {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 16px;
}

.preset-selectors .form-group {
    margin-bottom: 0;
}

.header-action-btn {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.header-action-btn:hover {
    background: white;
    border-color: #E91E63;
}
.header-action-btn:hover .icon {
    stroke: #E91E63;
}
.header-action-btn .icon {
    width: 20px;
    height: 20px;
    stroke: #666;
    stroke-width: 1.5;
}

/* 图片放大模态框样式 */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s;
}

.image-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.image-modal-close:hover,
.image-modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}


/* 动画 */
@keyframes spin {
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes fade {
    50% {
        opacity: 0.5;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


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

    .right-column .result-card {
        min-height: 500px;
    }
}

@media (max-width: 640px) {
    .header-content {
        padding: 15px 20px;
    }

    .header-logo {
        width: 60px;
    }

    .header-title {
        font-size: 20px;
    }

    .main-content {
        padding: 0 20px;
        gap: 20px;
    }

    .prompt-actions {
        flex-direction: column;
    }
    
    .preset-selectors {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}
