@import url('../shared/colors.css');
@import url('../shared/styles.css');
@import url('fonts.css');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-tab-size: 4;
    tab-size: 4;
    line-height: 1.5;
    font-family: var(--font-sans);
    -webkit-tap-highlight-color: transparent;
    height: 100%;
}

/* body 样式统一在 shared/styles.css */

/* 侧边栏基础样式 */
/* ═══ Sidebar ═══ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    width: var(--sidebar-width);
    background-color: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: width 150ms ease-out, transform 300ms ease;
}

.sidebar[data-collapsible="icon"] {
    width: var(--sidebar-width-icon);
}

/* 折叠态：隐藏文字，居中按钮，缩小图标 */
.sidebar[data-collapsible="icon"] .sidebar-menu-button { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar[data-collapsible="icon"] .sidebar-menu-button > span { display: none; }
.sidebar[data-collapsible="icon"] .sf-btn-text { display: none; }
.sidebar[data-collapsible="icon"] .sidebar-menu-button > img { width: 24px; height: 24px; }
.sidebar[data-collapsible="icon"] .sidebar-nav { padding: 0 8px; align-items: flex-start; }
.sidebar[data-collapsible="icon"] .sidebar-header-inner { justify-content: center; }

/* Sessions 区域：填满 nav/tools 和 footer 之间的空间，内部滚动 */
#sidebar-sessions {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    display: flex;
    flex-direction: column;
}
#sidebar-sessions::-webkit-scrollbar { display: none; }

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.sidebar-header-inner {
    display: flex;
    height: 48px;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
}

.sidebar-trigger {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 350;
    white-space: nowrap;
    border-radius: 6px;
    border: 1px solid transparent;
    background-color: transparent;
    color: var(--muted-foreground);
    width: 36px;
    height: 36px;
    outline: none;
    cursor: pointer;
    transition: all 200ms ease;
}

.sidebar-trigger > svg,
.sidebar-trigger > img {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    pointer-events: none;
    filter: brightness(0) saturate(100%) invert(100%);
}

.sidebar-trigger:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

.sidebar-trigger:focus-visible {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent);
}

.sidebar-trigger:disabled,
.sidebar-trigger[aria-disabled="true"] {
    pointer-events: none;
    opacity: 0.5;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 8px;
    align-items: flex-start;
}

.sidebar-menu-button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    overflow: hidden;
    padding: 8px 16px;
    width: 100%;
    font-size: 14px;
    text-align: start;
    font-weight: 400;
    border-radius: 6px;
    border: 1px solid transparent;
    background-color: transparent;
    position: relative;
    color: var(--sidebar-foreground);
    height: 36px;
    outline: none;
    text-decoration: none;
    cursor: pointer;
    transition: all 200ms ease;
}

.sidebar-menu-button > img,
.sidebar-menu-button > svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    object-fit: contain;
}

.sidebar-menu-button.icon-centered > img,
.sidebar-menu-button.icon-centered > svg {
    margin-left: auto;
    margin-right: auto;
}

.sidebar-menu-button > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.sidebar-menu-button:hover {
    background-color: var(--sidebar-accent);
    color: var(--sidebar-accent-foreground);
}

.sidebar-menu-button:focus {
    background-color: var(--sidebar-accent);
    color: var(--sidebar-accent-foreground);
}

.sidebar-menu-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sidebar-ring);
}

.sidebar-menu-button:active {
    transform: scale(0.98);
}

.sidebar-menu-button:disabled,
.sidebar-menu-button[aria-disabled="true"] {
    pointer-events: none;
    opacity: 0.5;
}

.sidebar-menu-button[data-active="true"] {
    background-color: var(--background);
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.sidebar-menu-button[data-active="true"]:hover {
    background-color: var(--sidebar-accent);
    color: var(--sidebar-accent-foreground);
}

/* 主内容区基础样式 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left 300ms ease, margin-right 300ms ease;
    position: relative;
    min-height: 0;
}

/* 滚动区域：包裹默认视图/动态内容，提示框悬浮其上 */
.scrollable-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}


.container {
    width: 100%;
    max-width: 1400px;
    padding: 0 16px;
    padding-bottom: 24px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    box-sizing: border-box;
}

.image-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto;
}

.icon {
    width: 40px;
    height: 40px;
}

.title {
    margin-top: 4px;
    text-align: center;
    font-size: 36px;
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--foreground);
}

.card-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.image-card {
    position: relative;
    display: flex;
    aspect-ratio: 4/5;
    width: 96px;
    padding: 16px;
    transform-origin: bottom;
    align-items: flex-end;
    overflow: hidden;
    border-radius: 12px;
    background-color: var(--bg-color);
    background-size: cover;
    background-position: center;
    border: none;
    cursor: pointer;
    will-change: transform;
    margin-left: -16px;
    transform: rotate(var(--rotate)) scale(var(--scale)) translateY(var(--translateY));
    transition: transform 200ms ease-out;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.image-card:first-child {
    margin-left: 0;
}

.image-card:hover {
    transform: rotate(var(--rotate)) scale(calc(var(--scale) * 1.05)) translateY(var(--translateY)) !important;
}

.image-card:active {
    transform: rotate(var(--rotate)) scale(0.98) translateY(var(--translateY)) !important;
}

@media (min-width: 1024px) {
    .image-card {
        width: 120px;
    }
}

@media (min-width: 1536px) {
    .image-card {
        width: 168px;
        padding: 24px;
    }
    .card-title,
    .card-gradient {
        display: block;
    }
}

@media (min-width: 2048px) {
    .image-card {
        width: 208px;
    }
}

.card-title {
    position: relative;
    z-index: 2;
    display: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 20px;
    font-weight: 500;
    text-transform: capitalize;
    color: var(--text-color);
    width: 100%;
    text-align: left;
    line-height: 1.4;
}

.card-gradient {
    pointer-events: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    height: 66.666%;
    background: linear-gradient(to top, var(--bg-color) 10%, transparent 100%);
}

/* 顶部导航栏基础样式 */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background-color: var(--background);
    z-index: 50;
    border-bottom: 1px solid var(--border);
}

.top-header-left,
.top-header-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.top-header-right {
    justify-content: flex-end;
}

.top-header-center {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 注意：sidebar-trigger-mobile 的样式已移至 style-mobile.css */

/* Top Model Selector 基础样式 */
#topModelSelectorContainerDesktop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 14px 16px;
}

#topModelSelectorContainerMobile {
    display: none;
}

#topModelSelectorContainer {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

body.assets-view .top-model-selector { display: none; }
.top-model-selector {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    z-index: 50;
}

.top-model-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 1rem;
    font-size: 1.125rem;
    font-weight: 400;
    white-space: nowrap;
    border: none;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.dark .top-model-trigger {
    background: rgba(0, 0, 0, 0.4);
}

.top-model-trigger:hover {
    background: rgba(255, 255, 255, 0.5);
}

.dark .top-model-trigger:hover {
    background: rgba(0, 0, 0, 0.5);
}

.top-model-trigger:active {
    transform: scale(0.98);
}

/* 历史记录列表上下留白 — 避开悬浮顶栏和底栏 */
[data-gh-wrapper] ul,
.generation-state-scroll ul {
    padding-top: 36px;
    padding-bottom: calc(var(--prompt-box-height, 250px) + 40px);
}

/* ── 生成结果响应式图片网格 ── */
/* 手机端：flex 横向滚动 + snap */
.gh-img-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 1rem;
    scroll-padding-right: 1rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

.gh-img-grid > * {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* PromptBox — 悬浮在滚动区域上方，不随滚动移动 */
#promptBoxContainer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1020;
    padding: 16px;
    display: flex;
    justify-content: center;
    pointer-events: auto;
    transition: padding-right 300ms ease;
}

/* 桌面端：提示词组件在 Lightbox(1030) 之上，全屏预览时仍可见 */
@media (min-width: 769px) {
    #promptBoxContainer { z-index: 1035; }
}

#promptBoxContainer > * {
    width: 100%;
    max-width: 896px;
}

/* 取消输入框聚焦时的白色外框 */
#promptBoxContainer textarea:focus,
#promptBoxContainer input:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* 搜索弹窗 */
#session-search-dialog {
    background-color: oklch(20% 0 0 / 0.75) !important;
}

#session-search-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

#session-search-dialog input:focus {
    outline: none;
}

.active-scale-99:active {
    transform: scale(0.99);
}

/* 临时禁用过渡动画辅助类 */
.no-transition, .no-transition * {
    transition: none !important;
    animation: none !important;
}
