@import url('https://fonts.loli.net/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
    --primary-text: #202124;
    --secondary-text: #5f6368;
    --brand-color: #1E8E3E;
    --border-color: #DDE1E6;
    --background-gradient: linear-gradient(180deg, #F8FBF8 0%, #E6F2E6 100%);
    --container-bg: rgba(255, 255, 255, 0.8);
    --button-bg: #4A5568;
    --button-hover-bg: #2D3748;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
}

/* SEO和无障碍访问样式 */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 跳转链接（键盘导航） */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--brand-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    font-weight: 500;
}

.skip-link:focus {
    top: 6px;
}

/* 焦点样式增强 */
*:focus {
    outline: 2px solid var(--brand-color);
    outline-offset: 2px;
}

button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--brand-color);
    outline-offset: 2px;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --primary-text: #000000;
        --secondary-text: #333333;
        --brand-color: #0066cc;
        --border-color: #666666;
    }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-text: #e8eaed;
        --secondary-text: #9aa0a6;
        --brand-color: #4fc3f7;
        --border-color: #5f6368;
        --background-gradient: linear-gradient(180deg, #1a1a1a 0%, #2d2d2d 100%);
        --container-bg: rgba(42, 42, 42, 0.8);
        --button-bg: #5f6368;
        --button-hover-bg: #80868b;
    }
    
    body {
        background: var(--background-gradient);
        color: var(--primary-text);
    }
    
    #identity-input,
    .input-area-modal textarea,
    .template-name-input input {
        background-color: #2d2d2d;
        color: var(--primary-text);
        border-color: var(--border-color);
    }
    
    .modal-content {
        background-color: #2d2d2d;
        color: var(--primary-text);
    }
    
    .template-item {
        background-color: #2d2d2d;
        border-color: var(--border-color);
    }
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background-gradient);
    color: var(--primary-text);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    text-align: center;
}

.top-bar {
    width: fit-content;
    margin-top: 24px;
    padding: 8px 16px;
    background-color: #2D3748;
    color: white;
    border-radius: var(--border-radius-lg);
    font-size: 0.9em;
    font-weight: 500;
}

.main-container {
    width: 100%;
    max-width: 680px;
    padding: 20px;
    box-sizing: border-box;
}

header h1 {
    font-size: 3.5em;
    font-weight: 700;
    margin: 40px 0 16px;
}

header h1 strong {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    font-weight: 700;
}

header .subtitle {
    font-size: 1.2em;
    color: var(--secondary-text);
    margin-bottom: 8px;
}

header .quote {
    font-size: 1em;
    color: var(--secondary-text);
    margin-bottom: 40px;
}

.input-area {
    position: relative;
    margin-bottom: 24px;
}

#identity-input {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    font-size: 1em;
    line-height: 1.6;
    box-sizing: border-box;
    resize: vertical;
    background-color: #F8FBF8;
    color: var(--primary-text);
}

#identity-input:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 0 2px rgba(30, 142, 62, 0.2);
}

.textarea-decorator {
    position: absolute;
    top: 16px;
    right: 16px;
    color: var(--brand-color);
    font-size: 1.2em;
}

#generate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 16px;
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 1.1em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#generate-btn:hover {
    background-color: var(--button-hover-bg);
}

#generate-btn:disabled {
    background-color: #999;
    cursor: not-allowed;
}

.hint {
    font-size: 0.9em;
    color: var(--secondary-text);
    margin-top: 16px;
}

#menu-container {
    margin-top: 10px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: auto;
    background-color: transparent;
}

#save-btn {
    margin-top: 24px;
    padding: 12px 25px;
    background-color: var(--brand-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

#save-btn:hover {
    background-color: #1A73E8;
}

footer {
    margin-top: 0px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: var(--secondary-text);
}

footer p {
    margin: 4px 0;
}

.feedback-link-footer, .author-link-footer, .github-link-footer {
    color: var(--brand-color);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: inline-block;
}

.feedback-link-footer:hover, .author-link-footer:hover, .github-link-footer:hover {
    background-color: rgba(30, 142, 62, 0.1);
    transform: translateY(-1px);
    text-decoration: none;
}

/* Menu Styles (re-integrated from minimalist theme) */
.menu-header .menu-title {
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 2.5em;
    font-weight: 700;
    color: var(--primary-text);
    margin-bottom: 15px;
    text-align: center;
}

.menu-header .menu-slogan-cn {
    font-size: 1.2em;
    color: var(--secondary-text);
    margin-bottom: 5px;
    text-align: center;
}

.menu-header .menu-slogan-en {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    font-size: 1.1em;
    color: #7f8c8d;
    margin-bottom: 40px;
    text-align: center;
    letter-spacing: 1px;
}

.menu-body {
    border-top: 1px solid var(--border-color);
    padding-top: 30px;
}

.menu-category-title {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    font-size: 1.8em;
    font-weight: 400;
    color: var(--brand-color);
    text-align: center;
    margin-top: 40px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    letter-spacing: 1px;
}

.menu-body > .menu-category-title:first-child {
    margin-top: 10px;
}

.menu-item {
    margin-bottom: 30px;
}

.menu-item:last-child {
    margin-bottom: 0;
}

.menu-item .dish-name-cn {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--primary-text);
    margin: 0 0 4px;
}

.menu-item .dish-name-en {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    font-size: 1.1em;
    color: var(--secondary-text);
    margin-bottom: 12px;
}

.menu-item .dish-desc {
    font-size: 1em;
    color: #34495e;
    line-height: 1.7;
}

/* Style for capturing the menu as an image with a fixed width */
.menu-for-capture {
    width: 800px !important;
    box-sizing: border-box;
}

/* Styles for controls, moved from index.html */
.controls-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 15px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.template-selector, .size-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}
.radio-group {
    display: inline-flex;
    gap: 10px;
    align-items: center;
}
.radio-group label {
    cursor: pointer;
}
.slider-group {
    display: flex;
    align-items: center;
    gap: 5px;
}
.slider-group input[type="range"] {
    width: 120px;
}
#menu-image {
    display: block;
    max-width: none;
    border-radius: var(--border-radius-lg);
    margin: 0 auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.05);
}
.save-hint {
    margin-top: 16px;
    font-size: 0.9em;
    color: var(--secondary-text);
}

/* Button Group Styles */
.button-group {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.btn-group-item {
    padding: 8px 16px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.9em;
    color: var(--secondary-text);
}

.btn-group-item:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.btn-group-item.active {
    background-color: var(--brand-color);
    color: white;
    font-weight: 500;
}

.btn-group-item:hover:not(.active) {
    background-color: rgba(30, 142, 62, 0.1);
}

/* AI Template Controls */
.ai-template-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: transparent;
    color: var(--secondary-text);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: rgba(30, 142, 62, 0.1);
    border-color: var(--brand-color);
    color: var(--brand-color);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--brand-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: #1A73E8;
}

.btn-primary:disabled {
    background-color: #999;
    cursor: not-allowed;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--primary-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 24px;
}

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

/* Input Method Selector */
.input-method-selector {
    margin-bottom: 24px;
}

.input-area-modal {
    margin-bottom: 20px;
}

.input-area-modal label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--primary-text);
}

.input-area-modal textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 1em;
    line-height: 1.5;
    box-sizing: border-box;
    resize: vertical;
    background-color: #F8FBF8;
}

.input-area-modal textarea:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 0 2px rgba(30, 142, 62, 0.2);
}

/* Image Upload Zone */
.image-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.image-upload-zone:hover {
    border-color: var(--brand-color);
}

.image-upload-zone.dragover {
    border-color: var(--brand-color);
    background-color: rgba(30, 142, 62, 0.05);
}

.upload-placeholder svg {
    color: var(--secondary-text);
    margin-bottom: 16px;
}

.upload-placeholder p {
    margin: 8px 0;
    color: var(--primary-text);
}

.upload-hint {
    font-size: 0.9em;
    color: var(--secondary-text);
}

#image-preview {
    position: relative;
}

#preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}

.btn-remove:hover {
    background-color: rgba(255, 0, 0, 1);
}

/* Template Name Input */
.template-name-input {
    margin-top: 20px;
}

.template-name-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--primary-text);
}

.template-name-input input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 1em;
    box-sizing: border-box;
    background-color: #F8FBF8;
}

.template-name-input input:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 0 2px rgba(30, 142, 62, 0.2);
}

/* Template Manager */
.template-manager-actions {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.template-list {
    max-height: 400px;
    overflow-y: auto;
}

.empty-template-list {
    text-align: center;
    padding: 40px 20px;
    color: var(--secondary-text);
}

.empty-template-list svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Template Thumbnail Styles */
.template-actions button {
    padding: 6px 12px;
    font-size: 0.8em;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-use {
    background-color: var(--brand-color);
    color: white;
    border: none;
}

.btn-use:hover {
    background-color: #1A73E8;
}

.btn-export {
    background-color: transparent;
    color: var(--secondary-text);
    border: 1px solid var(--border-color);
}

.btn-export:hover {
    background-color: rgba(30, 142, 62, 0.1);
    border-color: var(--brand-color);
    color: var(--brand-color);
}

.btn-delete {
    background-color: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.btn-delete:hover {
    background-color: #dc3545;
    color: white;
}

/* Template Item Layout */
.template-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    margin-bottom: 12px;
    background-color: #F8FBF8;
    transition: background-color 0.2s ease;
}

.template-item:hover {
    background-color: rgba(30, 142, 62, 0.05);
}

.template-thumbnail-container {
    flex-shrink: 0;
    width: 120px;
    height: 90px;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.template-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.template-thumbnail:hover {
    transform: scale(1.05);
}

.template-thumbnail-loading,
.template-thumbnail-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--secondary-text);
    font-size: 0.75em;
    text-align: center;
    padding: 8px;
}

.template-thumbnail-loading svg {
    animation: spin 1s linear infinite;
    width: 20px;
    height: 20px;
}

.template-thumbnail-error {
    color: #dc3545;
}

.template-thumbnail-error svg {
    width: 20px;
    height: 20px;
}

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

.template-info {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.template-info h3 {
    margin: 0 0 4px 0;
    font-size: 1.1em;
    color: var(--primary-text);
    font-weight: 600;
}

.template-info p {
    margin: 0;
    font-size: 0.9em;
    color: var(--secondary-text);
}

.template-actions {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .template-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .template-thumbnail-container {
        width: 100%;
        height: 120px;
        align-self: center;
        max-width: 200px;
    }
    
    .template-info {
        text-align: center;
    }
    
    .template-actions {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .template-actions button {
        width: 100%;
        padding: 10px 16px;
        font-size: 0.9em;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .template-list {
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .template-item {
        padding: 12px;
    }
    
    .template-thumbnail-container {
        height: 100px;
        max-width: 160px;
    }
    
    .template-info h3 {
        font-size: 1em;
    }
    
    .template-info p {
        font-size: 0.8em;
    }
    
    .template-actions button {
        padding: 8px 12px;
        font-size: 0.85em;
    }
}

/* Template Preview Modal */
.template-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.template-preview-content {
    background-color: white;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.template-preview-header h3 {
    margin: 0;
    font-size: 1.3em;
    color: var(--primary-text);
}

.template-preview-body {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    background-color: #f8f9fa;
}

.template-preview-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Progress Bar Styles */
.progress-container {
    text-align: center;
    padding: 20px;
}

.progress-container p {
    margin: 0 0 16px 0;
    color: var(--primary-text);
    font-size: 1em;
}

.progress-bar {
    width: 100%;
    max-width: min(680px, 100vw);
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 12px auto;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-color), #1A73E8);
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: progress-shimmer 2s infinite;
}

.progress-text {
    margin: 0;
    font-size: 0.9em;
    color: var(--secondary-text);
    font-weight: 500;
}

@keyframes progress-shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.progress-fill {
    background: linear-gradient(
        90deg,
        var(--brand-color) 0%,
        #1A73E8 50%,
        var(--brand-color) 100%
    );
    background-size: 200px 100%;
    animation: progress-shimmer 2s infinite;
}

/* AI Template Progress Styles */
.ai-template-progress {
    margin-top: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.ai-template-progress .progress-container {
    padding: 0;
}
