/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

:root {
    --brand-color: #667eea;
    --text-muted: #6b7280;
    --border-color: #e9ecf2;
    --surface: #ffffff;
    --surface-muted: #f8f9ff;
    --background: #667eea;
    --focus-ring: 0 0 0 3px rgba(255, 255, 255, 0.20);
    --button-primary: #4a5568;
    --button-secondary: #e2e8f0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: #ffffff;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.logo {
    animation: none;
}

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

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: 700;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 500px;
}

/* 主要内容区域 */
.main-content {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    backdrop-filter: none;
}

/* 两栏布局 */
.content-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 28px;
}

.left-pane, .right-pane {
    min-width: 0;
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid var(--border-color);
}

/* 结果区域分组 */
.result-section {
    margin-bottom: 24px;
}

.result-section:last-child {
    margin-bottom: 0;
}

.section-title {
    color: var(--brand-color);
    margin-bottom: 16px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* 卡面区域 */
.card-area {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-area:not(:empty) {
    display: block;
    align-items: stretch;
    justify-content: flex-start;
}

.card-placeholder {
    color: #9aa0b4;
    font-size: 14px;
}

/* 表单区域 */
.form-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f2f5;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    color: var(--brand-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

/* 表单组件 */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2b2f36;
}

.required {
    color: #e74c3c;
}

/* 日期时间输入 */
.date-time-inputs {
    display: flex;
    gap: 15px;
}

.date-time-inputs input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: #fff;
}

.date-time-inputs input:focus {
    border-color: var(--brand-color);
    outline: none;
    box-shadow: var(--focus-ring);
    background: #fff;
}

/* 性别选择 */
.gender-options {
    display: flex;
    gap: 20px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 15px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    transition: all 0.3s ease;
    flex: 1;
    background: #fafafa;
}

.radio-option:hover {
    border-color: var(--brand-color);
    background-color: #f8f9ff;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 50%;
    position: relative;
    transition: all 0.3s ease;
}

.radio-option input[type="radio"]:checked + .radio-custom {
    border-color: var(--brand-color);
    background-color: var(--brand-color);
}

.radio-option input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background-color: white;
    border-radius: 50%;
}

.radio-option input[type="radio"]:checked ~ * {
    color: var(--brand-color);
}

/* 城市选择器 */
.city-selector {
    position: relative;
}

#citySearch {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: #fff;
}

#citySearch:focus {
    border-color: var(--brand-color);
    outline: none;
    box-shadow: var(--focus-ring);
    background: white;
}

.city-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    display: none;
}

.city-dropdown.show {
    display: block;
}

.city-option {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.city-option:hover {
    background-color: var(--surface-muted);
}

.city-option:last-child {
    border-bottom: none;
}

.city-option.selected {
    background-color: var(--brand-color);
    color: white;
}

.city-province {
    font-size: 12px;
    opacity: 0.7;
}

/* 文本区域 */
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    resize: vertical;
    min-height: 100px;
    transition: all 0.2s ease;
    font-family: inherit;
    background: #fff;
}

textarea:focus {
    border-color: var(--brand-color);
    outline: none;
    box-shadow: var(--focus-ring);
    background: white;
}

/* 小提示文字 */
small {
    color: #6b7280;
    font-size: 14px;
    margin-top: 5px;
    display: block;
}

/* 下拉选择通用样式 */
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    background: #fff;
    transition: all 0.2s ease;
}

select:focus {
    border-color: var(--brand-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 行内表单布局：标签与控件同一行 */
.form-inline {
    display: grid;
    grid-template-columns: 110px 1fr;
    align-items: center;
    column-gap: 16px;
}

.form-inline label {
    margin-bottom: 0;
}

/* 提交按钮 */
.form-actions {
    text-align: center;
    margin-top: 40px;
}

.submit-btn {
    background: var(--brand-color);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.22);
}

.submit-btn:hover {
    transform: none;
    box-shadow: 0 5px 16px rgba(102, 126, 234, 0.28);
}

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

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 加载状态 */
.loading-state {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    margin: 0 auto 20px;
}

.loading-tip {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    margin-top: 10px;
}

/* 结果区域 */
.result-area {
    margin-top: 12px;
    padding: 16px;
    background: var(--surface-muted);
    border-radius: 12px;
    border-left: 3px solid var(--brand-color);
}

/* 工具类 */
.hidden {
    display: none !important;
}

/* 页脚 */
.footer {
    text-align: center;
    margin-top: 40px;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0.8;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .content-layout {
        grid-template-columns: 320px 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-content {
        padding: 0;
    }

    .content-layout {
        display: block;
    }

    .right-pane {
        margin-top: 18px;
    }

    .form-inline {
        grid-template-columns: 1fr;
        row-gap: 8px;
    }
    
    .header h1 {
        font-size: 1.6rem;
    }
    
    .date-time-inputs {
        flex-direction: column;
        gap: 10px;
    }
    
    .gender-options {
        flex-direction: column;
        gap: 10px;
    }
    
    .submit-btn {
        width: 100%;
        padding: 20px;
    }
}

/* 滚动条样式 */
.city-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 城市选择器头部样式 */
.city-option-header {
    padding: 10px 15px;
    background: #f8f9ff;
    font-size: 12px;
    color: var(--brand-color);
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

/* 塔罗牌结果样式 */
.tarot-result {
    text-align: left;
}

.tarot-result h3 {
    color: var(--brand-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
}

.result-content {
    line-height: 1.8;
    font-size: 16px;
    color: #333;
    white-space: pre-wrap;
}

/* Markdown内容样式 */
.markdown-content {
    white-space: normal;
    line-height: 1.6;
}

.markdown-content h1 {
    font-size: 1.8rem;
    color: var(--brand-color);
    margin: 20px 0 12px 0;
    border-bottom: 2px solid var(--brand-color);
    padding-bottom: 8px;
}

.markdown-content h2 {
    font-size: 1.5rem;
    color: var(--brand-color);
    margin: 18px 0 10px 0;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}

.markdown-content h3 {
    font-size: 1.3rem;
    color: #2b2f36;
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.markdown-content strong {
    color: var(--brand-color);
    font-weight: 600;
}

.markdown-content em {
    color: #666;
    font-style: italic;
}

/* 优化列表间距 */
.markdown-content ul {
    margin: 6px 0;
    padding-left: 24px;
    list-style-type: disc;
}

.markdown-content ol {
    margin: 6px 0;
    padding-left: 24px;
    list-style-type: decimal;
}

.markdown-content li {
    margin: 2px 0;
    line-height: 1.5;
}

.markdown-content a {
    color: var(--brand-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.markdown-content a:hover {
    border-bottom-color: var(--brand-color);
}

.markdown-content code {
    background: #f5f7fa;
    color: #e74c3c;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

/* 优化段落间距 */
.markdown-content p {
    margin: 6px 0;
    line-height: 1.6;
}

/* 优化段落之间的间距 */
.markdown-content p + p {
    margin-top: 8px;
}

/* 优化标题与段落之间的间距 */
.markdown-content h1 + p,
.markdown-content h2 + p,
.markdown-content h3 + p {
    margin-top: 8px;
}

/* 优化列表与段落之间的间距 */
.markdown-content p + ul,
.markdown-content p + ol {
    margin-top: 6px;
}

.markdown-content ul + p,
.markdown-content ol + p {
    margin-top: 8px;
}

/* 优化粗体文本与后续段落之间的间距 */
.markdown-content strong + p {
    margin-top: 4px;
}

/* 优化段落中粗体文本后的间距 */
.markdown-content p strong {
    display: inline-block;
    margin-bottom: 2px;
}

/* 错误信息样式 */
.error-message {
    text-align: center;
    padding: 30px;
}

.error-message h3 {
    color: #e74c3c;
    margin-bottom: 15px;
}

.error-message p {
    color: #666;
    margin-bottom: 20px;
    font-size: 16px;
}

.retry-btn {
    background: var(--brand-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.retry-btn:hover {
    background: #5a6fd8;
}

/* 卡片显示样式 */
.cards-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: nowrap;
    padding: 0 16px;
    overflow-x: auto;
}

.card-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fafbfc;
    transition: all 0.3s ease;
    flex: 0 0 auto;
    max-width: 240px;
}

.card-item:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.card-image {
    width: 200px;
    height: 340px;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid #e9ecf2;
    margin-bottom: 12px;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-image.loaded img {
    opacity: 1;
}

.image-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image.loaded .image-loading {
    display: none;
}

.image-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 12px;
    text-align: center;
    gap: 4px;
}

.card-image.error .image-error {
    display: flex;
}

.card-image.error .image-loading {
    display: none;
}

.card-info {
    text-align: center;
    width: 100%;
}

.card-info h4 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2b2f36;
}

.card-name-en {
    margin: 0 0 6px 0;
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

.card-type {
    margin: 0;
    font-size: 14px;
    color: var(--brand-color);
    font-weight: 500;
    padding: 4px 8px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    display: inline-block;
}

.card-content {
    color: #2b2f36;
    line-height: 1.6;
}

/* 卡片移动端优化 */
@media (max-width: 768px) {
    .result-content {
        font-size: 14px;
    }
    
    .tarot-result h3 {
        font-size: 1.3rem;
    }
    
    .cards-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
    }
    
    .card-item {
        max-width: 200px;
        padding: 12px;
    }
    
    .card-image {
        width: 150px;
        height: 255px;
        margin-bottom: 10px;
    }
    
    .card-info h4 {
        font-size: 16px;
    }
    
    .card-name-en {
        font-size: 11px;
    }
    
    .card-type {
        font-size: 13px;
        padding: 3px 6px;
    }
}

@media (max-width: 480px) {
    .cards-container {
        gap: 12px;
    }
    
    .card-item {
        max-width: 180px;
        padding: 10px;
    }
    
    .card-image {
        width: 120px;
        height: 204px;
    }
    
    .card-info h4 {
        font-size: 15px;
    }
}

/* Mermaid图表样式 */
.mermaid {
    text-align: center;
    margin: 16px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecf2;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}

/* 确保Mermaid图表在移动端也能正常显示 */
@media (max-width: 768px) {
    .mermaid {
        padding: 12px;
        margin: 12px 0;
    }
}