/* 全局样式 */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #ec4899;
    --background-dark: #0f172a;
    --background-card: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.1);
    
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --gradient-glow: radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
}

body {
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    background-color: var(--background-dark);
    color: var(--text-main);
    padding-top: 76px;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* 导航栏样式 */
.navbar {
    background-color: rgba(15, 23, 42, 0.8) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
}

.navbar-brand i {
    -webkit-text-fill-color: initial;
    color: #8b5cf6; 
}

.nav-link {
    color: var(--text-muted) !important;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem !important;
    border-radius: 0.5rem;
}

.nav-link:hover {
    color: var(--text-main) !important;
    background-color: rgba(255, 255, 255, 0.05);
}

/* active 状态保持与其它导航文字同色（避免“首页”比“促销价”更亮） */
.nav-link.active {
    color: var(--text-muted) !important;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-link i {
    margin-right: 0.5rem;
    color: var(--secondary-color);
}

/* 按钮样式 */
.btn {
    font-weight: 600;
    border-radius: 0.75rem;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.4);
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

/* 卡片玻璃拟态 */
.card {
    background: var(--background-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.card-title {
    font-weight: 700;
    color: var(--text-main);
}

/* 表单样式 */
.form-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.form-label i {
    color: var(--secondary-color);
}

.form-control, .form-select {
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    background-color: rgba(15, 23, 42, 0.8);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    color: var(--text-main);
}

.form-control::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

/* 生成结果区域 */
#generateResult {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    background: rgba(0, 0, 0, 0.2);
}

/* When we have generated images, allow the preview to fill the container */
#generateResult.has-image {
    display: block;
    padding: 1rem;
}

.generated-result-wrap {
    width: 100%;
}

.generated-preview-frame {
    width: 100%;
    /* 竖图/长图需要完整展示：容器自适应高度，并限制最大高度 */
    height: auto;
    max-height: 72vh;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.generated-preview-img {
    width: 100%;
    height: auto;
    max-height: 72vh;
    object-fit: contain; /* show full image without cropping */
    display: block;
}

.generated-actions .hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.generated-thumbs {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.generated-thumb {
    width: 88px;
    height: 88px;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.generated-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.generated-thumb:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.generated-thumb.active {
    opacity: 1;
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Bootstrap 的 .text-muted 在深色主题下对比度太低：统一映射到我们的主题色 */
.text-muted {
    color: var(--text-muted) !important;
}

.text-muted i {
    color: var(--secondary-color);
    opacity: 0.5;
}

.generated-image {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    position: relative;
    border: 1px solid var(--border-color);
}

.image-toolbar {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.generated-image:hover .image-toolbar {
    opacity: 1;
    transform: translateY(0);
}

.image-toolbar button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    color: white;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-toolbar button:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

/* 历史记录 */
.history-item {
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.history-item:hover img {
    transform: scale(1.1);
}

.history-item .overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* 会员套餐 */
.pricing-card-highlight {
    border: 2px solid var(--primary-color);
    background: linear-gradient(to bottom, rgba(99, 102, 241, 0.1), rgba(30, 41, 59, 0.7));
    position: relative;
    /* 避免顶部徽标被裁切（badge 使用 translate-middle 会超出卡片边界） */
    overflow: visible;
}

.pricing-card-highlight::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

/* Pricing section readability (dark cards + Bootstrap text-muted) */
.list-unstyled li {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

/* Pricing 卡片中，列表文案确保可读（避免某些 Bootstrap 默认色过暗） */
#pricing .list-unstyled li {
    color: rgba(248, 250, 252, 0.92);
}

.list-unstyled li i {
    margin-right: 0.75rem;
    font-size: 0.9rem;
}

.fa-check {
    color: #10b981;
}

.fa-times {
    color: #ef4444;
}

/* 模态框 */
.modal-content {
    background-color: #1e293b;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

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

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* 页脚 */
footer {
    border-top: 1px solid var(--border-color);
    background-color: #0b1120 !important;
}

/* Section 标题 */
h2.text-center {
    font-weight: 800;
    margin-bottom: 3rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

/* Generate hero title (2-line marketing copy) */
.generate-hero {
    position: relative;
    padding-top: 0.25rem;
}

.generate-hero-title {
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0;
    font-size: 2.85rem;
    background: linear-gradient(135deg, #ffffff 0%, rgba(148, 163, 184, 0.95) 55%, rgba(139, 92, 246, 0.95) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.generate-hero-subtitle {
    font-size: 1.12rem;
    line-height: 1.5;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.01em;
    max-width: 920px;
    margin: 0 auto;
}

.generate-hero-accent {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

@media (max-width: 768px) {
    .generate-hero-title {
        font-size: 2.0rem;
    }
    .generate-hero-subtitle {
        font-size: 0.98rem;
    }
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0f172a;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Loading Spinner */
.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.floating-icon {
    animation: float 3s ease-in-out infinite;
}

/* 积分 Badge */
.credit-display {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.badge.bg-warning {
    background: var(--gradient-primary) !important;
    color: white;
    font-weight: 600;
    padding: 0.5rem 1rem;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .card-body {
        padding: 1.5rem;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    h2.text-center {
        font-size: 1.75rem;
    }
}

/* Mobile tweaks (<=576px): reduce fixed sizes to avoid overflow and improve above-the-fold UX */
@media (max-width: 576px) {
    body {
        padding-top: 64px;
    }

    .navbar-brand {
        font-size: 1.15rem;
    }

    .card-body {
        padding: 1.1rem;
    }

    /* Generate hero */
    .generate-hero-title {
        font-size: 1.7rem;
    }
    .generate-hero-subtitle {
        font-size: 0.92rem;
    }

    /* Generated result */
    #generateResult {
        min-height: 320px;
    }
    .generated-preview-frame,
    .generated-preview-img {
        max-height: 60vh;
    }
    .generated-thumb {
        width: 72px;
        height: 72px;
    }

    /* Input images dropzone */
    .input-images-dropzone {
        padding: 12px;
        gap: 10px;
        min-height: 140px;
    }
    .upload-box {
        width: 110px;
        height: 110px;
    }
    .thumbnail-item {
        width: 110px;
        height: 110px;
    }
    .thumbnail-caption {
        width: 110px;
    }
}
/* Input Images Section */
#inputImagesContainer {
    min-height: 120px;
    transition: all 0.3s ease;
}

.upload-box {
    transition: all 0.3s ease;
}

.upload-box:hover {
    border-color: var(--primary-color) !important;
    background: rgba(99, 102, 241, 0.1);
}

.thumbnail-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

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

.thumbnail-item:hover .thumbnail-delete {
    opacity: 1;
}

/* Section copy */
.section-title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.3;
}

/* Input Images dropzone (match reference layout, keep dark theme) */
.input-images-dropzone {
    border: 2px dashed rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.20);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: flex-start;
    min-height: 170px;
}

.upload-box {
    width: 140px;
    height: 140px;
    cursor: pointer;
    border: 2px dashed rgba(255,255,255,0.18);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.35);
    transition: all 0.25s ease;
}

.upload-box:hover {
    border-color: rgba(99, 102, 241, 0.55);
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-main);
}

.upload-box-text {
    font-size: 0.85rem;
}

.thumbnail-item {
    width: 140px;
    height: 140px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.35);
    position: relative;
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}


.thumbnail-caption {
    margin-top: 8px;
    width: 140px;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.25;
}

.thumbnail-caption .name {
    color: var(--text-main);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thumbnail-caption .meta {
    opacity: 0.7;
}

.thumbnail-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
    border: 1px solid rgba(255,255,255,0.12);
}

/* Quality Buttons */
.quality-btn {
    border-color: var(--border-color);
    color: var(--text-muted);
}

.quality-btn:hover {
    background-color: rgba(15, 23, 42, 0.04);
    color: var(--text-main);
    border-color: var(--border-color);
}

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

/* Ratio Popup Styles */
#sizePopup .ratio-btn {
    border-radius: 6px;
    font-weight: 500;
}

#sizePopup .ratio-btn:hover {
    background-color: #f1f5f9;
    color: #1e293b;
    border-color: #cbd5e1;
}

#sizePopup .ratio-btn.active {
    background-color: #0f172a !important; /* Black/Dark for active */
    color: white !important;
    border-color: #0f172a !important;
}

