/* ========================================
   鸿蒙大世界 - 仙侠风格主题
   ======================================== */

/* === 基础变量 === */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #222842;
    --bg-input: #151a2e;
    --border-color: #2a3050;
    --border-glow: #4a6fa5;
    --text-primary: #e8e6e3;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-gold: #d4a843;
    --accent-blue: #5b8def;
    --accent-purple: #8b5cf6;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-cyan: #06b6d4;
    --health-bar: #ef4444;
    --mana-bar: #3b82f6;
    --stamina-bar: #f59e0b;
    --exp-bar: #8b5cf6;
    --font-main: 'Noto Serif SC', 'STSong', serif;
    --font-ui: 'Noto Sans SC', -apple-system, sans-serif;
    --radius: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --transition: all 0.3s ease;
}

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

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(90,60,180,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(70,130,220,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(212,168,67,0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { color: var(--accent-gold); }

/* === 布局 === */
.app-container {
    display: flex;
    height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.narrative-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.right-panel {
    width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

/* === 顶部导航 === */
.top-bar {
    height: 52px;
    background: linear-gradient(135deg, #111827 0%, #1a1f35 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    flex-shrink: 0;
}

.top-bar .logo {
    font-family: var(--font-main);
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-gold), #f0d78c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.top-bar .world-info {
    display: flex;
    gap: 16px;
    margin-left: auto;
    font-size: 13px;
    color: var(--text-secondary);
}

.top-bar .world-info span { display: flex; align-items: center; gap: 4px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-green); display: inline-block; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* === 侧边栏 === */
.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.player-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--accent-gold);
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: var(--bg-card);
}

.player-name {
    font-family: var(--font-main);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-gold);
}

.player-title {
    font-size: 12px;
    color: var(--accent-purple);
    margin-top: 2px;
}

.player-realm {
    font-size: 13px;
    color: var(--accent-cyan);
    margin-top: 4px;
}

/* === 属性条 === */
.stat-bars {
    padding: 12px 16px;
}

.stat-bar {
    margin-bottom: 8px;
}

.stat-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 3px;
    color: var(--text-secondary);
}

.stat-bar-track {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.stat-bar-fill.health { background: linear-gradient(90deg, #dc2626, #ef4444); }
.stat-bar-fill.mana { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.stat-bar-fill.stamina { background: linear-gradient(90deg, #d97706, #f59e0b); }
.stat-bar-fill.exp { background: linear-gradient(90deg, #7c3aed, #8b5cf6); }

/* === 属性面板 === */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    background: var(--bg-card);
    border-radius: 4px;
}

.stat-item .label { color: var(--text-secondary); }
.stat-item .value { color: var(--text-primary); font-weight: 600; }

/* === 侧边栏导航 === */
.sidebar-nav {
    padding: 8px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.nav-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--bg-card); color: var(--accent-gold); border-left: 3px solid var(--accent-gold); }
.nav-btn .emoji { font-size: 18px; width: 24px; text-align: center; }

/* === 叙事面板 === */
.narrative-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.narrative-entry {
    margin-bottom: 20px;
    animation: fadeInUp 0.5s ease;
}

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

.narrative-scene-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-family: var(--font-main);
    font-size: 16px;
    color: var(--accent-gold);
}

.narrative-text {
    font-family: var(--font-main);
    font-size: 15px;
    line-height: 1.9;
    color: var(--text-primary);
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent-purple);
    white-space: pre-wrap;
}

.narrative-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-top: 10px;
}

.state-changes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.state-change-tag {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.state-change-tag.positive { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.state-change-tag.negative { background: rgba(239,68,68,0.15); color: var(--accent-red); }

/* === 选项按钮 === */
.options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.option-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.option-btn:hover {
    border-color: var(--accent-gold);
    background: var(--bg-card-hover);
    color: var(--accent-gold);
    transform: translateY(-1px);
}

/* === 输入区域 === */
.action-input-area {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.action-input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-ui);
    outline: none;
    transition: var(--transition);
}

.action-input:focus { border-color: var(--accent-gold); box-shadow: 0 0 0 2px rgba(212,168,67,0.2); }
.action-input::placeholder { color: var(--text-muted); }

.send-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-gold), #c49a3c);
    border: none;
    border-radius: var(--radius);
    color: #1a1a2e;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.send-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(212,168,67,0.3); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* === 右侧面板 === */
.panel-section {
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
}

.panel-section-title {
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--accent-gold);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === 聊天面板 === */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
}

.chat-tab.active { color: var(--accent-gold); border-bottom-color: var(--accent-gold); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-size: 13px;
}

.chat-msg {
    margin-bottom: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.chat-msg .sender { color: var(--accent-cyan); font-weight: 600; }
.chat-msg .content { color: var(--text-primary); }
.chat-msg.system { color: var(--accent-gold); font-style: italic; }
.chat-msg.tiandao { color: var(--accent-purple); background: rgba(139,92,246,0.08); }

.chat-input-area {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.chat-send-btn {
    padding: 6px 12px;
    background: var(--accent-blue);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
}

/* === 地图面板 === */
.world-map {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    background:
        radial-gradient(circle at 50% 50%, rgba(90,60,180,0.05) 0%, transparent 70%);
}

.map-container {
    position: relative;
    width: 800px;
    height: 600px;
    margin: 20px auto;
}

.map-node {
    position: absolute;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    min-width: 100px;
    z-index: 2;
}

.map-node:hover {
    border-color: var(--accent-gold);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(212,168,67,0.2);
}

.map-node.current {
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(212,168,67,0.3);
    background: linear-gradient(135deg, var(--bg-card), rgba(212,168,67,0.1));
}

.map-node.accessible { border-color: var(--accent-green); }
.map-node.locked { opacity: 0.5; border-style: dashed; cursor: not-allowed; }

.map-node .emoji { font-size: 24px; display: block; }
.map-node .name { font-size: 13px; font-weight: 600; margin-top: 4px; }
.map-node .info { font-size: 11px; color: var(--text-muted); }

.map-line {
    position: absolute;
    background: var(--border-color);
    z-index: 1;
    opacity: 0.5;
}

/* === 弹窗/模态框 === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-title {
    font-family: var(--font-main);
    font-size: 20px;
    color: var(--accent-gold);
    margin-bottom: 16px;
    text-align: center;
}

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

.form-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.form-input:focus { border-color: var(--accent-gold); }

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: linear-gradient(135deg, var(--accent-gold), #c49a3c); color: #1a1a2e; }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-danger { background: var(--accent-red); color: white; }
.btn-success { background: var(--accent-green); color: white; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; justify-content: center; }

/* === 物品/背包 === */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    padding: 8px;
}

.item-card {
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.item-card:hover { border-color: var(--accent-gold); }
.item-card .emoji { font-size: 24px; }
.item-card .name { font-size: 12px; margin-top: 4px; }
.item-card .qty { font-size: 11px; color: var(--text-muted); }

.item-card.rarity-common { border-color: #6b7280; }
.item-card.rarity-uncommon { border-color: #10b981; }
.item-card.rarity-rare { border-color: #3b82f6; }
.item-card.rarity-epic { border-color: #8b5cf6; }
.item-card.rarity-legendary { border-color: #f59e0b; box-shadow: 0 0 10px rgba(245,158,11,0.2); }

/* === 宗门列表 === */
.sect-card {
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.sect-card:hover { border-color: var(--accent-gold); }
.sect-card .sect-name { font-size: 16px; font-weight: 700; }
.sect-card .sect-info { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.alignment-righteous { color: var(--accent-blue); }
.alignment-neutral { color: var(--text-secondary); }
.alignment-demonic { color: var(--accent-red); }

/* === 排行榜 === */
.rank-list { list-style: none; }

.rank-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.rank-pos {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    background: var(--bg-card);
}

.rank-pos.top-1 { background: linear-gradient(135deg, #ffd700, #daa520); color: #1a1a2e; }
.rank-pos.top-2 { background: linear-gradient(135deg, #c0c0c0, #a8a8a8); color: #1a1a2e; }
.rank-pos.top-3 { background: linear-gradient(135deg, #cd7f32, #b87333); color: #1a1a2e; }

/* === 世界事件横幅 === */
.world-event-banner {
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(212,168,67,0.1));
    border: 1px solid var(--accent-purple);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 8px 0;
    animation: eventGlow 3s infinite alternate;
}

@keyframes eventGlow {
    from { box-shadow: 0 0 5px rgba(139,92,246,0.2); }
    to { box-shadow: 0 0 15px rgba(139,92,246,0.4); }
}

.world-event-banner .event-title { font-family: var(--font-main); font-size: 15px; color: var(--accent-gold); }
.world-event-banner .event-desc { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* === 加载动画 === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === 通知/Toast === */
.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    animation: slideInRight 0.3s ease;
    max-width: 360px;
    box-shadow: var(--shadow);
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success { background: rgba(16,185,129,0.9); color: white; }
.toast.error { background: rgba(239,68,68,0.9); color: white; }
.toast.info { background: rgba(59,130,246,0.9); color: white; }
.toast.tiandao { background: linear-gradient(135deg, rgba(139,92,246,0.95), rgba(90,60,180,0.95)); color: white; }

/* === 登录/注册页面 === */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(90,60,180,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(212,168,67,0.1) 0%, transparent 50%),
        var(--bg-primary);
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 420px;
    box-shadow: var(--shadow);
}

.auth-title {
    font-family: var(--font-main);
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-gold), #f0d78c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-toggle a { color: var(--accent-gold); cursor: pointer; }

/* === 滚动条 === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-glow); }

/* === 响应式 === */
@media (max-width: 1200px) {
    .right-panel { width: 260px; }
}

@media (max-width: 1024px) {
    .sidebar { width: 240px; }
    .right-panel { display: none; }
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; flex-direction: row; overflow-x: auto; }
    .sidebar-header { display: none; }
    .stat-bars { display: none; }
    .stats-grid { display: none; }
    .sidebar-nav { display: flex; flex-direction: row; gap: 4px; padding: 4px; }
    .nav-btn { padding: 8px; font-size: 12px; white-space: nowrap; }
    .main-content { height: calc(100vh - 100px); }
}

/* === 隐藏面板 === */
.panel-hidden { display: none !important; }
