/*
AI 故事机 - 前端样式表 (static/style.css)
--------------------------------------
功能：
1. 包含故事机页面的主要视觉设计样式，如玻璃拟态（Glassmorphism）、卡通渐变背景。
2. 包含气泡对话的卡片效果样式、AI 思考时的跳动加载动画样式。
3. 定义了微信风格的录音提示浮层及录音按键的状态过渡动画。

使用方式：
通过 static/index.html 的 <link href="/static/style.css" rel="stylesheet"> 标签引入。
*/

:root {
    /* 男孩星空探索主题 */
    --primary-color: #00d2ff;
    --primary-light: #3a7bd5;
    --bg-gradient-start: #0f2027;
    --bg-gradient-end: #2c5364;
    --text-color: #ecf0f1;
    --ai-bubble-bg: #1e293b;
    --user-bubble-bg: #00d2ff;
    --shadow-soft: 0 8px 30px rgba(0,0,0,0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    height: 100%;
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-color);
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-soft);
}

@media (min-width: 500px) {
    .app-container {
        height: 95vh;
        border-radius: 30px;
        margin-top: 2.5vh;
        border: 2px solid rgba(255, 255, 255, 0.6);
    }
}

.header {
    display: flex;
    align-items: center;
    padding: 20px 25px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.header-left {
    margin-right: 15px;
}

.profile-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid rgba(15, 23, 42, 0.8);
    pointer-events: none;
}

.profile-tooltip {
    position: absolute;
    top: 55px;
    right: 0;
    background: var(--primary-color);
    color: #0f172a;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 210, 255, 0.4);
    animation: bounceTooltip 2s infinite;
    pointer-events: none;
}
.profile-tooltip::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 15px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--primary-color);
}
@keyframes bounceTooltip {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.avatar {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
    margin-right: 15px;
    animation: float 3s ease-in-out infinite;
    border: 2px solid var(--primary-color);
}

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

.title-container {
    display: flex;
    flex-direction: column;
}

h1 {
    font-family: 'ZCOOL KuaiLe', cursive;
    color: var(--primary-color);
    font-size: 22px;
    margin-bottom: 2px;
}

.subtitle {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 600;
}

.chat-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    max-width: 85%;
    animation: slideUp 0.3s ease-out;
}

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

.ai-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.bubble {
    padding: 14px 18px;
    border-radius: 24px;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    position: relative;
    word-break: break-word;
}

.ai-message .bubble {
    background: var(--ai-bubble-bg);
    border-bottom-left-radius: 6px;
    color: var(--text-color);
}

.user-message .bubble {
    background: var(--user-bubble-bg);
    color: white;
    border-bottom-right-radius: 6px;
}

.controls {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px 20px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
}

.status-indicator {
    text-align: center;
    font-size: 12px;
    color: #b2bec3;
    font-weight: 600;
    margin-bottom: 5px;
}

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

.record-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    color: #0f172a;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 210, 255, 0.3);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.record-btn:active, .record-btn.recording {
    transform: scale(0.9);
    background: var(--primary-color);
}

.record-btn.recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.6); }
    70% { box-shadow: 0 0 0 15px rgba(0, 210, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0); }
}

.text-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: #1e293b;
    border-radius: 25px;
    padding: 5px 5px 5px 20px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2), 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.1);
}

.text-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-color);
    background: transparent;
}

.text-input-wrapper input::placeholder {
    color: #b2bec3;
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: #0f172a;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:active {
    transform: scale(0.9);
    background: #000;
}

/* 隐藏系统滚动条 */
::-webkit-scrollbar {
    display: none;
}

/* Bouncing animation for loading */
.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    width: fit-content;
    margin: 10px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #6366f1;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* WeChat Style Voice Button */
.toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.toggle-btn:active {
    transform: scale(0.9);
}

.voice-mode-container {
    flex: 1;
    display: flex;
    justify-content: center;
}

.wechat-record-btn {
    width: 100%;
    height: 44px;
    border-radius: 22px;
    border: none;
    background: #1e293b;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2), 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.1s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    border: 1px solid rgba(0, 210, 255, 0.3);
}

.wechat-record-btn.recording {
    background: #0f172a;
    color: #64748b;
}

.hidden {
    display: none !important;
}

/* 录音指示器浮层 */
.recording-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.recording-overlay.show {
    opacity: 1;
}

.recording-overlay i {
    font-size: 48px;
    margin-bottom: 8px;
    animation: pulse-mic 1s infinite alternate;
}

@keyframes pulse-mic {
    0% { opacity: 0.6; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1.05); }
}

.recording-overlay span {
    font-size: 14px;
    font-weight: 500;
}

/* 顶部按钮 */
.header-actions {
    margin-left: auto;
}
.icon-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--primary-color);
    cursor: pointer;
    transition: transform 0.2s;
}
.icon-btn:active {
    transform: scale(0.9);
}

/* 互动选项卡片 */
.options-container {
    padding: 0 20px 10px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: wrap;
    justify-content: center;
}
.option-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 16px;
    padding: 12px 18px;
    font-weight: bold;
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    border: 1px solid rgba(0, 210, 255, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.option-card:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 侧边栏和抽屉通用 */
.drawer, .sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    transition: opacity 0.3s;
}
.drawer.hidden, .sidebar-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 侧边栏样式 */
.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: #0f172a;
    z-index: 1001;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.1);
    box-shadow: 5px 0 20px rgba(0,0,0,0.5);
}
.sidebar.hidden {
    transform: translateX(-100%);
}
.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-header h3 {
    color: var(--text-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.new-session-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.parent-entry-btn {
    width: 100%;
    background: transparent;
    border: 1px dashed rgba(255, 71, 87, 0.5);
    color: #ff6b81;
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.parent-entry-btn:hover {
    background: rgba(255, 71, 87, 0.1);
    border-style: solid;
}
.session-item {
    padding: 12px 15px;
    border-radius: 12px;
    margin-bottom: 5px;
    cursor: pointer;
    color: #94a3b8;
    transition: background 0.2s, color 0.2s;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.session-item i {
    font-size: 18px;
    color: #64748b;
}
.session-item:hover {
    background: rgba(255,255,255,0.05);
}
.session-item.active {
    background: #1e293b;
    color: var(--primary-color);
}
.session-item.active i {
    color: var(--primary-color);
}

/* 底部抽屉样式 */
.drawer {
    display: flex;
    align-items: flex-end;
}
.drawer-content {
    width: 100%;
    background: #1e293b;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 20px;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    border-top: 1px solid rgba(255,255,255,0.1);
}
.drawer.hidden .drawer-content {
    transform: translateY(100%);
}
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.drawer-header h3 {
    color: var(--text-color);
}
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 5px;
    font-weight: 600;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: #0f172a;
    font-size: 15px;
    color: white;
    outline: none;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(58, 123, 213, 0.3);
}

.preset-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.preset-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 210, 255, 0.3);
    color: var(--text-color);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.preset-tag:hover {
    background: rgba(0, 210, 255, 0.2);
    color: var(--primary-color);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}
.primary-btn, .secondary-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.1s;
}
.primary-btn:active, .secondary-btn:active {
    transform: scale(0.95);
}
.primary-btn {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    color: #0f172a;
}
.secondary-btn {
    background: #334155;
    color: var(--text-color);
}

