/* style.css - 完美适配 Windows/Mac 的现代字体方案 */

/* ===== CSS Variables ===== */
:root {
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --primary-light: rgba(245, 158, 11, 0.15);
    --primary-glow: rgba(245, 158, 11, 0.4);
    --bg-dark: #0a0a0b;
    --bg-card: #151517;
    --bg-card-hover: #1c1c1f;
    --bg-input: #1a1a1d;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border-color: #27272a;
    --border-light: #3f3f46;
    --error: #ef4444;
    --success: #22c55e;
    --glass-bg: rgba(21, 21, 23, 0.9);
    --glass-border: rgba(255, 255, 255, 0.06);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 40px -10px var(--primary-glow);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family:
        "MiSans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI",
        sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    /* 字体抗锯齿优化，让字体看起来更细更清晰 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background gradient */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(
            ellipse 80% 50% at 20% 10%,
            rgba(245, 158, 11, 0.12) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse 60% 40% at 80% 90%,
            rgba(168, 85, 247, 0.08) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse 50% 50% at 50% 50%,
            rgba(6, 182, 212, 0.05) 0%,
            transparent 60%
        );
    pointer-events: none;
    z-index: -1;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
}
.glass-light {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}

/* ===== Page Layout ===== */
.page {
    display: none;
    min-height: 100vh;
}
.page.active {
    display: block;
}

/* ===== Login Page ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: fadeInUp 0.5s ease-out;
}
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}
.logo-icon {
    font-size: 44px;
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-8px) rotate(5deg);
    }
}
.logo h1 {
    font-size: 26px;
    font-weight: 700;
    background: linear-gradient(
        135deg,
        var(--primary) 0%,
        #fcd34d 50%,
        var(--primary) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s linear infinite;
    /* 标题强制使用最粗的字重 */
    font-weight: 800;
}
@keyframes shimmer {
    to {
        background-position: 200% center;
    }
}
.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.input-group {
    margin-bottom: 20px;
}
.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.input-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.2s ease;
    /* 输入框继承全局现代字体 */
    font-family: inherit;
}
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.error-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    color: var(--error);
    font-size: 14px;
    text-align: center;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #f97316 100%);
    color: #000;
    width: 100%;
    position: relative;
    overflow: hidden;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px -8px rgba(245, 158, 11, 0.5);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-full);
}
.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}
.btn-large {
    padding: 16px 32px;
    font-size: 16px;
    margin-top: 20px;
    border-radius: var(--radius-lg);
}

/* ===== App Header ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--glass-border);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-icon-small {
    font-size: 26px;
}
.app-title {
    font-size: 17px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), #fcd34d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ===== App Main ===== */
.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 40px;
}
.main-content {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 40px;
}
.prompt-section {
    order: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.upload-section {
    order: 1;
    position: sticky;
    top: 80px;
}

.section-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}
.section-title svg {
    color: var(--primary);
    flex-shrink: 0;
}
.section-title .hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

/* ===== Upload Section ===== */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.upload-slot {
    position: relative;
    aspect-ratio: 1;
}
.file-input {
    display: none;
}
.upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}
.upload-label:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
    border-style: solid;
}
.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}
.image-preview {
    position: relative;
    width: 100%;
    height: 100%;
}
.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 3px 8px;
    background: var(--primary);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-full);
}
.remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.remove-btn:hover {
    background: var(--error);
    transform: scale(1.1);
}

/* ===== Prompt Section ===== */
.prompt-textarea {
    width: 100%;
    flex: 1;
    min-height: 160px;
    padding: 16px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 15px;
    resize: vertical;
    font-family: inherit;
}
.prompt-textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.prompt-tips {
    padding: 12px 14px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.prompt-tips em {
    color: var(--primary);
    font-style: normal;
    font-weight: 600;
    background: var(--primary-light);
    padding: 1px 6px;
    border-radius: 4px;
}
.settings-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.setting-item {
    flex: 1;
}
.setting-item label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.select-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}

/* ===== Result Section ===== */
.result-section {
    margin-top: 32px;
    animation: fadeInUp 0.4s ease-out;
}
.result-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.result-item {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}
.result-text {
    padding: 16px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    border-top: 1px solid var(--border-color);
    white-space: pre-wrap;
}

/* ===== Thinking Feature ===== */
.thinking-item {
    background: rgba(255, 255, 255, 0.02);
}
.thinking-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    user-select: none;
    font-size: 14px;
    font-weight: 500;
}
.thinking-header:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--primary);
}
.thinking-header .chevron {
    margin-left: auto;
    transition: transform 0.3s;
    opacity: 0.5;
}
.thinking-header .chevron.rotated {
    transform: rotate(180deg);
}
.thinking-content {
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 800px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}
.thinking-content.collapsed {
    max-height: 0;
    border-top-color: transparent;
}
.thinking-content pre {
    margin: 0;
    padding: 16px;
    /* 代码块/思考过程 使用现代等宽字体 */
    font-family: "JetBrains Mono", "Fira Code", "Consolas", "Monaco", monospace;
    font-size: 13px;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===== Enhanced Image Display ===== */
.result-image {
    width: 100%;
    min-height: 200px;
    background: #000;
    display: block;
}
.result-image:not([src]),
.result-image[src=""] {
    min-height: 300px;
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
}
@keyframes skeletonLoading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.result-actions {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}
.btn-download {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
    border-radius: var(--radius-md);
    justify-content: center;
}
.btn-download:hover {
    background: var(--border-color);
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
    border-color: var(--primary);
}

/* ===== Loading ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.loading-content {
    text-align: center;
    padding: 40px 48px;
    border-radius: var(--radius-xl);
}
.loading-spinner {
    width: 52px;
    height: 52px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.loading-text {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
}
.loading-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }
}
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .prompt-section {
        order: 1;
    }
    .upload-section {
        order: 2;
        position: static;
    }
    .upload-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
