/* Zen Chat Page Styles */

:root {
    --zen-primary: #2c2c2c;
    --zen-secondary: #666;
    --zen-border: #e0e0e0;
    --zen-bg: #fafafa;
    --zen-card-bg: #ffffff;
    --zen-shadow: rgba(0, 0, 0, 0.08);
    --zen-accent: #8b7355;
    --transition: 0.3s ease;
}

body {
    background: var(--zen-bg);
    padding-top: 60px; /* Match mobile navbar height */
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
    /* 移动端触摸优化 */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-touch-callout: none;
    /* 防止文本选择（在某些交互元素上） */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Main Container */
.zen-container {
    max-width: 700px;
    width: 100%;
    margin: 0 auto;
    padding: 3rem 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 80px);
    box-sizing: border-box;
}

/* ============================================
   Container Mode System (容器模式系统)
   
   使用模式类来控制不同的页面布局和功能。
   每个模式可以有独特的布局、显示/隐藏规则和样式。
   
   当前支持的模式：
   - mode-dialogue: 对话模式
   - mode-meditation: 冥想模式
   
   未来可扩展的模式示例：
   - mode-journal: 日记模式
   - mode-wisdom: 智慧模式
   - mode-reflection: 反思模式
   ============================================ */

/* Mode: Dialogue (对话模式) */
.zen-container.mode-dialogue {
    /* 对话模式使用默认布局 */
}

/* Mode: Meditation (冥想模式) */
.zen-container.mode-meditation {
    /* 保持与对话模式相同的 padding-top，确保位置一致 */
    padding-bottom: 0;
    justify-content: flex-start;
}

/* Greeting Section */
.zen-greeting {
    text-align: center;
    padding-top: 3rem;
    margin-bottom: 2rem;
    flex-shrink: 0;
}

/* 固定头部容器 - 防止切换时跳动 */
.zen-header-container {
    min-height: 180px; /* 固定容器高度，预留统计信息和引导语的空间 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.zen-title {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--zen-primary);
    margin: 0 0 0.75rem 0;
    letter-spacing: 0.1em;
}

.zen-subtitle {
    font-size: 1rem;
    font-weight: 300;
    color: var(--zen-secondary);
    margin: 0;
    line-height: 1.8;
    min-height: 1.8rem; /* 固定最小高度 */
}

/* Zen Stats - 统计信息（副标题下方） */
.zen-stats {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--zen-secondary);
    opacity: 0.5;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 1.8rem; /* 固定最小高度，与引导语保持一致 */
}

.zen-stats-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.zen-stats-label {
    font-weight: 300;
}

.zen-stats-value {
    font-weight: 400;
    color: var(--zen-accent);
    opacity: 0.7;
}

.zen-stats-separator {
    opacity: 0.3;
    margin: 0 0.25rem;
}

/* Meditation Guide - 冥想引导语 */
.zen-meditation-guide {
    margin-top: 0.5rem;
    padding: 0 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    min-height: 1.8rem; /* 固定最小高度，与统计信息保持一致 */
}

.meditation-guide-text {
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--zen-secondary);
    opacity: 0.7;
    line-height: 1.8;
    letter-spacing: 0.05em;
    margin: 0;
    text-align: center;
}

/* ============================================
   Chat Area (对话区域)
   
   显示规则：
   - mode-dialogue: 显示
   - mode-meditation: 隐藏
   ============================================ */
.zen-chat-area {
    flex: 1;
    overflow-y: auto;
    opacity: 1;
    transition: opacity 0.3s ease;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 100%;
}

.zen-container.mode-meditation .zen-chat-area {
    display: none !important;
}

.zen-cards {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
    max-width: 100%;
}

/* Zen Card */
.zen-card {
    background: var(--zen-card-bg);
    border: 1px solid var(--zen-border);
    border-radius: 8px;
    padding: 2rem;
    padding-bottom: 3.5rem;
    box-shadow: 0 1px 3px var(--zen-shadow);
    animation: slideUp 1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    width: 500px;
    max-width: 100%;
    margin: 0 auto;
    min-height: auto;
}

/* Thinking State Card */
.zen-card.thinking {
    padding: 3rem 2rem;
    text-align: center;
    animation: fadeIn 0.6s ease;
}

.zen-card.thinking .thinking-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.thinking-dots {
    display: flex;
    gap: 0.5rem;
}

.thinking-dots .dot {
    width: 8px;
    height: 8px;
    background: var(--zen-accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.thinking-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.thinking-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
}

.thinking-text {
    font-size: 0.9rem;
    color: var(--zen-secondary);
    font-weight: 300;
}

/* Card Content (for image export) */
.zen-card-content {
    position: relative;
    /* 确保内容区域有正确的内边距，用于图片导出 */
    padding: 0;
}

.zen-card-question {
    margin: 0 0 1.5rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--zen-border);
    animation: fadeIn 0.6s ease 0.2s both;
}

.zen-card-question-label {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--zen-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
    display: block;
    opacity: 0.6;
}

.zen-card-question-text {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--zen-primary);
    line-height: 1.8;
    margin: 0;
    /* 允许文本选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.zen-card-answer {
    margin: 0;
    animation: expandFromTop 1.2s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
    transform-origin: top;
}

.zen-card-answer-label {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--zen-accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
    display: block;
    opacity: 0.6;
    animation: fadeIn 0.6s ease 0.6s both;
}

.zen-card-answer-text {
    font-size: 0.95rem;
    font-weight: 300;
    color: var(--zen-primary);
    line-height: 1.9;
    white-space: pre-wrap;
    margin: 0;
    animation: fadeIn 0.8s ease 1.8s both;
    /* 允许文本选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Watermark (only shown in exported image) */
.zen-card-watermark {
    display: none; /* 默认隐藏 */
    text-align: center;
    padding: 1.5rem 0 0 0;
    margin-top: 1.5rem;
    border-top: 1px solid var(--zen-border);
    font-size: 0.9rem;
    color: var(--zen-secondary);
    opacity: 0.6;
    font-weight: 300;
    letter-spacing: 0.05em;
}

/* Card Retry Button (top-right) */
.card-retry-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--zen-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    opacity: 0.4;
    z-index: 10;
    animation: fadeIn 0.6s ease 0.5s both;
}

.card-retry-btn:hover {
    color: var(--zen-accent);
    background: var(--zen-bg);
    opacity: 1;
    transform: rotate(180deg);
}

.card-retry-btn:active {
    transform: rotate(180deg) scale(0.95);
}

/* Card Action Buttons */
.zen-card-actions {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    animation: fadeIn 0.6s ease 0.8s both;
}

.card-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--zen-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    opacity: 0.5;
}

.card-action-btn:hover {
    color: var(--zen-accent);
    background: var(--zen-bg);
    opacity: 1;
}

.card-action-btn.active {
    color: var(--zen-accent);
    opacity: 1;
}

/* Reply Section (回复输入框) */
.zen-reply-section {
    background: var(--zen-card-bg);
    border: 1px solid var(--zen-border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px var(--zen-shadow);
    margin-top: 1rem;
    width: 500px;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.reply-input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.zen-reply-textarea {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--zen-border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 300;
    line-height: 1.5;
    color: var(--zen-primary);
    background: var(--zen-bg);
    resize: none;
    font-family: inherit;
    transition: border-color var(--transition);
    /* 允许文本选择和编辑 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    /* 移动端优化 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.zen-reply-textarea:focus {
    outline: none;
    border-color: var(--zen-accent);
}

.zen-reply-textarea::placeholder {
    color: var(--zen-secondary);
    opacity: 0.5;
}

.reply-submit-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border: none;
    background: var(--zen-accent);
    color: white;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
}

.reply-submit-btn:hover {
    background: var(--zen-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--zen-shadow);
}

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

.reply-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}


/* ============================================
   Input Section (输入框)
   
   显示规则：
   - mode-dialogue: 动态显示/隐藏（由JS控制）
   - mode-meditation: 隐藏
   ============================================ */
.zen-input-section {
    background: var(--zen-card-bg);
    border: 1px solid var(--zen-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px var(--zen-shadow);
    margin-top: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.zen-container.mode-meditation .zen-input-section {
    display: none;
}

.input-container {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.zen-textarea {
    flex: 1;
    min-height: 24px;
    max-height: 120px;
    padding: 0.5rem 0;
    border: none;
    font-size: 0.95rem;
    font-weight: 300;
    line-height: 1.5;
    color: var(--zen-primary);
    background: transparent;
    resize: none;
    font-family: inherit;
    overflow: hidden;
    /* 允许文本选择和编辑 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    /* 移动端优化 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.zen-textarea:focus {
    outline: none;
}

.zen-textarea::placeholder {
    color: var(--zen-secondary);
    opacity: 0.4;
}

.zen-privacy-hint {
    font-size: 0.75rem;
    color: var(--zen-secondary);
    opacity: 0.5;
    text-align: center;
    margin: 0.5rem 0 0 0;
    line-height: 1.4;
    font-weight: 300;
    letter-spacing: 0.05em;
}


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

@keyframes expandFromTop {
    from {
        transform: scaleY(0);
        opacity: 0;
    }
    50% {
        opacity: 0.5;
    }
    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

/* ============================================
   Tab Switcher
   ============================================ */
.zen-tabs {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0 0;
    padding: 0;
}

.zen-tab {
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--zen-secondary);
    padding: 0.5rem 0;
    cursor: pointer;
    position: relative;
    transition: color var(--transition);
    letter-spacing: 0.05em;
}

.zen-tab:hover {
    color: var(--zen-primary);
}

.zen-tab.active {
    color: var(--zen-primary);
    font-weight: 400;
}

.zen-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--zen-accent);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: scaleX(0);
        opacity: 0;
    }
    to {
        transform: scaleX(1);
        opacity: 1;
    }
}

/* ============================================
   Meditation Area (冥想区域)
   
   显示规则：
   - mode-dialogue: 隐藏
   - mode-meditation: 显示
   ============================================ */
.zen-meditation-area {
    display: none; /* 默认隐藏 */
    align-items: center;
    justify-content: center;
    margin-bottom: 3rem;
    opacity: 1;
    transition: opacity 0.3s ease;
    flex-shrink: 0; /* 不要收缩 */
    width: 100%;
    max-width: 100%;
}

.zen-container.mode-dialogue .zen-meditation-area {
    display: none !important;
}

.zen-container.mode-meditation .zen-meditation-area {
    display: flex !important;
    margin-bottom: 2rem;
}

.meditation-container {
    text-align: center;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
}

/* Circular Timer */
.meditation-timer {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 2rem;
}

.timer-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: var(--zen-border);
    stroke-width: 3;
}

.timer-ring-progress {
    fill: none;
    stroke: var(--zen-accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 0.3s linear;
    opacity: 0.8;
}

/* Subtle breathing effect on ring when playing */
.meditation-timer.playing .timer-ring-progress {
    animation: ringBreathe 8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes ringBreathe {
    0%, 100% {
        opacity: 0.7;
        stroke-width: 3;
    }
    50% {
        opacity: 1;
        stroke-width: 3.5;
    }
}

/* Play Button in Center */
.meditation-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--zen-card-bg);
    border: 1px solid var(--zen-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 12px var(--zen-shadow);
    padding: 0;
}

.meditation-play-btn:hover {
    box-shadow: 0 6px 16px var(--zen-shadow);
    border-color: var(--zen-accent);
}

/* Only scale on hover when not playing */
.meditation-timer:not(.playing) .meditation-play-btn:hover {
    transform: translate(-50%, -50%) scale(1.05);
}

.meditation-timer:not(.playing) .meditation-play-btn:active {
    transform: translate(-50%, -50%) scale(0.98);
}

.play-icon {
    display: block;
    color: var(--zen-primary);
}

.pause-icon {
    display: block;
    color: var(--zen-secondary);
    opacity: 0.5;
}

/* Time Display - Hidden */
.meditation-time {
    display: none;
}

/* Meditation Title */
.meditation-title {
    font-size: 1rem;
    color: var(--zen-primary);
    font-weight: 300;
    margin: 0;
    letter-spacing: 0.1em;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

/* Subtle breathing effect on title when playing */
.meditation-container.playing .meditation-title {
    animation: textBreathe 8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes textBreathe {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Breathing animation when playing */
.meditation-timer.playing .meditation-play-btn {
    animation: breathe 8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes breathe {
    0%, 100% {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0.85;
        box-shadow: 0 4px 12px var(--zen-shadow);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
        box-shadow: 0 8px 24px rgba(139, 115, 85, 0.4);
    }
}


@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    60% {
        opacity: 0.8;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Empty State */
.zen-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--zen-secondary);
    opacity: 0.7;
}

.zen-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.zen-empty-text {
    font-size: 1rem;
    font-weight: 300;
}

/* Mobile Design Overrides */
@media (max-width: 768px) {
    .zen-container {
        padding: 2rem 1rem 1.5rem;
    }

    .zen-container.mode-meditation {
        /* 只调整左右和底部padding，保持顶部padding与对话模式一致 */
        padding-left: 1rem;
        padding-right: 1rem;
        padding-bottom: 0;
    }

    .zen-input-section {
        margin-top: 1.5rem;
    }

    .zen-title {
        font-size: 2rem;
    }

    .zen-subtitle {
        font-size: 0.9rem;
    }

    .zen-stats {
        font-size: 0.7rem;
    }

    .zen-meditation-guide {
        padding: 0 1rem;
    }

    .meditation-guide-text {
        font-size: 0.8rem;
    }

    .zen-greeting {
        padding-top: 2rem;
        margin-bottom: 2rem;
    }
    
    /* 冥想模式下稍微减少底部间距 */
    .zen-container.mode-meditation .zen-greeting {
        margin-bottom: 1.5rem;
    }

    .zen-header-container {
        min-height: 170px;
    }

    .zen-card {
        padding: 1.5rem;
        width: 100%;
        max-width: 100%;
    }

    .zen-card-question-text {
        font-size: 0.9rem;
    }

    .zen-card-answer-text {
        font-size: 0.9rem;
    }

    .zen-textarea {
        font-size: 0.9rem;
        min-height: 44px; /* Touch target size */
    }

    .card-action-btn {
        min-width: 44px; /* Touch target size */
        min-height: 44px;
    }
    
    .card-retry-btn {
        min-width: 44px; /* Touch target size */
        min-height: 44px;
    }
    
    .meditation-timer {
        width: 240px;
        height: 240px;
    }
    
    .meditation-play-btn {
        width: 70px;
        height: 70px;
    }
    
    .zen-tabs {
        gap: 1.5rem;
    }
    
    .zen-reply-section {
        width: 100%;
        padding: 0.75rem;
    }
    
    .zen-reply-textarea {
        font-size: 0.9rem;
        min-height: 44px; /* Touch target size */
    }
    
    .reply-submit-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

/* Desktop Design */
@media (min-width: 769px) {
    body {
        padding-top: 70px; /* Match desktop navbar height */
    }
    
    .zen-container {
        padding: 3rem 1.5rem 2rem;
    }
    
    .zen-container.mode-meditation {
        /* 只调整左右和底部padding，保持顶部padding与对话模式一致 */
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        padding-bottom: 0;
        justify-content: flex-start;
    }

    .zen-input-section {
        margin-top: 2rem;
    }

    .zen-title {
        font-size: 2.5rem;
    }

    .zen-subtitle {
        font-size: 1rem;
    }

    .zen-greeting {
        padding-top: 4rem;
        margin-bottom: 2.5rem;
    }
    
    /* 冥想模式下稍微减少底部间距 */
    .zen-container.mode-meditation .zen-greeting {
        margin-bottom: 2rem;
    }

    .zen-header-container {
        min-height: 180px; /* 桌面端固定容器高度，预留统计信息和引导语的空间 */
    }

    .meditation-guide-text {
        font-size: 0.85rem;
    }

    .zen-card {
        padding: 2rem;
        width: 500px;
        max-width: 100%;
    }

    .zen-card-question-text {
        font-size: 0.95rem;
    }

    .zen-card-answer-text {
        font-size: 0.95rem;
    }

    .zen-textarea {
        font-size: 0.95rem;
        min-height: 24px;
    }
    
    .zen-reply-section {
        width: 500px;
        max-width: 100%;
        padding: 1rem;
    }
    
    .zen-reply-textarea {
        font-size: 0.9rem;
        min-height: 40px;
    }
    
    .reply-submit-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
}


/* Toast Message */
.zen-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--zen-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideInUp 0.3s ease, fadeOut 0.3s ease 2.7s;
    z-index: 1000;
    text-align: center;
}

@keyframes slideInUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
}
