/**
 * 应用全局样式 — 统一布局系统
 * 所有页面共享的 CSS，保持一致性
 */

/* ============ 统一页面布局 ============ */

/* 基础页面容器 — 全屏 flex 列布局 */
.page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: oklch(var(--b2));
}

/* 主内容滚动区 — 无侧边栏 */
.page-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
}

/* 内容容器 — 居中 + 最大宽度 */
.page-content {
    width: 100%;
    max-width: 48rem;    /* 768px = max-w-3xl */
    margin: 0 auto;
    padding: 1rem;
}

/* 主内容滚动区 — 有侧边栏（flex 容器，整体居中） */
.page-layout {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

/* 侧边栏基础 — 透明背景透出 base-200，面板浮于其上 */
.page-sidebar {
    width: 240px;
    flex-shrink: 0;
    display: none;
    overflow: hidden;
    padding: 0.75rem 0;
}

@media (min-width: 1024px) {
    .page-sidebar {
        display: flex;
        flex-direction: column;
    }
}

/* 侧栏内容面板 — 卡片风格，与主内容一致 */
.sidebar-panel {
    background-color: oklch(var(--b1));
    border-radius: var(--rounded-box, 1rem);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* 小屏桌面隐藏右侧栏（1280px 以下） */
@media (max-width: 1279px) {
    .page-sidebar-right {
        display: none !important;
    }
}

.page-sidebar-left {
    border-right: 1px solid oklch(var(--b3) / 0.3);
}

.page-sidebar-right {
    border-left: 1px solid oklch(var(--b3) / 0.3);
}

/* 侧边栏内容区 */
.sidebar-section {
    padding: 1rem;               /* 内边距 1rem，与主内容卡片一致 */
}

.sidebar-section-header {
    padding: 1rem 1rem 0.5rem;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0 0.5rem 1rem;
}

/* 侧边栏底部操作区 */
.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid oklch(var(--b3));
    flex-shrink: 0;
}

/* 侧边栏旁的主内容区 */
.page-main {
    width: 100%;
    max-width: 48rem;
    overflow-y: auto;
}

/* 侧边栏旁的内容容器 */
.page-main > .page-content {
    max-width: 48rem;
    margin: 0 auto;
    padding: 1rem;
}


/* ============ 弹性内容布局 — 消息区自适应，输入区吸底 ============ */
.page-content-sticky {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 1rem;
    padding: 1rem;
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
}
.scroll-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.sticky-bottom {
    flex-shrink: 0;
}

/* ============ 极小字体（用于时间戳等次要信息） ============ */
.text-tiny {
    font-size: 0.625rem;
    line-height: 1rem;
}

/* ============ 统一卡片风格 ============ */
.card-base {
    background-color: oklch(var(--b1));
    border-radius: var(--rounded-box, 1rem);
    box-shadow: 0 1px 3px oklch(0 0 0 / 0.08);
}

.card-hover {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card-hover:hover {
    box-shadow: 0 4px 12px oklch(0 0 0 / 0.1);
    transform: translateY(-1px);
}

/* ============ 统一空状态 ============ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: oklch(var(--bc) / 0.35);
    text-align: center;
}
.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}
.empty-state .text {
    font-size: 0.75rem;
    line-height: 1.4;
}

/* ============ 列表项基础 ============ */
.list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: background-color 0.15s ease;
}
.list-item:hover {
    background-color: oklch(var(--b2) / 0.6);
}
.list-item.active {
    background-color: oklch(var(--p) / 0.1);
    border-left: 3px solid oklch(var(--p));
    box-shadow: 0 1px 2px oklch(0 0 0 / 0.05);
}

/* ============ 按钮交互效果 ============ */
.btn {
    transition: all 0.15s ease;
}
.btn:active {
    transform: scale(0.97);
}

/* ============ 头像圆标 ============ */
.avatar-circle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ============ 消息气泡动画 ============ */
.chat-bubble {
    animation: bubble-in 0.2s ease-out;
}
@keyframes bubble-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============ Toast动画 ============ */
.toast .alert {
    animation: toast-in 0.3s ease-out;
}
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============ Modal动画 ============ */
.modal-box {
    animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: oklch(var(--b3));
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: oklch(var(--b4));
}

/* ============ 输入框聚焦效果 ============ */
.input:focus,
.textarea:focus,
.select:focus {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ============ 移动端优化 ============ */
@media (max-width: 1023px) {
    .navbar-center {
        display: none !important;
    }
    /* 移动端侧栏滑出覆盖 — 复用桌面内容 */
    .page-sidebar-left {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 40;
        padding-top: 0;
        padding-bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 20px oklch(0 0 0 / 0.15);
    }
    .page-sidebar-left.sidebar-open {
        transform: translateX(0);
    }
    .sidebar-mask {
        position: fixed;
        inset: 0;
        z-index: 39;
        background: oklch(0 0 0 / 0.3);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .sidebar-mask.show {
        opacity: 1;
        pointer-events: auto;
    }
}

/* 小屏手机：紧凑内边距、自适应元素 */
@media (max-width: 639px) {
    .page-content,
    .page-content-sticky,
    .page-main > .page-content {
        padding: 0.75rem;
    }
    .page-content-sticky {
        gap: 0.75rem;
    }

    /* 论坛搜索：按钮仅图标 */
    .search-btn-text {
        display: none;
    }
    .search-btn-icon {
        display: inline;
    }

    /* toast 适配小屏 */
    .toast {
        right: 0.5rem;
        left: 0.5rem;
        bottom: 0.5rem;
    }
    .toast .alert {
        width: 100%;
    }

    /* 导航栏紧凑 */
    .navbar {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    .navbar .select {
        width: 6rem;
    }

    /* 侧栏面板全宽边距 */
    .sidebar-panel {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* modal 内边距紧凑 */
    .modal-box {
        padding: 1rem;
    }

    /* 聊天/AI 消息气泡自适应 */
    .chat-bubble {
        max-width: 85vw;
    }
}

/* 超小屏（<400px）：进一步压缩 */
@media (max-width: 399px) {
    .navbar .select {
        width: 3.5rem;
        font-size: 0.65rem;
    }
    .navbar .btn-ghost {
        padding-left: 0.2rem;
        padding-right: 0.2rem;
    }
    .page-content,
    .page-content-sticky {
        padding: 0.5rem;
    }
}

/* 移动端吸底元素适配安全区 */
.sticky-bottom {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem)) !important;
}

/* 大屏安全区 */
@media (min-width: 1024px) {
    .search-btn-icon {
        display: none;
    }
    .search-btn-text {
        display: inline;
    }
}

/* ============ 文本截断 ============ */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

