/* 主样式文件 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff3333;
    --secondary-color: #cc0000;
    --accent-color: #ff6666;
    --dark-bg: #1a0000;
    --light-bg: #2a0000;
    --text-primary: #ffffff;
    --text-secondary: #ffaaaa;
    --border-color: rgba(255,0,0,0.3);
    --shadow: 0 2px 10px rgba(255,0,0,0.2);
    --shadow-hover: 0 4px 20px rgba(255,0,0,0.4);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0000 0%, #2a0000 50%, #0a0000 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 移除头部样式 - 不再需要 */

/* 主容器 */
.main-container {
    flex: 1;
    display: flex;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
    height: 100vh;
}

/* NPC选择器 */
.npc-selector {
    width: 220px;
    background: linear-gradient(135deg, rgba(20,0,0,0.95), rgba(40,0,0,0.95));
    border-radius: 0;
    padding: 0;
    box-shadow: var(--shadow);
    overflow-y: auto;
    border: 1px solid var(--border-color);
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* 隐藏Chrome/Safari滚动条 */
.npc-selector::-webkit-scrollbar {
    display: none;
}

.search-box {
    margin-bottom: 20px;
    padding: 0 15px;
}

.search-box input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

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

.npc-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    margin: 0;
}

.npc-card {
    width: 100%;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
}

.npc-card:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(255,0,0,0.2);
    background: rgba(255,0,0,0.1);
}

.npc-card.selected {
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255,51,51,0.2);
    background: rgba(255,0,0,0.15);
}

/* 故事区域 */
.story-area {
    flex: 1;
    background: linear-gradient(135deg, rgba(20,0,0,0.95), rgba(40,0,0,0.95));
    border-radius: 0;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.welcome-screen {
    padding: 60px 40px;
    text-align: center;
}

.welcome-screen h2 {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-screen p {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.features {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
}

.feature {
    text-align: center;
    max-width: 200px;
}

.feature-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.feature h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.feature p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 故事界面 */
.story-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.character-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255,51,51,0.2);
    background: rgba(0,0,0,0.3);
}

.character-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(255,0,0,0.3);
}

.character-info {
    flex: 0;
}

.character-info h3 {
    font-size: 18px;
    margin: 0;
    color: var(--text-primary);
}

.character-info p {
    font-size: 14px;
    color: var(--text-secondary);
}

.story-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: rgba(10,0,0,0.8);
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* 隐藏Chrome/Safari故事内容滚动条 */
.story-content::-webkit-scrollbar {
    display: none;
}

/* 重新生成按钮样式 */
.regenerate-btn {
    display: inline-block;
    margin-left: 10px;
    padding: 5px 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
}

.regenerate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.regenerate-btn.loading {
    background: #999;
    cursor: not-allowed;
}

/* 只在最后一个故事块显示重新生成按钮 */
.story-block:last-child .regenerate-btn {
    opacity: 1;
}


/* 输入区域 */
.input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(30,0,0,0.9);
}


.input-controls {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

#userPrompt {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    resize: none;
    height: 60px;
    background: rgba(20,0,0,0.8);
    color: white;
}

#userPrompt:focus {
    outline: none;
    border-color: var(--primary-color);
}


/* 右侧栏 */
.sidebar-right {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-panel,
.history-panel {
    background: linear-gradient(135deg, rgba(20,0,0,0.95), rgba(40,0,0,0.95));
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.settings-panel h3,
.history-panel h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--text-secondary);
}

.setting-item select,
.setting-item input[type="range"] {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

.setting-item input[type="range"] {
    padding: 0;
}

#creativityValue {
    display: inline-block;
    margin-left: 10px;
    font-size: 14px;
    color: var(--primary-color);
}

.story-history {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 8px;
    background: var(--light-bg);
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid var(--border-color);
}

.history-item:hover {
    background: linear-gradient(135deg, rgba(255,0,0,0.2), rgba(100,0,0,0.2));
    border-color: rgba(255,0,0,0.5);
}

.history-item h4 {
    font-size: 14px;
    margin-bottom: 5px;
}

.history-item p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 按钮样式 */
.btn-primary {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255,51,51,0.5);
}

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

/* 生成按钮样式优化 */
.btn-primary .btn-text {
    font-size: 15px;
    font-weight: 600;
}

.btn-primary .btn-cost {
    font-size: 12px;
    opacity: 0.9;
    margin-left: 8px;
    padding: 2px 6px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}

.btn-secondary {
    padding: 8px 16px;
    background: rgba(30,0,0,0.8);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 10px rgba(255,51,51,0.4);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: rgba(30,0,0,0.8);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    color: white;
}

.btn-icon:hover {
    background: var(--primary-color);
    box-shadow: 0 2px 10px rgba(255,51,51,0.4);
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    color: #fff;
}

.modal-content h2 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 24px;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}

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

/* 加载提示 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 18px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .sidebar-right {
        display: none;
    }

    .main-container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    /* 头部响应式 */
    .header-content {
        padding: 10px 15px;
    }

    .logo h1 {
        font-size: 18px;
    }

    .logo-icon {
        font-size: 24px;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-end;
        gap: 5px;
        font-size: 12px;
    }

    /* 主容器响应式 */
    .main-container {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }

    /* NPC选择器响应式 */
    .npc-selector {
        width: 100%;
        max-height: 150px;
        padding: 15px;
        border-radius: 10px;
    }

    .npc-selector h2 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .npc-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
        padding-bottom: 10px;
    }

    .npc-list::-webkit-scrollbar {
        height: 5px;
    }

    .npc-card {
        flex-shrink: 0;
        width: 120px;
        margin-right: 10px;
    }

    .npc-card:hover {
        transform: scale(1.03);
    }

    /* 故事区域响应式 */
    .story-area {
        border-radius: 10px;
        min-height: 500px;
    }

    .welcome-screen {
        padding: 30px 20px;
    }

    .welcome-screen h2 {
        font-size: 24px;
    }

    .welcome-screen p {
        font-size: 14px;
    }

    .features {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .feature {
        max-width: 100%;
    }

    .feature-icon {
        font-size: 36px;
    }

    .feature h3 {
        font-size: 16px;
    }

    .feature p {
        font-size: 12px;
    }

    /* 角色头部响应式 */
    .character-header {
        padding: 8px 12px;
    }

    .character-avatar {
        width: 36px;
        height: 36px;
    }

    .character-info h3 {
        font-size: 16px;
    }

    .character-info p {
        font-size: 12px;
    }

    /* 故事会话管理响应式 */
    .session-manager {
        margin: 10px 0 !important;
        padding: 8px !important;
    }

    .session-manager h4 {
        font-size: 14px !important;
    }

    #npcStoryList {
        padding: 3px 0 !important;
    }

    /* 故事内容响应式 */
    .story-content {
        padding: 15px;
        font-size: 14px;
    }

    .story-block {
        padding: 12px;
        margin-bottom: 12px;
    }

    .story-block h4 {
        font-size: 14px;
    }

    .story-block p {
        font-size: 13px;
        line-height: 1.5;
    }

    /* 输入区域响应式 */
    .input-area {
        padding: 15px;
    }

    .chips-indicator {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .input-controls {
        flex-direction: column;
    }

    #userPrompt {
        width: 100%;
        height: 50px;
        font-size: 13px;
        padding: 10px;
    }

    .btn-primary {
        width: 100%;
        padding: 10px;
        font-size: 14px;
    }

    /* 模态框响应式 */
    .modal-content {
        padding: 20px;
        width: 95%;
        max-height: 90vh;
    }

    .modal-content h2 {
        font-size: 18px;
    }

    /* 重新生成按钮响应式 */
    .regenerate-btn {
        font-size: 11px;
        padding: 4px 10px;
    }
}

/* 超小屏幕响应式 */
@media (max-width: 480px) {
    .logo h1 {
        font-size: 16px;
    }

    .npc-selector {
        max-height: 120px;
    }

    .npc-card {
        width: 100px;
    }

    .welcome-screen h2 {
        font-size: 20px;
    }

    .story-content {
        padding: 10px;
    }
}