/* ============================================================================
   LaTeX → Word — 学术风格样式表
   设计理念：学术期刊 × 现代极简
   色调：深蓝黑底 + 象牙白卡 + 金铜点缀
   ============================================================================ */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
    /* 核心色板 */
    --ink: #1a1d23;             /* 墨黑 — 主文字 */
    --ink-light: #4a5568;       /* 浅墨 — 辅助文字 */
    --paper: #faf9f6;           /* 纸白 — 卡片背景 */
    --paper-dark: #f0ede6;      /* 旧纸 — 次级背景 */
    --navy: #1e3a5f;            /* 深蓝 — 主题色 */
    --navy-light: #2c5282;      /* 亮蓝 — 悬停 */
    --gold: #b8860b;            /* 金铜 — 点缀 */
    --gold-light: #d4a853;      /* 亮金 — 悬停 */
    --border: #e2dcd0;          /* 边框 */
    --border-dark: #c4b99a;     /* 深边框 */
    --success: #2d6a4f;         /* 墨绿 — 成功 */
    --error: #9b2c2c;           /* 暗红 — 错误 */
    --warning: #b7791f;         /* 琥珀 — 警告 */

    /* 尺寸 */
    --radius: 3px;
    --radius-lg: 6px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-elevated: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

    /* 字体 — 基于系统原生字体，零外部依赖，保证中英文混排品质 */
    --font-display: 'Georgia', 'Times New Roman', 'Noto Serif SC', 'SimSun', 'STSong', serif;
    --font-body:    'Georgia', 'Palatino Linotype', 'Book Antiqua', 'Noto Serif SC', 'STSong', 'PingFang SC', 'Microsoft YaHei', serif;
    --font-mono:    'Consolas', 'SF Mono', 'Cascadia Code', 'Courier New', monospace;

    /* 过渡 */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    background: #f5f1eb;
    color: var(--ink);
    line-height: 1.8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Subtle background texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(30,58,95,0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(184,134,11,0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* --------------------------------------------------------------------------
   Top Bar — 学术顶栏
   -------------------------------------------------------------------------- */
.topbar {
    background: var(--navy);
    color: rgba(255,255,255,0.8);
    padding: 10px 0;
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 0.8px;
    position: relative;
    z-index: 10;
}

.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-brand {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 15px;
    color: var(--gold-light);
    letter-spacing: 0.6px;
}

.topbar-version {
    font-family: var(--font-mono);
    font-size: 11px;
    opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Header — 标题区
   -------------------------------------------------------------------------- */
.header {
    background: var(--navy);
    color: var(--paper);
    padding: 56px 0 64px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.header::after {
    content: '';
    display: block;
    width: 60px;
    height: 2px;
    background: var(--gold);
    margin: 32px auto 0;
    opacity: 0.6;
}

.header h1 {
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 400;
    letter-spacing: 2px;
    margin-bottom: 14px;
    line-height: 1.25;
}

.header h1 .accent {
    color: var(--gold-light);
    font-style: italic;
}

.header .subtitle {
    font-family: var(--font-body);
    font-size: 15px;
    color: rgba(255,255,255,0.5);
    font-weight: 400;
    letter-spacing: 0.6px;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.8;
}

/* --------------------------------------------------------------------------
   Main Layout
   -------------------------------------------------------------------------- */
.main {
    flex: 1;
    padding: 48px 0 80px;
    position: relative;
    z-index: 1;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 32px;
}

/* 双列布局 */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-bottom: 28px;
}

@media (max-width: 768px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

/* --------------------------------------------------------------------------
   Section Heading
   -------------------------------------------------------------------------- */
.section-heading {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 400;
    color: var(--navy);
    letter-spacing: 0.8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-heading .num {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--gold);
    background: rgba(184,134,11,0.08);
    padding: 2px 8px;
    border-radius: 2px;
    letter-spacing: 0;
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-card);
}

/* --------------------------------------------------------------------------
   Tab Bar — 文本转换 / 文档修复切换
   -------------------------------------------------------------------------- */
.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: -1px;
    position: relative;
    z-index: 2;
}

.tab-btn {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 400;
    padding: 14px 32px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    cursor: pointer;
    color: var(--ink-light);
    letter-spacing: 1px;
    transition: all 0.2s var(--ease);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.tab-btn:hover {
    color: var(--navy);
    background: rgba(30,58,95,0.03);
}

.tab-btn.active {
    color: var(--navy);
    background: var(--paper);
    border-color: var(--border);
    font-weight: 600;
}

.tab-panel {
    display: none;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-card);
}

.tab-panel.active {
    display: block;
}

/* Text Conversion tab: border radius on left too */
.tab-panel:first-of-type.active {
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
}

/* --------------------------------------------------------------------------
   Textarea
   -------------------------------------------------------------------------- */
.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 400;
    color: var(--navy);
    letter-spacing: 0.6px;
    margin-bottom: 12px;
}

textarea#latexInput {
    width: 100%;
    min-height: 240px;
    padding: 20px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.9;
    color: var(--ink);
    background: #fdfcf9;
    resize: vertical;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
    outline: none;
}

textarea#latexInput:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(30,58,95,0.08);
}

textarea#latexInput::placeholder {
    color: #b0a894;
    font-family: var(--font-body);
    font-size: 14px;
    font-style: italic;
    letter-spacing: 0.3px;
    line-height: 1.8;
}

.char-count {
    text-align: right;
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--ink-light);
    margin-top: 8px;
    letter-spacing: 0.5px;
    font-style: italic;
}

/* --------------------------------------------------------------------------
   File Upload — 文档修复 Tab
   -------------------------------------------------------------------------- */
.file-drop-zone {
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    background: #fdfcf9;
}

.file-drop-zone:hover {
    border-color: var(--navy);
    background: rgba(30,58,95,0.02);
}

.file-drop-zone.has-file {
    border-style: solid;
    border-color: var(--navy);
    background: rgba(30,58,95,0.03);
}

.file-drop-zone .file-icon {
    font-family: var(--font-display);
    font-size: 18px;
    font-style: italic;
    color: var(--navy);
    opacity: 0.5;
    margin-bottom: 12px;
    display: block;
    letter-spacing: 1px;
}

.file-drop-zone .file-hint {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink-light);
    line-height: 1.8;
    letter-spacing: 0.3px;
}

.file-drop-zone .file-hint strong {
    color: var(--navy);
    font-weight: 600;
}

.file-drop-zone .file-name-display {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--navy);
    margin-top: 8px;
    display: none;
}

.file-drop-zone.has-file .file-name-display {
    display: block;
}

.file-drop-zone.has-file .file-hint {
    display: none;
}

input[type="file"] {
    display: none;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn-row {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 32px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    letter-spacing: 0.5px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.btn-primary {
    background: var(--navy);
    color: var(--paper);
}

.btn-primary:hover {
    background: var(--navy-light);
    box-shadow: 0 2px 8px rgba(30,58,95,0.25);
    transform: translateY(-1px);
}

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

.btn-primary:disabled {
    background: #8a9ab0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.btn-secondary:hover {
    background: rgba(30,58,95,0.04);
    border-color: var(--navy);
}

.btn-icon {
    font-size: 16px;
}

.shortcut-hint {
    font-size: 12px;
    color: var(--ink-light);
    font-family: var(--font-body);
    font-style: italic;
    letter-spacing: 0.5px;
}

/* Format Select */
.format-select {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--navy);
    background: var(--paper);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: 12px 36px 12px 16px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231e3a5f' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    letter-spacing: 0.4px;
    transition: border-color 0.2s var(--ease);
    outline: none;
}

.format-select:focus {
    border-color: var(--navy);
}

.format-select:hover {
    border-color: var(--navy);
}

/* Loading state */
.btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Preview Area
   -------------------------------------------------------------------------- */
.preview-section {
    margin-top: 24px;
}

.preview-label {
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--ink-light);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.preview-box {
    background: #fdfcf9;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 60px;
    font-size: 16px;
    line-height: 2;
    overflow-x: auto;
}

.preview-empty {
    color: #b0a894;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 14px;
    letter-spacing: 0.4px;
    text-align: center;
    padding: 20px;
}

/* --------------------------------------------------------------------------
   Report
   -------------------------------------------------------------------------- */
.report-section {
    margin-top: 20px;
    display: none;
}

.report-section.visible {
    display: block;
    animation: fadeIn 0.35s var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.report-content {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.8;
    color: var(--ink);
    padding: 20px 24px;
    background: #fdfcf9;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    border-left: 3px solid var(--navy);
}

.report-content.error {
    border-left-color: var(--error);
}

/* --------------------------------------------------------------------------
   Info Cards Grid
   -------------------------------------------------------------------------- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 32px;
}

@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
}

.info-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.info-card .info-num {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 24px;
    color: var(--gold);
    opacity: 0.5;
    display: block;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.info-card h4 {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--navy);
    letter-spacing: 0.6px;
    margin-bottom: 10px;
    font-weight: 400;
}

.info-card p {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink-light);
    line-height: 1.8;
    letter-spacing: 0.3px;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer {
    background: var(--navy);
    color: rgba(255,255,255,0.4);
    padding: 32px 0;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.footer a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--gold-light);
}

.footer .sep {
    color: rgba(255,255,255,0.2);
    margin: 0 12px;
}

/* --------------------------------------------------------------------------
   Payment & Quota
   -------------------------------------------------------------------------- */

/* 额度状态栏 */
.quota-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    margin-bottom: 20px;
    background: rgba(30,58,95,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.quota-text {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--navy);
    letter-spacing: 0.3px;
}

.btn-sm {
    font-size: 13px;
    padding: 8px 20px;
}

/* 支付弹窗遮罩 */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26,29,35,0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-overlay.visible {
    display: flex;
}

/* 弹窗卡片 */
.modal-card {
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: 40px 36px 36px;
    max-width: 440px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: modalIn 0.25s var(--ease);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--ink-light);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.modal-close:hover { opacity: 1; }

.modal-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    color: var(--navy);
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: 0.8px;
}

/* 套餐卡片 */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.plan-card {
    text-align: center;
    padding: 20px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    background: var(--paper);
}

.plan-card:hover {
    border-color: var(--navy);
    background: rgba(30,58,95,0.02);
}

.plan-card.selected {
    border-color: var(--navy);
    background: rgba(30,58,95,0.06);
    box-shadow: 0 0 0 1px var(--navy);
}

.plan-price {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--navy);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.plan-label {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--ink);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.plan-desc {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--ink-light);
    letter-spacing: 0.3px;
}

/* 二维码区域 */
.qrcode-section {
    text-align: center;
    margin-top: 8px;
}

.qrcode-hint {
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--ink-light);
    margin-bottom: 16px;
    letter-spacing: 0.3px;
}

.qrcode-waiting {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink-light);
    font-style: italic;
    margin-top: 12px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}

#qrcodeContainer {
    display: flex;
    justify-content: center;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: inline-block;
}

#qrcodeContainer img {
    display: block;
}

.modal-error {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: var(--error);
    text-align: center;
    margin-top: 16px;
    padding: 14px 20px;
    border-radius: var(--radius);
    letter-spacing: 0.3px;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: var(--shadow-elevated);
    animation: slideDown 0.3s var(--ease);
    display: none;
    letter-spacing: 0.3px;
}

.toast.visible { display: block; }

.toast.success { background: var(--success); color: #fff; }
.toast.error   { background: var(--error); color: #fff; }
.toast.info    { background: var(--navy); color: #fff; }

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .container { padding: 0 20px; }
    .header { padding: 40px 0 48px; }
    .header h1 { font-size: 26px; }
    .header .subtitle { font-size: 14px; }
    .tab-bar { overflow-x: auto; }
    .tab-btn { padding: 12px 18px; font-size: 13px; white-space: nowrap; }
    .tab-panel { padding: 20px; }
    .btn-row { flex-direction: column; }
    .btn { width: 100%; justify-content: center; }
}
