/* ================= css/pages/chat.css ================= */

/* 聊天页整体布局 */
#view-chat {
    display: none;
    flex-direction: column;
    height: 100vh; height: 100dvh;
    padding-bottom: 0 !important;
    overflow: hidden;
}
#view-chat.active {
    display: flex;
}

/* ====== 顶部导航栏 ====== */
.ch-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
    z-index: 10;
    min-height: 52px;
}
.ch-header-btn {
    width: 36px; height: 36px;
    border: none; background: none;
    font-size: 22px; color: var(--text-primary);
    cursor: pointer; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.ch-header-btn:active {
    background: rgba(0,0,0,0.06);
}
.ch-header-center {
    flex: 1;
    text-align: center;
    min-width: 0;
    overflow: hidden;
}
.ch-header-nick {
    font-size: 17px; font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
    line-height: 1.3;
}
.ch-header-nick:active {
    opacity: 0.6;
}

/* 备注编辑态 */
.ch-nick-input {
    font-size: 17px;
    font-weight: 700;
    border: none;
    border-bottom: 1.5px solid var(--text-primary);
    background: transparent;
    outline: none;
    text-align: center;
    width: 100%;
    max-width: 220px;
    padding: 2px 4px;
    font-family: inherit;
    color: var(--text-primary);
}

/* ====== 消息列表区域 ====== */
.ch-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: none;
}
.ch-messages::-webkit-scrollbar { display: none; }

/* 时间分隔线 */
.ch-time-divider {
    text-align: center;
    padding: 4px 0;
}
.ch-time-divider span {
    font-size: 12px;
    color: var(--text-tertiary);
    background: rgba(0,0,0,0.03);
    padding: 3px 12px;
    border-radius: 10px;
}

/* ====== 消息行 ====== */
.ch-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-items: flex-start;
}
.ch-msg-ai {
    align-self: flex-start;
}
.ch-msg-user {
    align-self: flex-end;
}

/* 头像 */
.ch-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    flex-shrink: 0;
}
.ch-avatar-ai {
    background: linear-gradient(135deg, #3A3A3C, #1C1C1E);
    color: #fff;
}
.ch-avatar-user {
    background: linear-gradient(135deg, #8B7355, #6B5B45);
    color: #fff;
}
.ch-avatar img {
    width: 100%; height: 100%;
    object-fit: cover; border-radius: 50%;
}

/* 消息主体 */
.ch-msg-body {
    display: flex; flex-direction: column;
    min-width: 0;
}
.ch-msg-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    padding: 0 4px;
}
.ch-msg-user .ch-msg-meta {
    text-align: right;
}

/* 气泡 */
.ch-bubble {
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.65;
    word-break: break-word;
}
.ch-bubble-ai {
    background: rgba(0,0,0,0.04);
    border-radius: 2px 16px 16px 16px;
    color: var(--text-primary);
}
.ch-bubble-user {
    background: #4A3F35;
    border-radius: 16px 2px 16px 16px;
    color: #fff;
}

/* 表情包消息 */
.ch-bubble-sticker {
    background: transparent !important;
    padding: 4px !important;
}
.ch-bubble-sticker img {
    max-width: 120px; max-height: 120px;
    border-radius: 8px;
}

/* 思考过程（Thinking）— 在气泡下方 */
.ch-thinking {
    margin-top: 6px;
    margin-left: 4px;
}
.ch-thinking-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    transition: background 0.15s;
    border: none; text-align: left;
    font-family: inherit;
    width: fit-content;
}
.ch-thinking-toggle:hover {
    background: rgba(0,0,0,0.06);
}
.ch-thinking-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}
.ch-thinking-arrow.open {
    transform: rotate(90deg);
}
.ch-thinking-content {
    display: none;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding: 8px 12px;
    margin-top: 4px;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
    border-left: 2px solid rgba(0,0,0,0.08);
}
.ch-thinking-content.open {
    display: block;
}

/* ====== 操作过程折叠块（独立于气泡外） ====== */
.ch-ops-block {
    align-self: flex-start;
    margin-left: 48px;
    width: calc(100% - 64px);
}
.ch-ops-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 14px;
    background: rgba(0,0,0,0.03);
    border-radius: 10px;
    transition: background 0.15s;
    font-weight: 600;
}
.ch-ops-toggle:active {
    background: rgba(0,0,0,0.06);
}
.ch-ops-arrow {
    font-size: 11px;
    transition: transform 0.25s;
    display: inline-block;
}
.ch-ops-arrow.open {
    transform: rotate(90deg);
}
.ch-ops-detail {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    padding-left: 6px;
    animation: opsSlideIn 0.2s ease;
}
.ch-ops-detail.open {
    display: flex;
}
@keyframes opsSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.ch-ops-row {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
    border-left: 2px solid rgba(0,0,0,0.06);
    line-height: 1.5;
}

/* ====== 底部输入区 ====== */
.ch-input-area {
    flex-shrink: 0;
    background: var(--bg-color, #F2F2F7);
    border-top: 1px solid rgba(0,0,0,0.06);
    padding-bottom: env(safe-area-inset-bottom);
}
.ch-input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
}
.ch-input-btn {
    width: 36px; height: 36px;
    border: none; background: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}
.ch-input-btn:active {
    background: rgba(0,0,0,0.06);
}
.ch-input-btn.active {
    color: var(--text-primary);
}
.ch-input-field {
    flex: 1;
    padding: 9px 16px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.8);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    color: var(--text-primary);
    min-width: 0;
    transition: border-color 0.2s;
}
.ch-input-field:focus {
    border-color: rgba(0,0,0,0.2);
}
.ch-input-field::placeholder {
    color: var(--text-tertiary);
}
.ch-send-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--text-primary, #1C1C1E);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}
.ch-send-btn:active {
    transform: scale(0.9);
}
.ch-send-btn:disabled {
    opacity: 0.35; cursor: not-allowed;
}

/* ====== ⊕ 功能面板 ====== */
.ch-plus-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
                padding 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding: 0 16px;
    background: var(--bg-color, #F2F2F7);
}
.ch-plus-panel.open {
    max-height: 220px;
    padding: 8px 16px 16px;
}
.ch-plus-grip {
    width: 36px; height: 4px;
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
    margin: 4px auto 12px;
}
.ch-plus-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px 12px;
    justify-items: center;
}
.ch-plus-item {
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    cursor: pointer;
    transition: transform 0.15s;
}
.ch-plus-item:active {
    transform: scale(0.9);
}
.ch-plus-icon-box {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(0,0,0,0.06);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
}
.ch-plus-item span {
    font-size: 11px; font-weight: 500;
    color: var(--text-secondary);
}

/* ====== AI 正在输入指示器 ====== */
.ch-typing {
    display: flex; gap: 10px;
    align-items: flex-start;
    align-self: flex-start;
}
.ch-typing-dots {
    display: flex; gap: 4px;
    padding: 12px 16px;
    background: rgba(0,0,0,0.04);
    border-radius: 2px 16px 16px 16px;
}
.ch-typing-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.4s infinite ease-in-out;
}
.ch-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ch-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}
