/* ==================== 设计变量 ==================== */
:root {
    /* 主色调：薄荷绿/青绿色系 */
    --primary: #14b8a6;
    --primary-dark: #0d9488;
    --primary-light: #ccfbf1;
    --primary-lighter: #f0fdfa;

    /* 背景色 */
    --bg: #f6faf9;
    --surface: #ffffff;

    /* 文字 */
    --text: #134e4a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* 边框 */
    --border: #e2e8e6;
    --border-focus: #14b8a6;

    /* 状态 */
    --error: #ef4444;
    --error-light: #fef2f2;
    --success: #22c55e;

    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    /* 阴影 */
    --shadow: 0 2px 12px rgba(20, 184, 166, 0.06);
    --shadow-hover: 0 4px 20px rgba(20, 184, 166, 0.12);
    --shadow-active: 0 0 0 3px rgba(20, 184, 166, 0.15);

    /* 字体 */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
            "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ==================== 顶部引导区 ==================== */
.header {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: #fff;
    padding: 28px 20px;
}

.header-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 36px;
    line-height: 1;
}

.logo h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 2px;
}

.tagline {
    font-size: 13px;
    opacity: 0.9;
}

.header-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    background: rgba(255, 255, 255, 0.18);
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    backdrop-filter: blur(4px);
}

/* ==================== 主内容区 ==================== */
.main {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

/* ==================== 卡片 ==================== */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px 24px;
    margin-bottom: 20px;
}

.card-header {
    margin-bottom: 24px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==================== 步骤指示器 ==================== */
.steps {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
    padding: 0 8px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s ease;
}

.step-label {
    font-size: 12px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.step.active .step-num {
    background: var(--primary);
    color: #fff;
}

.step.active .step-label {
    color: var(--primary-dark);
    font-weight: 600;
}

.step.done .step-num {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 8px;
    margin-top: -18px;
    border-radius: 1px;
    transition: background 0.3s ease;
}

.step-line.done {
    background: var(--primary-light);
}

/* ==================== 表单步骤 ==================== */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.form-step-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
}

.form-step-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ==================== 表单字段 ==================== */
.field-group {
    margin-bottom: 20px;
}

.field-row {
    display: flex;
    gap: 16px;
}

.field-row .field-group {
    flex: 1;
}

.field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.required {
    color: var(--primary);
}

.optional {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    margin-left: 4px;
}

/* 输入框 */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-field {
    width: 100%;
    padding: 12px 56px 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field:focus {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-active);
}

.input-suffix {
    position: absolute;
    right: 16px;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.input-full {
    padding-right: 16px;
}

.textarea-field {
    resize: vertical;
    min-height: 56px;
    padding-right: 16px;
    line-height: 1.5;
}

/* ==================== 卡片选项 ==================== */
.card-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.card-options-2col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

.card-option {
    cursor: pointer;
    user-select: none;
}

.card-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.card-option-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    transition: all 0.2s ease;
    min-width: 80px;
    text-align: center;
}

.card-option:hover .card-option-content {
    border-color: var(--primary-light);
    color: var(--text);
}

.card-option input:checked + .card-option-content {
    border-color: var(--primary);
    background: var(--primary-lighter);
    color: var(--primary-dark);
    font-weight: 600;
}

/* ==================== 按钮 ==================== */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary-light);
    color: var(--text);
}

.btn-submit {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    width: 100%;
    justify-content: center;
    padding: 14px 28px;
    font-size: 16px;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
    font-size: 13px;
}

.btn-text:hover {
    color: var(--primary-dark);
}

.form-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 28px;
    gap: 12px;
}

.form-nav:has(#btn-prev[style*="none"]) {
    justify-content: flex-end;
}

/* ==================== 加载状态 ==================== */
.loading-card {
    text-align: center;
    padding: 48px 24px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-light);
    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: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.loading-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* ==================== 结果区 ==================== */
.result-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text);
    overflow-x: auto;
}

.result-content h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 20px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

.result-content h2:first-child {
    margin-top: 0;
}

.result-content h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 16px 0 8px;
}

.result-content p {
    margin-bottom: 12px;
}

.result-content ul {
    margin: 8px 0 16px 0;
    padding-left: 0;
    list-style: none;
}

.result-content li {
    padding: 4px 0 4px 20px;
    position: relative;
}

.result-content li::before {
    content: "•";
    color: var(--primary);
    font-weight: 700;
    position: absolute;
    left: 4px;
}

.result-content strong {
    color: var(--primary-dark);
}

.result-content a {
    color: var(--primary-dark);
    text-decoration: underline;
    text-decoration-color: var(--primary-light);
    text-underline-offset: 2px;
    word-break: break-all;
}

.result-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.result-content th,
.result-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.result-content th {
    background: var(--primary-lighter);
    font-weight: 600;
    color: var(--primary-dark);
}

.result-content tr:nth-child(even) td {
    background: var(--bg);
}

/* ==================== 聊天区 ==================== */
.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-msg.bot strong {
    color: var(--primary-dark);
}

.chat-msg.bot a {
    color: var(--primary-dark);
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding-right: 16px;
}

.btn-chat-send {
    white-space: nowrap;
    padding: 12px 20px;
}

.chat-actions {
    margin-top: 12px;
    text-align: center;
}

/* ==================== 错误提示 ==================== */
.field-error {
    border-color: var(--error) !important;
}

.error-msg {
    color: var(--error);
    font-size: 13px;
    margin-top: 6px;
    display: none;
}

.error-msg.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* ==================== 底部 ==================== */
.footer {
    text-align: center;
    padding: 24px 20px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ==================== 响应式 ==================== */
@media (max-width: 600px) {
    .header {
        padding: 20px 16px;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .main {
        padding: 16px 12px 32px;
    }

    .card {
        padding: 20px 16px;
    }

    .field-row {
        flex-direction: column;
        gap: 0;
    }

    .card-options {
        flex-direction: column;
    }

    .card-options-2col {
        grid-template-columns: 1fr;
    }

    .card-option-content {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 16px;
    }

    .step-label {
        display: none;
    }

    .btn-submit {
        width: 100%;
    }

    .chat-input-area {
        flex-direction: column;
    }

    .btn-chat-send {
        width: 100%;
    }
}

/* ==================== 用户认证样式 ==================== */

/* header 右侧区域：badges + auth 按钮纵向排列 */
.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

/* auth 按钮栏 */
.auth-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-greeting {
    font-size: 14px;
    opacity: 0.95;
}

/* 小号按钮（用于 header 内） */
.btn-sm {
    padding: 6px 16px !important;
    font-size: 13px !important;
}

/* header 内的文字按钮要适配深色背景 */
.header .btn-text {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.12);
}

.header .btn-text:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* header 内的主按钮也要适配 */
.header .btn-primary {
    background: #fff;
    color: var(--primary-dark);
}

.header .btn-primary:hover {
    background: var(--primary-light);
}

/* 全宽按钮 */
.btn-full {
    width: 100%;
    justify-content: center;
}

/* ==================== 登录/注册弹窗 ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(19, 78, 74, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    padding: 32px;
    max-width: 400px;
    width: 100%;
    position: relative;
    animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* 表单字段间距 */
#auth-login-form .field-group,
#auth-register-form .field-group {
    margin-bottom: 16px;
}

/* 错误提示 */
.auth-error {
    color: var(--error);
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 12px;
    text-align: center;
}

.auth-error:empty {
    display: none;
}

/* 切换登录/注册链接 */
.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 20px;
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* 弹窗内输入框聚焦时清除错误 */
.modal-card .input-field:focus {
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

/* 手机端适配 */
@media (max-width: 600px) {
    .header-right {
        align-items: stretch;
        width: 100%;
    }

    .auth-bar {
        justify-content: flex-end;
    }

    .modal-card {
        padding: 24px 20px;
    }
}

/* ==================== 悬浮加载遮罩 ==================== */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(19, 78, 74, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.overlay-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    padding: 40px 48px;
    text-align: center;
    animation: modalSlideIn 0.25s ease-out;
}

.overlay-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

.overlay-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    min-width: 180px;
    transition: opacity 0.3s ease;
}

.overlay-text.fade {
    opacity: 0;
}

/* ==================== 计划页空状态 ==================== */
.plan-empty-content {
    text-align: center;
    padding: 48px 24px;
}

.plan-empty-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 20px;
}

.plan-empty-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.plan-empty-desc {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* ==================== 结果区操作按钮 ==================== */
.result-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 28px 24px;
}

/* ==================== 历史页 ==================== */

/* 返回链接 */
.history-back {
    margin-top: 4px;
}

.history-back-link {
    font-size: 14px;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.history-back-link:hover {
    opacity: 0.7;
}

/* 加载中文本 */
.history-loading-text {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 15px;
}

/* 时间线卡片 */
.history-card {
    display: flex;
    gap: 16px;
    margin-bottom: 4px;
}

.history-timeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 22px;
    flex-shrink: 0;
}

.history-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px var(--border);
    flex-shrink: 0;
}

.history-dot-active {
    background: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.history-line {
    width: 2px;
    flex: 1;
    background: var(--border);
    margin-top: 4px;
    min-height: 20px;
}

/* 卡片主体 */
.history-card-body {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 16px;
    transition: box-shadow 0.2s ease;
}

.history-card-body:hover {
    box-shadow: var(--shadow-hover);
}

.history-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.history-card-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-dark);
}

.history-badge-current {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    padding: 2px 10px;
    border-radius: var(--radius-pill);
}

.history-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.history-card-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

/* 进度记录区 */
.history-progress-section {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--primary-lighter);
    border-radius: var(--radius-md);
}

.history-progress-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.history-progress-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.history-progress-item:last-child {
    border-bottom: none;
}

.history-progress-item strong {
    color: var(--text);
    font-weight: 600;
}

/* 展开/收起按钮 */
.history-toggle-btn {
    margin-top: 4px;
}

/* 展开的计划全文 */
.history-plan-detail {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid var(--primary-light);
    animation: fadeIn 0.3s ease;
}

.history-plan-detail .result-content {
    font-size: 14px;
    line-height: 1.7;
}

/* 手机端适配 */
@media (max-width: 600px) {
    .history-card {
        gap: 10px;
    }

    .history-timeline {
        padding-top: 20px;
    }

    .history-card-body {
        padding: 16px 16px;
    }

    .history-card-header {
        flex-wrap: wrap;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    /* 隐藏所有不需要打印的元素 */
    header.header,
    #form-section,
    #loading-section,
    #chat-section,
    #plan-empty,
    .footer,
    #auth-modal,
    #progress-modal,
    #loading-overlay,
    .result-actions,
    .chat-actions,
    #history-list,
    #history-empty,
    .history-back,
    .history-toggle-btn {
        display: none !important;
    }

    /* 只显示结果区 */
    #result-section {
        display: block !important;
    }

    /* 打印优化 */
    body {
        background: white !important;
        color: black !important;
    }

    .card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .result-content {
        font-size: 12pt;
        line-height: 1.8;
        color: black !important;
    }

    .result-content h2,
    .result-content h3 {
        color: black !important;
        page-break-after: avoid;
    }

    .result-content table {
        page-break-inside: avoid;
    }
}
