/* 
 * 纹样世界 - Light Theme
 * Clean, Modern, Professional UI
 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --success: #10b981;
    --success-light: #34d399;
    --warning: #f59e0b;
    --error: #ef4444;
    --error-light: #f87171;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-light: #6b7280;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* Header */
.header {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header .container { display: flex; justify-content: space-between; align-items: center; }

.logo {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none;
    font-family: 'Noto Serif SC', serif;
    font-size: 1.4rem; font-weight: 700;
    color: var(--primary);
}
.logo::before { content: '◈'; font-size: 1.6rem; color: var(--accent); }

.nav { display: flex; gap: 4px; }
.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem; font-weight: 500;
    transition: all 0.2s;
}
.nav a:hover { color: var(--primary); background: var(--bg-secondary); }
.nav a.active { color: var(--primary); background: #eef2ff; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px;
    border: none; border-radius: var(--radius-md);
    font-family: inherit; font-size: 0.95rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: all 0.2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-secondary:hover { background: var(--bg-tertiary); }
.btn-success { background: linear-gradient(135deg, var(--success), var(--success-light)); color: #fff; }
.btn-danger { background: linear-gradient(135deg, var(--error), var(--error-light)); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card-header { border-bottom: 1px solid var(--border-light); padding-bottom: 16px; margin-bottom: 20px; }
.card-header h3, .card-title, .card-header .card-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.2rem; font-weight: 600;
    color: var(--primary);
    margin: 0;
}

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500; font-size: 0.9rem;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 1rem; color: var(--text-primary);
    transition: all 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { min-height: 100px; resize: vertical; }

/* Section Title */
.section-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.5rem; font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

/* Page Title */
.page-title {
    text-align: center;
    padding: 40px 0 30px;
    font-family: 'Noto Serif SC', serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}
.page-title h1 {
    font-family: 'Noto Serif SC', serif;
    font-size: 2rem; font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.page-title .subtitle { color: var(--text-light); font-size: 1rem; }

/* Main Content */
.main-content { padding: 20px 0 100px; min-height: calc(100vh - 200px); }

/* Story Cards */
.story-grid, .story-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
label.story-card, .story-card {
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: block;
    font-weight: normal;
    font-size: inherit;
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0;
}
.story-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); }
.story-card.selected { border-color: var(--primary); background: #fafaff; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.story-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.story-card h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin: 0 0 8px 0; }
.story-card p { font-size: 0.9rem; color: var(--text-light); line-height: 1.5; margin: 0; }
.story-card .story-icon { font-size: 2.5rem; margin-bottom: 12px; }
.story-card .story-name { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.story-card .story-desc { font-size: 0.9rem; color: var(--text-light); line-height: 1.5; }

/* Pattern Grid */
.pattern-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.pattern-item {
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.pattern-item:hover { border-color: var(--primary-light); }
.pattern-item.selected { border-color: var(--primary); background: #fafaff; }
.pattern-item input[type="checkbox"] { display: none; }
.pattern-name { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.pattern-desc { font-size: 0.8rem; color: var(--text-muted); }
.required-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 4px;
    margin-left: 4px;
}

/* Ratio Options */
.ratio-options { display: flex; gap: 12px; flex-wrap: wrap; }
label.ratio-option, .ratio-option {
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-width: 80px;
    font-weight: 500;
    color: var(--text-primary);
    display: inline-block;
    font-size: 0.9rem;
}
.ratio-option:hover { border-color: var(--primary-light); }
.ratio-option.selected { border-color: var(--primary); background: #fafaff; }
.ratio-option input[type="radio"] { display: none; }
.ratio-label { font-weight: 600; color: var(--text-primary); }

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 0.95rem;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* History / Results Grid */
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s;
}
.history-item:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.history-image { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--bg-tertiary); }
.history-info { padding: 14px; }
.history-title { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.history-meta { font-size: 0.85rem; color: var(--text-muted); }
.history-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state-text { font-size: 1rem; }

/* Login/Register Forms */
.auth-container { max-width: 400px; margin: 60px auto; }
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}
.auth-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.5rem; font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 30px;
}
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--text-light); }
.auth-footer a { color: var(--primary); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* Footer */
.footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--bg-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .header .container { flex-direction: column; gap: 12px; }
    .nav { width: 100%; justify-content: center; flex-wrap: wrap; }
    .story-grid { grid-template-columns: 1fr; }
    .pattern-grid { grid-template-columns: repeat(2, 1fr); }
    .auth-container { margin: 30px 16px; }
    .auth-card { padding: 24px; }
}

/* Loading State */
.loading { opacity: 0.6; pointer-events: none; }
.loading-spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Badge */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-primary { background: #eef2ff; color: var(--primary); }
.badge-success { background: #ecfdf5; color: var(--success); }
.badge-warning { background: #fffbeb; color: #b45309; }
.badge-danger { background: #fef2f2; color: var(--error); }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-light); }
th { background: var(--bg-secondary); font-weight: 600; color: var(--text-secondary); font-size: 0.85rem; }
tr:hover { background: var(--bg-secondary); }

/* Main Generate Page */
.generate-section { margin-bottom: 30px; }
.generate-section-title {
    font-size: 1.1rem; font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.generate-section-title::before {
    content: '';
    width: 4px; height: 20px;
    background: var(--primary);
    border-radius: 2px;
}

/* Submit Section */
.submit-section {
    background: linear-gradient(135deg, #fafaff 0%, #f5f3ff 100%);
    border: 1px solid #e0e7ff;
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}
.submit-section .btn { min-width: 200px; font-size: 1.1rem; padding: 14px 32px; }

/* Character / Preview Section */
.preview-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text-muted);
}
.preview-placeholder { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }

/* Video Section Styles */
.video-section { margin-top: 30px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 30px; }
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    background: var(--bg-card);
}
.pagination a:hover { background: var(--bg-secondary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
