/* ============================================
   文字修仙游戏 - 主样式文件
   ============================================ */

/* CSS变量 */
:root {
    --primary-color: #8b5cf6;
    --primary-dark: #6d28d9;
    --primary-light: #a78bfa;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: #1e1e3f;
    
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --text-muted: #6b6b6b;
    
    --border-color: #2d2d4a;
    --border-light: #3d3d5c;
    
    --gold: #ffd700;
    --jade: #00d4aa;
    --spirit: #7dd3fc;
    
    --font-main: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

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

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ============================================
   模态框样式
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    color: var(--primary-light);
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.config-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group .hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.input-with-toggle {
    display: flex;
    gap: 8px;
}

.input-with-toggle input {
    flex: 1;
}

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

.param-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.param-item input {
    width: 100%;
}

.status-text {
    font-size: 0.9rem;
    margin-left: 12px;
}

.status-text.success {
    color: var(--secondary-color);
}

.status-text.error {
    color: var(--danger-color);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* ============================================
   按钮样式
   ============================================ */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.btn-large {
    padding: 16px 40px;
    font-size: 1.2rem;
}

/* ============================================
   游戏容器布局
   ============================================ */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* 顶部栏 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
    font-size: 2rem;
    color: var(--gold);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--gold), var(--jade));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-status {
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--bg-tertiary);
}

.ai-status.connected {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary-color);
}

.ai-status.disconnected {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding: 16px;
    gap: 16px;
}

/* 侧边栏 */
.sidebar-left, .sidebar-right {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

/* 面板样式 */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.panel h3 {
    color: var(--primary-light);
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.panel h4 {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 12px 0 8px;
}

/* 角色信息面板 */
.character-info {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.char-avatar {
    width: 60px;
    height: 60px;
}

.avatar-frame {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--gold);
}

.realm-icon {
    font-size: 1.5rem;
    color: var(--gold);
    font-weight: bold;
}

.char-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.char-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-primary);
}

.char-realm {
    color: var(--jade);
    font-size: 0.9rem;
}

.char-level {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 属性条 */
.stat-bar {
    display: grid;
    grid-template-columns: 40px 1fr 70px;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bar-container {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.hp-bar {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.mp-bar {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.exp-bar {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.stat-value {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    font-family: var(--font-mono);
}

/* 属性网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.stat-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-num {
    font-size: 0.9rem;
    color: var(--spirit);
    font-family: var(--font-mono);
}

/* 资源 */
.resource-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.resource-icon {
    font-size: 1rem;
}

.resource-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.resource-value {
    font-size: 0.9rem;
    color: var(--gold);
    font-family: var(--font-mono);
}

/* ============================================
   游戏主区域
   ============================================ */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.scene-panel {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scene-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* 欢迎屏幕 */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-title {
    font-size: 2rem;
    color: var(--gold);
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.welcome-desc {
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.8;
}

/* 选择按钮区 */
.choices-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-secondary);
}

.choice-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-family: var(--font-main);
}

.choice-btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.choice-btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-color: var(--primary-light);
}

/* AI生成指示器 */
.ai-generating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    background: rgba(139, 92, 246, 0.1);
    border-top: 1px solid var(--primary-color);
}

.generating-animation {
    display: flex;
    gap: 4px;
}

.generating-animation .dot {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.generating-animation .dot:nth-child(1) { animation-delay: -0.32s; }
.generating-animation .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.generating-text {
    color: var(--primary-light);
    font-size: 0.9rem;
}

/* ============================================
   底部操作栏
   ============================================ */
.bottom-bar {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
}

.action-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.action-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.action-tab:hover {
    background: var(--bg-card);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.action-tab.active {
    background: var(--primary-dark);
    border-color: var(--primary-color);
    color: white;
}

.tab-icon {
    font-size: 1.2rem;
}

.tab-text {
    font-size: 0.85rem;
}

/* ============================================
   日志面板
   ============================================ */
.log-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    transition: all 0.3s ease;
    z-index: 100;
}

.log-panel.collapsed {
    transform: translateY(calc(100% - 40px));
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
}

.log-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.log-content {
    max-height: 150px;
    overflow-y: auto;
    padding: 8px 16px 16px;
    border-top: 1px solid var(--border-color);
}

.log-entry {
    padding: 4px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(45, 45, 74, 0.5);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.important {
    color: var(--gold);
}

.log-entry.danger {
    color: var(--danger-color);
}

.log-entry.success {
    color: var(--secondary-color);
}

/* ============================================
   事件/场景内容样式
   ============================================ */
.event-title {
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: 16px;
    text-align: center;
}

.event-description {
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-color);
}

.event-type-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.event-type-badge.combat {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.event-type-badge.exploration {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info-color);
}

.event-type-badge.social {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary-color);
}

.event-type-badge.mystery {
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary-light);
}

/* NPC卡片 */
.npc-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.npc-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--jade), var(--spirit));
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
}

.npc-info {
    flex: 1;
}

.npc-name {
    font-size: 1.2rem;
    color: var(--gold);
    margin-bottom: 4px;
}

.npc-title {
    color: var(--jade);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.npc-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* 势力卡片 */
.force-card {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    border-left: 3px solid var(--jade);
}

.force-name {
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 4px;
}

.force-type {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 1200px) {
    .sidebar-left, .sidebar-right {
        width: 240px;
    }
}

@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar-left, .sidebar-right {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .sidebar-left .panel,
    .sidebar-right .panel {
        min-width: 250px;
    }
}
