/* src/css/main.css - 全局样式与基础布局 */

/*
 * 默认主题变量 (Darcula)
 * 这些变量将被主题文件覆盖。
 */
:root {
    /* 颜色变量 */
    --bg-primary: #21252b;
    --bg-panel: #2b2b2b;
    --bg-header: #3c3c3c;
    --text-primary: #a9b7c6;
    --text-secondary: #808080;
    --border-color: #454545;
    --accent-color: #62a3ff;
    --accent-color-hover: #4d8ce7;
    --selection-color: #264e6e;
    --shadow-color: rgba(0, 0, 0, 0.3);

    /* 错误/警告颜色 */
    --color-error: #ff6b6b;
    --color-warning: #ffc107;
    --color-info: #6a9955;
    --color-untracked: #808080;
    --color-modified: #e0b400;
    --color-added: #6a9955;
    --color-deleted: #cd3131;

    /* 字体定义 */
    --font-family-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-family-mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', 'Monaco', monospace;

    /* 尺寸变量 */
    --panel-header-height: 35px;
    --toolbar-height: 40px;
    --status-bar-height: 25px;
}

/* 通用重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* HTML, Body 基础样式 */
html, body {
    height: 100%;
    width: 100%;
    font-family: var(--font-family-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* App 容器 - 使用 CSS Grid 实现整体布局 */
.app-container {
    display: grid;
    grid-template-rows: var(--toolbar-height) 1fr var(--status-bar-height);
    grid-template-columns: 1fr;
    height: 100%;
    width: 100%;
}

/* 主内容区 - 使用 CSS Flex 实现垂直布局 (上下结构) */
#main-panels {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 新增: 顶部面板包裹器，用于内部的水平布局 */
#top-panels-wrapper {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    overflow: hidden;
    min-height: 0;
}

/* 面板通用样式 */
.panel {
    background-color: var(--bg-panel);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    flex-shrink: 0;
    flex-basis: 0;
}

.panel-header {
    height: var(--panel-header-height);
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 10px;
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--text-secondary);
}

/* 面板内容区域 */
.panel-content-area {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

.panel-content {
    /* position: absolute;  <-- 已移除 */
    /* top: 0;              <-- 已移除 */
    /* left: 0;             <-- 已移除 */
    /* width: 100%;         <-- 已移除 */
    height: 100%;
    overflow: auto;
    display: none;
    padding: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.panel-content.active {
    display: block;
}

/* 底部面板的水平布局容器样式 */
.bottom-panel-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* 确保wrapper内的panel能正确参与flex布局 */
.bottom-panel-wrapper > .panel {
    flex-grow: 1;
    flex-shrink: 0;
    flex-basis: 0;
    display: flex;
    flex-direction: column;
}


/* Monaco Editor 的挂载点 */
#editor-area {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

/* 可拖拽分隔条样式 */
.custom-gutter {
    background-color: var(--bg-header);
    flex-shrink: 0;
    z-index: 10;
    transition: background-color 0.1s ease-in-out;
}

.custom-gutter.horizontal {
    width: 5px;
    cursor: ew-resize;
}

.custom-gutter.vertical {
    height: 5px;
    cursor: ns-resize;
}

.custom-gutter:hover,
.custom-gutter.is-dragging {
    background-color: var(--accent-color);
}

/* 拖拽时禁用页面选择 */
body.is-resizing {
    user-select: none !important;
}

body.is-resizing * {
    pointer-events: none !important;
}

/* 自定义滚动条 (Webkit) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #606060;
}

/* 会话锁定屏幕样式 */
.lock-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    text-align: center;
    font-family: var(--font-family-main);
}

.lock-screen-overlay.visible {
    display: flex;
}

.lock-screen-content {
    max-width: 500px;
    padding: 40px;
}

.lock-screen-icon {
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}

.lock-screen-content h1 {
    font-size: 2rem;
    margin-bottom: 15px;
}

.lock-screen-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.lock-screen-timer {
    margin-top: 20px;
    font-size: 0.9rem;
}

.spinner {
    margin: 30px auto 0;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- 繁忙状态遮罩层 --- */
.busy-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.05);
    z-index: 10001;
    cursor: wait;
    display: none;
}

.busy-overlay.visible {
    display: block;
}


/* ========================= 核心修改 START ========================= */
/* --- 主题切换的视图过渡动画 --- */
@keyframes reveal-in {
    from {
        clip-path: circle(0 at var(--clip-x) var(--clip-y));
    }
    to {
        clip-path: circle(var(--clip-r) at var(--clip-x) var(--clip-y));
    }
}

/*
  默认情况下，View Transitions API 会对新旧视图进行淡入淡出。
  我们禁用这个默认动画，以便应用我们自己的 clip-path 动画。
*/
::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

/*
  在主题切换时，我们只关心新视图的进入动画。
  我们让新视图（`::view-transition-new`）在旧视图（`::view-transition-old`）之上
  执行“圆形揭示”动画。
*/
::view-transition-new(root) {
    /* 将新视图置于顶层 */
    z-index: 1;
    /* 应用我们的自定义动画 */
    animation: reveal-in 0.5s ease-in-out;
}

::view-transition-old(root) {
    /* 将旧视图置于底层，它会立即被新视图覆盖 */
    z-index: 0;
}
/* ========================= 核心修改 END =========================== */