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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* ===== 应用容器 ===== */
#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== 头部 ===== */
.header {
    text-align: center;
    padding: 30px 20px;
    color: white;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* ===== Tab切换 ===== */
.tab-nav {
    display: flex;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
}

.tab-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    white-space: nowrap;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.1);
}

.tab-btn.active {
    background: white;
    color: #764ba2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ===== Tab面板 ===== */
.tab-panel {
    display: none;
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.tab-panel h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #333;
}

/* ===== 输入表单 ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.form-group .input-hint {
    font-size: 0.8rem;
    color: #999;
    margin-top: 4px;
}

/* ===== 计算按钮 ===== */
.btn-calculate {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 8px;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

/* ===== 结果卡片 ===== */
.result-area {
    margin-top: 24px;
    display: none;
}

.result-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.result-emoji {
    font-size: 3rem;
    margin-bottom: 8px;
}

.result-number {
    font-size: 3rem;
    font-weight: 700;
    color: #764ba2;
    line-height: 1.2;
}

.result-unit {
    font-size: 1.2rem;
    color: #999;
    font-weight: 400;
}

.result-joke-label {
    display: inline-block;
    background: #764ba2;
    color: white;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin: 12px 0 8px;
}

.result-joke-text {
    font-size: 1rem;
    color: #555;
    font-style: italic;
    margin-bottom: 16px;
}

.result-detail {
    text-align: left;
    background: white;
    border-radius: 10px;
    padding: 16px;
    margin: 16px 0;
    font-size: 0.9rem;
    color: #666;
}

.result-detail p {
    margin: 4px 0;
}

.result-city-joke {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 8px;
    padding: 10px;
    font-size: 0.9rem;
    color: #b8860b;
    margin-bottom: 16px;
}

.result-retirement,
.result-job-advice {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    font-size: 0.9rem;
}

.result-error {
    background: #fff1f0;
    border: 1px solid #ffa39e;
    color: #cf1322;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
}

/* ===== 分享按钮 ===== */
.btn-share {
    width: 100%;
    padding: 12px;
    background: #52c41a;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-share:hover {
    background: #389e0d;
    transform: translateY(-1px);
}

/* ===== 热度榜 ===== */
.hot-section {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.hot-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #333;
}

.hot-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: #f5f5f5;
    font-size: 0.9rem;
}

.hot-count {
    color: #999;
    font-size: 0.8rem;
}

.hot-empty {
    color: #999;
    text-align: center;
    padding: 16px;
}

/* ===== 地图区域 ===== */
.map-section {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.map-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #333;
}

.map-search {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.map-search input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    font-size: 0.95rem;
}

.map-search input:focus {
    outline: none;
    border-color: #667eea;
}

.map-search button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

#map-container {
    width: 100%;
    height: 400px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.map-error {
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 1rem;
    background: #f5f5f5;
    border-radius: 12px;
}

/* Leaflet弹窗样式 */
.map-popup h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.map-popup p {
    margin: 2px 0;
    font-size: 0.85rem;
}

.popup-area {
    font-size: 1.2rem !important;
    font-weight: 700;
    color: #764ba2;
}

.popup-joke {
    color: #faad14;
    font-weight: 500;
}

.popup-hint {
    color: #999;
    font-size: 0.8rem !important;
    margin-top: 8px !important;
}

/* ===== 分享弹窗 ===== */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
}

.share-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1;
    text-align: center;
}

.share-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.share-modal-content h3 {
    margin-bottom: 16px;
    color: #333;
}

.share-modal-img {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 16px;
}

.share-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.share-modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-download {
    background: #667eea;
    color: white;
}

.btn-copy-text {
    background: #f0f0f0;
    color: #333;
}

/* 分享卡片截图样式 */
.share-card-capture {
    position: fixed;
    left: -9999px;
    width: 750px;
    height: 1000px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 60px;
}

.share-card-inner {
    background: white;
    border-radius: 24px;
    padding: 48px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.share-header {
    margin-bottom: 40px;
}

.share-logo {
    font-size: 2rem;
    font-weight: 700;
    color: #764ba2;
}

.share-subtitle {
    font-size: 1rem;
    color: #999;
    margin-top: 4px;
}

.share-city {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 20px;
}

.share-result {
    font-size: 4rem;
    font-weight: 700;
    color: #764ba2;
    margin-bottom: 12px;
}

.share-label {
    display: inline-block;
    background: #764ba2;
    color: white;
    padding: 8px 24px;
    border-radius: 24px;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.share-quote {
    font-size: 1.2rem;
    color: #555;
    font-style: italic;
    line-height: 1.6;
    margin-bottom: 40px;
    padding: 0 20px;
}

.share-footer {
    margin-top: auto;
    color: #999;
    font-size: 0.9rem;
}

.share-url {
    color: #667eea;
    font-weight: 500;
    margin-top: 8px;
}

/* ===== 加载提示 ===== */
#loading-hint {
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 1.1rem;
}

.init-error {
    text-align: center;
    padding: 40px;
    color: white;
}

.init-error h2 {
    margin-bottom: 16px;
}

.init-error button {
    margin-top: 20px;
    padding: 12px 24px;
    background: white;
    color: #764ba2;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
}

.footer a {
    color: rgba(255,255,255,0.9);
}

/* ===== Debug面板 ===== */
#debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    max-height: 400px;
    background: #1a1a2e;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    color: #ccc;
    overflow: hidden;
}

#debug-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    font-weight: 600;
    color: #e94560;
}

#debug-actions {
    display: flex;
    gap: 6px;
}

#debug-actions button {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background: #0f3460;
    color: #ccc;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

#debug-actions button:hover {
    background: #e94560;
    color: white;
}

#debug-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.debug-entry {
    padding: 6px 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 0.78rem;
    line-height: 1.4;
}

.debug-time {
    opacity: 0.6;
    margin-right: 6px;
}

.debug-level {
    font-weight: 600;
    margin-right: 6px;
}

.debug-data {
    margin-top: 2px;
    padding-left: 12px;
    opacity: 0.8;
    font-size: 0.75rem;
    word-break: break-all;
}

/* Debug面板收起状态 */
#debug-panel.debug-collapsed #debug-content {
    display: none;
}

#debug-panel.debug-collapsed {
    height: auto;
    max-height: 50px;
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
    #app {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .tab-btn {
        font-size: 0.8rem;
        padding: 10px 4px;
    }

    .tab-panel {
        padding: 16px;
    }

    .result-number {
        font-size: 2.2rem;
    }

    #map-container {
        height: 300px;
    }

    #debug-panel {
        width: 90vw;
        right: 5vw;
        bottom: 10px;
    }

    .share-card-capture {
        width: 100vw;
        padding: 30px;
    }
}
