:root {
    --primary-color: #8b5cf6;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --error-color: #dc3545;
    --background-base: linear-gradient(135deg, #0a0e27 0%, #1a1a3e 50%, #0d0f1e 100%);
    --text-color: #e0e0e0;
    --border-color: rgba(255, 255, 255, 0.1);
    --box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3), 0 8px 32px rgba(139, 92, 246, 0.2);
    --background-dark: rgba(50, 50, 50, 0.95);
    --text-dark: #ffffff;
}

.dark-mode {
    --background-base: var(--background-dark);
    --text-color: var(--text-dark);
    --border-color: rgba(255, 255, 255, 0.1);
    --box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3), 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1a3e 50%, #0d0f1e 100%);
    min-height: 100vh;
    color: #e0e0e0;
    position: relative;
    overflow-x: hidden;
}

.background-blur {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 20px 120px;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    text-align: left;
    margin-bottom: 50px;
    padding-top: 40px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.header-content h1 {
    font-size: 3em;
    margin-bottom: 0;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -1px;
}

.header-content p {
    font-size: 1.1em;
    color: #a0aec0;
    font-weight: 300;
    letter-spacing: 0.5px;
    text-align: left;
    margin-bottom: 10px;
}

/* User Info */
.user-info {
    padding: 12px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeInUp 0.6s ease-out;
    align-self: flex-end;
    margin-bottom:-2em;
}

.user-info.hidden {
    display: none;
}

.user-details {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
    flex: 1;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name {
    color: #e0e0e0;
    font-weight: 500;
    font-size: 0.95em;
    flex-shrink: 0;
}

.history-link {
    color: #06b6d4;
    text-decoration: none;
    font-size: 0.9em;
    padding: 6px 12px;
    border-radius: 15px;
    background: rgba(6, 182, 212, 0.1);
    border: 1.5px solid rgba(6, 182, 212, 0.3);
    transition: all 0.3s ease;
    font-weight: 400;
    display: inline-block;
    line-height: 1.2;
    vertical-align: middle;
}

.history-link:hover {
    background: rgba(6, 182, 212, 0.2);
    border-color: rgba(6, 182, 212, 0.5);
    color: #0891b2;
    text-decoration: none;
    transform: translateY(-1px);
}

.logout-btn {
    background: rgba(220, 53, 69, 0.15);
    color: #f8d7da;
    border: 1.5px solid rgba(220, 53, 69, 0.4);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    cursor: pointer;
    font-weight: 300;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: inline-block;
    line-height: 1.2;
    vertical-align: middle;
}

.logout-btn:hover {
    background: rgba(220, 53, 69, 0.25);
    border-color: rgba(220, 53, 69, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

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

/* Glass Effect */
.glass-effect {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
}

/* File preview animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.upload-area .upload-prompt {
    transition: all 0.4s ease;
}

.upload-area.show-preview .upload-prompt {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.selected-file {
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
    transition: opacity 0.3s ease;
}

.file-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
}

.preview-image,
.pdf-icon {
    width: 120px;
    height: 120px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    margin-bottom: 10px;
}

.preview-image {
    object-fit: cover;
    width: 100%;
    max-width: 200px;
    height: auto;
}

.file-name {
    font-weight: 600;
    color: #f0f0f0;
    text-align: center;
    word-break: break-all;
}

.file-size {
    color: #a0aec0;
    font-size: 0.9em;
}

/* Keep preview during processing */
.progress-with-preview {
    position: relative;
}

.progress-with-preview .selected-file {
    position: absolute;
    top: -150px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 15px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Upload Area */
.upload-area {
    padding: 80px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.upload-area:hover::before,
.upload-area.dragover::before {
    opacity: 1;
}

.upload-icon {
    font-size: 5em;
    margin-bottom: 20px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

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

.upload-title {
    font-size: 1.3em;
    margin-bottom: 5px;
    color: #f0f0f0;
    font-weight: 600;
}

.upload-subtitle {
    font-size: 0.95em;
    margin-bottom: 30px;
    color: #a0aec0;
}

#file-input {
    display: none;
}

.btn-primary {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1.5px solid rgba(139, 92, 246, 0.4);
    padding: 14px 40px;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.btn-primary:hover {
    background: rgba(139, 92, 246, 0.25);
    border-color: rgba(139, 92, 246, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.3);
}

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

/* Progress */
.progress {
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.progress p {
    font-size: 1.1em;
    color: #e0e0e0;
    margin-bottom: 20px;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #3b82f6 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* Results */
.results {
    padding: 40px;
    position: relative;
    animation: fadeInUp 0.6s ease-out;
    opacity: 0;
    transform: translateY(30px);
}

.results.show {
    opacity: 1;
    transform: translateY(0);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.results-header h2 {
    font-size: 2.2em;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.results-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1.5px solid rgba(139, 92, 246, 0.4);
    padding: 5px 20px;
    border-radius: 25px;
    font-size: 0.9em;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover {
    background: rgba(139, 92, 246, 0.25);
    border-color: rgba(139, 92, 246, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.3);
    color: #a78bfa;
    text-decoration: none;
}

/* Markdown Wrapper and Copy Button */
.markdown-wrapper {
    position: relative;
    margin-bottom: 30px;
}

.copy-btn {
    position: absolute;
    top: 20px;
    right: 2em;
    background: rgba(59, 130, 246, 0.15);
    color: #06b6d4;
    border: 1.5px solid rgba(59, 130, 246, 0.4);
    border-radius: 25px;
    padding: 8px 14px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    font-weight: 500;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.copy-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

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

.copy-btn.copied {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #06d6a0;
}

/* Markdown Container */
.markdown-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 25px;
    padding: 70px 30px 25px 30px;
    margin-bottom: 25px;
    line-height: 1.8;
    font-size: 1em;
    max-height: calc(70vh - 120px); /* 减少高度避免与footer重叠 */
    overflow-y: auto;
    color: #e0e0e0;
    scrollbar-width: thin; /* Firefox滚动条宽度 */
    scrollbar-color: rgba(139, 92, 246, 0.3) rgba(139, 92, 246, 0.1); /* Firefox滚动条颜色 */
    /* 添加内边距来避免滚动条超出圆角范围 */
    padding-right: 35px; /* 为滚动条留出空间 */
}

/* Markdown Specific Styles */
.markdown-container h1,
.markdown-container h2,
.markdown-container h3,
.markdown-container h4,
.markdown-container h5,
.markdown-container h6 {
    color: #ffffff;
    margin-top: 2em;
    margin-bottom: 1em;
    font-weight: 600;
}

.markdown-container h1 {
    font-size: 2.2em;
    border-bottom: 2px solid rgba(139, 92, 246, 0.5);
    padding-bottom: 0.5em;
}

.markdown-container h2 {
    font-size: 1.8em;
    border-bottom: 1px solid rgba(139, 92, 246, 0.3);
    padding-bottom: 0.3em;
}

.markdown-container h3 {
    font-size: 1.5em;
    color: #e8d4f8;
}

.markdown-container p {
    margin-bottom: 1em;
    color: #d0d0d0;
}

.markdown-container strong,
.markdown-container b {
    color: #ffffff;
    font-weight: 700;
}

.markdown-container em,
.markdown-container i {
    color: #d0a8f2;
    font-style: italic;
}

.markdown-container blockquote {
    border-left: 4px solid #8b5cf6;
    margin: 1.5em 0;
    padding: 0.5em 1em;
    background: rgba(139, 92, 246, 0.1);
    color: #b0b0b0;
    font-style: italic;
}

.markdown-container ul,
.markdown-container ol {
    margin: 1em 0;
    padding-left: 2em;
}

.markdown-container li {
    margin-bottom: 0.5em;
    color: #d0d0d0;
}

.markdown-container code {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.markdown-container pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 1em;
    overflow-x: auto;
    margin: 1em 0;
}

.markdown-container pre code {
    background: none;
    padding: 0;
    color: #a78bfa;
    font-size: 0.95em;
}

/* Markdown Tables */
.markdown-container table.markdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.markdown-container th,
.markdown-container td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-container th {
    background: rgba(139, 92, 246, 0.2);
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9em;
}

.markdown-container tbody tr:nth-child(even) {
    background: rgba(139, 92, 246, 0.05);
}

.markdown-container tbody tr:hover {
    background: rgba(139, 92, 246, 0.15);
}

/* Markdown Images */
.markdown-container img.markdown-image {
    max-width: 100%;
    height: auto;
    margin: 1em 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.markdown-container img.markdown-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

/* Markdown Links */
.markdown-container a.markdown-link {
    color: #8b5cf6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.markdown-container a.markdown-link:hover {
    color: #a78bfa;
    text-decoration: underline;
}

/* Line breaks */
.markdown-container br.markdown-br {
    display: block;
    margin: 0.5em 0;
}

/* Markdown styling */
.markdown-container h1 {
    font-size: 2.5em;
    margin-top: 40px;
    margin-bottom: 20px;
    color: #ffffff;
    border-bottom: 3px solid rgba(139, 92, 246, 0.5);
    padding-bottom: 15px;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.5px;
    animation: fadeInUp 0.6s ease-out 0.4s both;
    position: relative;
}

.markdown-container h1::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    border-radius: 2px;
}

.markdown-container h2 {
    font-size: 1.6em;
    margin-top: 25px;
    margin-bottom: 12px;
    color: #e8d4f8;
}

.markdown-container h3 {
    font-size: 1.3em;
    margin-top: 20px;
    margin-bottom: 10px;
    color: #d0a8f2;
}

.markdown-container p {
    margin-bottom: 15px;
    color: #d0d0d0;
    line-height: 1.7;
}

.markdown-container img {
    max-width: 100%;
    height: auto;
    margin: 20px 0;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.2);
    transition: transform 0.3s ease;
}

.markdown-container img:hover {
    transform: scale(1.02);
}

.markdown-container a {
    color: #8b5cf6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.markdown-container a:hover {
    color: #a78bfa;
    text-decoration: underline;
}

.markdown-container ul,
.markdown-container ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.markdown-container li {
    margin-bottom: 8px;
    color: #d0d0d0;
}

.markdown-container blockquote {
    border-left: 4px solid #8b5cf6;
    padding-left: 15px;
    margin-left: 0;
    margin-bottom: 15px;
    color: #b0b0b0;
    font-style: italic;
}

.markdown-container code {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.markdown-container pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    margin-bottom: 15px;
}

.markdown-container pre code {
    background: none;
    color: #a78bfa;
    padding: 0;
}

/* Scrollbar styling */
.markdown-container::-webkit-scrollbar {
    width: 8px;
}

.markdown-container::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.1);
    border-radius: 10px;
    margin: 25px 0; /* 添加上下边距，使滚动条不超出圆角范围 */
}

.markdown-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 10px;
}

.markdown-container::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

.markdown-container::-webkit-scrollbar-corner {
    background: transparent;
}


/* Download Section */
.download-section {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-download {
    display: inline-block;
    background: rgba(59, 130, 246, 0.15);
    color: #06b6d4;
    padding: 14px 30px;
    text-decoration: none;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-size: 1em;
    font-weight: 600;
    border: 1.5px solid rgba(59, 130, 246, 0.4);
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.btn-download:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
    text-decoration: none;
    color: #06b6d4;
}

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

/* Error */
.error {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 25px;
    padding: 20px;
    margin-bottom: 30px;
    font-weight: 500;
    animation: slideUp 0.5s ease;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive */
/* Upload Controls Layout */
.upload-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    height: 450px;
    align-items: stretch;
}

.upload-left {
    flex: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 20px;
}

.upload-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 20px;
}

.format-area {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.format-header {
    margin-bottom: 10px;
}

.format-title {
    font-size: 1.2em;
    color: #f0f0f0;
    font-weight: 600;
    margin-bottom: 5px;
}

.format-subtitle {
    font-size: 0.85em;
    color: #a0aec0;
    font-weight: 400;
    margin-bottom: 15px;
    line-height: 1.4;
}

#format-select {
    width: 100%;
    max-width: 200px;
    padding: 12px 16px;
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 15px;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #ffffff;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.1);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
}

#format-select:hover {
    background-color: rgba(40, 40, 40, 0.95);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.2);
}

#format-select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3), 0 8px 32px rgba(139, 92, 246, 0.2);
    background: rgba(50, 50, 50, 0.95);
}

/* 由于浏览器对option样式支持有限，我们使用更暗的背景来确保可读性 */
#format-select option {
    background: rgba(20, 20, 20, 0.95);
    color: #ffffff;
    padding: 8px 12px;
    font-size: 1em;
}

#format-select option:checked {
    background: rgba(139, 92, 246, 0.4);
    color: #ffffff;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
        max-width: 100%;
    }
    
    .header-content h1 {
        font-size: 2em;
    }
    
    .header-content p {
        font-size: 0.95em;
    }

    /* 用户容器移动端优化：移到副标题下方后，一行1:1:1布局 */
    .user-info {
        margin-top: 3px;
        justify-content: center;
        padding: 8px 12px;
        margin-bottom: -2em;
    }

    .user-details {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 0;
        flex-wrap: nowrap;
        margin-left: 2em;
    }

    .user-name {
        flex: 1;
        text-align: center;
        font-size: 0.85em;
        padding: 3px 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
    }

    .user-actions {
        flex: 2;
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        gap: 0;
        margin-left: 0;
        flex-wrap: nowrap;
    }

    .history-link,
    .logout-btn {
        text-decoration: none;
        font-size: 0.9em;
        padding: 6px 12px;
        border-radius: 15px;
        transition: all 0.3s ease;
        font-weight: 300;
        display: inline-block;
        line-height: 1.2;
        vertical-align: middle;
    }
    
    .upload-controls {
        flex-direction: column;
        gap: 20px; /* 统一垂直间距 */
        height: auto;
        min-height: 400px;
        margin-bottom: 20px; /* 统一底部间距 */
    }
    
    .upload-area {
        padding: 30px 20px; /* 减少padding */
        min-height: 180px; /* 适中高度 */
        margin-bottom: 0; /* 移除额外间距 */
    }
    
    .upload-left,
    .upload-right {
        flex: 1;
        padding: 30px 20px; /* 统一padding */
    }
    
    .format-area {
        padding: 30px 20px;
        gap: 15px;
    }
    
    .upload-icon {
        font-size: 3.5em;
    }
    
    .upload-title {
        font-size: 1.1em;
    }
    
    .upload-subtitle {
        margin-bottom: 15px; /* 减少间距 */
    }
    
    .btn-primary {
        padding: 12px 30px;
        font-size: 0.95em;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .results-header h2 {
        font-size: 1.8em;
    }
    
    .download-section {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-download {
        width: 100%;
        text-align: center;
        padding: 12px 20px;
    }
    
    .markdown-container {
        max-height: calc(50vh - 120px); /* 调整高度避免footer重叠 */
        padding: 20px;
        font-size: 0.95em;
        line-height: 1.6;
        margin-bottom: 20px; /* 统一底部间距 */
    }
    
    .markdown-container h1 {
        font-size: 2em;
        margin-top: 30px;
        margin-bottom: 15px;
    }
    
    .copy-btn {
        position: static;
        margin-bottom: 10px;
        width: 100%;
        text-align: center;
    }
    
    .progress {
        padding: 25px 20px; /* 减少padding */
        margin-bottom: 20px; /* 统一底部间距 */
        max-height: calc(40vh - 100px); /* 限制高度避免重叠 */
    }
    
    .error {
        padding: 15px;
        margin-bottom: 20px; /* 统一底部间距 */
        font-size: 0.95em;
    }
    
    .results {
        padding: 20px; /* 统一padding */
        margin-bottom: 20px; /* 统一底部间距 */
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .header-content h1 {
        font-size: 1.6em;
    }
    
    .upload-area {
        padding: 40px 10px;
    }
    
    .upload-icon {
        font-size: 3em;
    }
    
    .btn-primary {
        padding: 12px 30px;
        font-size: 0.95em;
    }
    
    .results {
        padding: 20px;
    }
    
    .markdown-container h1 {
        font-size: 1.5em;
    }
    
    .markdown-container h2 {
        font-size: 1.2em;
    }
}

/* File Preview Styles */
.selected-file {
    display: none;
    margin-top: 20px;
    text-align: center;
}

.file-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 25px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    max-width: 280px;
    width: 100%;
    margin: 0 auto;
}

.preview-image {
    max-width: 150px;
    max-height: 150px;
    border-radius: 15px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.pdf-icon {
    font-size: 3em;
    opacity: 0.7;
}

.file-name {
    font-weight: 600;
    color: #f0f0f0;
    font-size: 0.9em;
    text-align: center;
    word-break: break-all;
    max-width: 200px;
}

.file-size {
    color: #a0aec0;
    font-size: 0.8em;
}

/* Upload area with file selected state */
.upload-area.has-file {
    padding: 30px 20px;
    justify-content: center;
    flex-direction: column;
    align-items: center;
}

.upload-area.has-file .upload-icon,
.upload-area.has-file .upload-title,
.upload-area.has-file .upload-subtitle {
    display: none;
}

.upload-area.has-file .selected-file {
    margin-top: 0;
    margin-bottom: 10px;
    order: -1;
}

.upload-area.has-file #upload-btn {
    order: 1;
    margin-top: 0;
}
/* Footer Styles */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px 30px 0 0;
    padding: 20px;
    text-align: left;
    z-index: 1000;
    color: #a0aec0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-top {
    font-size: 1.4em;
    text-align: left;
    padding-left: 0;
    font-weight: bold;
    color: #ffffff;
}

.footer-top a {
    color: #ffffff;
    text-decoration: none;
}

.footer-top a:hover {
    color: #a78bfa;
}

.footer-bottom {
    display: flex;
    justify-content: flex-start;
    gap: 30px;
    text-align: left;
    padding-left: 0;
    font-size: 0.85em;
}

/* Mobile Responsive for Footer */
@media (max-width: 768px) {
    .footer {
        position: static; /* 改为静态定位，成为文档流的一部分 */
        left: auto;
        right: auto;
        bottom: auto;
        width: auto;
        max-width: 100%;
        margin: 10px 10px 10px 10px; /* 两侧保留适度边距 */
        padding: 15px;
        border-radius: 20px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: auto; /* 移除z-index覆盖 */
    }

    .footer-content {
        align-items: center;
        text-align: center;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        justify-content: center;
    }

    .footer-top {
        font-size: 1.2em;
        text-align: center;
        padding-left: 0;
    }
}

.footer-bottom p {
    margin: 0;
}

/* 保存任务模态框样式 */
.save-task-form {
    margin-bottom: 20px;
}

.save-task-form label {
    display: block;
    margin-bottom: 8px;
    color: #ffffff;
    font-weight: 500;
}

.save-task-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 15px;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #ffffff;
    font-size: 1em;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.1);
}

.save-task-form input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3), 0 8px 32px rgba(139, 92, 246, 0.2);
    background: rgba(50, 50, 50, 0.95);
}

.save-task-form input::placeholder {
    color: #a0aec0;
}

/* 模态框通用样式已在history.css中定义，这里补充一些通用样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 1.3em;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.modal-body {
    padding: 25px 30px;
    max-height: 50vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 768px) {
    .footer-nav {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .results-actions {
        justify-content: center;
    }
    
    .user-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 20px;
    }
}

@media (min-width: 901px) {
    .footer {
        left: auto;
        width: 470px;
        margin: 0;
        max-width: none;
        right: calc((100vw - 860px) / 2);
    }
}