/* 稷下回忆录 Portal - 底部聊天 Dock */

/* ─── 底部固定 Dock ─── */
.ec-chat-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    transition: height 0.25s ease;
    height: 44px; /* 收起状态：只有 header */
    overflow: hidden;
}

.ec-chat-panel.expanded {
    height: min(45vh, 320px); /* 展开状态：自适应屏幕高度 */
}

/* 页面内容底部留白，避免被 Dock 遮挡 */
body.ec-chat-active main {
    padding-bottom: 52px;
    transition: padding-bottom 0.25s ease;
}
body.ec-chat-active.ec-chat-expanded main {
    padding-bottom: min(calc(45vh + 8px), 328px);
}

/* ─── 收起时隐藏消息区和输入栏 ─── */
.ec-chat-panel:not(.expanded) .ec-chat-messages,
.ec-chat-panel:not(.expanded) .ec-chat-input-bar {
    display: none;
}

/* ─── 头部（点击展开/收起）─── */
.ec-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.ec-chat-header:hover {
    background: #f9fafb;
}

.ec-chat-title {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ec-chat-status {
    font-size: 10px;
    color: #10b981;
    font-weight: 400;
}

.ec-chat-toggle {
    font-size: 12px;
    color: #9ca3af;
    transition: transform 0.2s;
}

.ec-chat-panel.expanded .ec-chat-toggle {
    transform: rotate(180deg);
}

/* ─── 消息列表（展开时显示）─── */
.ec-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    min-height: 0;
}

.ec-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.ec-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

/* ─── 消息气泡 ─── */
.ec-msg {
    max-width: 80%;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.ec-msg-user {
    align-self: flex-end;
    background: oklch(var(--p) / 1);
    color: oklch(var(--pc) / 1);
    border-bottom-right-radius: 3px;
}

.ec-msg-ai {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 3px;
}

.ec-msg-system {
    align-self: center;
    font-size: 11px;
    color: #9ca3af;
    background: none;
    padding: 2px 0;
    max-width: 100%;
    text-align: center;
}

/* ─── 输入栏 ─── */
.ec-chat-input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    flex-shrink: 0;
    border-top: 1px solid #f3f4f6;
}

.ec-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 7px 14px;
    font-size: 13px;
    outline: none;
    background: #fff;
    transition: border-color 0.2s;
    min-width: 0;
}

.ec-chat-input:focus {
    border-color: oklch(var(--p) / 0.5);
}

.ec-mic-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ec-mic-btn:hover {
    background: #e5e7eb;
}

.ec-mic-btn.recording {
    background: #ef4444;
    color: #fff;
    animation: ec-pulse 1.2s infinite;
}

@keyframes ec-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.ec-send-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: oklch(var(--p) / 1);
    color: oklch(var(--pc) / 1);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.ec-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ─── 响应式：桌面端对齐主内容容器 ─── */
@media (min-width: 769px) {
    .ec-chat-panel {
        max-width: 72rem; /* 匹配 max-w-6xl = 1152px */
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    }
}
