/**
 * 基础样式文件
 * 路径: css/base.css
 * 版本: Delta7 - 优化版
 * 包含: CSS变量、全局重置、字体、基础布局
 */

/* ======================
   CSS 变量定义（全局主题配置）
   ====================== */
:root {
    /* 主题色 */
    --primary-gradient-start: #667eea;
    --primary-gradient-end: #764ba2;
    --primary-color: #667eea;
    
    /* 功能色 */
    --success-color: #10b981;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #3b82f6;
    
    /* 中性色 */
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-600: #495057;
    --gray-700: #343a40;
    --gray-800: #212529;
    
    /* 尺寸 */
    --row-height: 40px;
    --header-height: 50px;
    --default-cell-width: 50px;
    --sidebar-width: 180px;
    --sidebar-min-width: 100px;
    --sidebar-max-width: 400px;
    --toolbar-collapsed-size: 48px;
    --toolbar-border-radius: 20px;
    --card-border-radius: 12px;
    --button-border-radius: 12px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(102, 126, 234, 0.4);
    --shadow-xl: 0 10px 30px rgba(0, 0, 0, 0.2);
    
    /* 过渡 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-index 层级 */
    --z-toolbar-collapsed: 1000;
    --z-toolbar-expanded: 998;
    --z-settings-panel: 1001;
    --z-quick-menu: 1002;
    --z-inline-form: 1000;
    --z-gantt-bar-selected: 10;
    --z-gantt-label: 5;
    --z-resize-handle: 999;
}

/* ======================
   全局样式优化
   ====================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif,
                 "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background: var(--gray-50);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 图标字体样式 */
.icon {
    font-style: normal;
    font-size: inherit;
}

/* 容器自适应布局 */
.container-fluid {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 15px;
    max-width: 100%;
    margin: 0 auto;
}

/* 标题渐变 */
h1 {
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 滚动条样式优化 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #212529;
        --gray-100: #343a40;
        --gray-200: #495057;
        --gray-300: #6c757d;
        --gray-400: #adb5bd;
        --gray-500: #dee2e6;
        --gray-600: #e9ecef;
        --gray-700: #f8f9fa;
        --gray-800: #ffffff;
    }

    body {
        background: var(--gray-50);
        color: var(--gray-800);
    }
}

/* 可访问性增强 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    .gantt-bar {
        border-width: 3px;
    }

    .toolbar-btn {
        border: 1px solid currentColor;
    }
}
/* css/base.css */

/* ======================
   顶部导航栏 (Header)
   ====================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 2000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

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

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

.header-center {
    flex: 2;
    display: flex;
    justify-content: center;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--gray-300);
    margin: 0 4px;
}

/* ======================
   项目名称悬停下拉菜单
   ====================== */
.project-menu-wrapper {
    position: relative;
    display: inline-block;
    height: 60px; /* 占满 header 高度方便悬停 */
    display: flex;
    align-items: center;
}

.project-title-box {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.project-title-box:hover {
    background: rgba(0,0,0,0.05);
}

.project-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
}

.dropdown-arrow {
    font-size: 0.7rem;
    color: #999;
    margin-left: 8px;
    transition: transform 0.2s;
}

.project-menu-wrapper:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* 下拉菜单本体 */
.project-dropdown-menu {
    position: absolute;
    top: 55px; /* header高度 - 这里的偏移 */
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: white;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 2001;
}

/* 悬停显示逻辑 */
.project-menu-wrapper:hover .project-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    color: #444;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: #f5f7ff;
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

/* ======================
   布局修正：工具栏并入 Header
   ====================== */

/* 1. 主容器布局 */
/* 只需要留出 Header 的高度 (60px) + 少量呼吸空间 (10px) */
.main-layout {
    padding-top: 70px !important; 
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 2. 甘特图容器 */
/* 移除之前的 margin-top，因为工具栏不再占用下方空间 */
.gantt-container {
    margin-top: 0 !important; 
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* 可选：加一个顶部边框分割线 */
    border-top: 1px solid #eee; 
}

#pertContainer {
    margin-top: 0 !important;
    flex: 1;
    overflow: hidden;
}

/* ======================
   3. 工具栏定位 (核心修改)
   将其定位坐标上移，使其视觉上位于 Header 内部
   ====================== */

/* 收起状态 (呼吸灯图标) */
.toolbar-collapsed {
    position: fixed !important;
    /* Header高度60px，图标约40-48px，垂直居中 */
    top: 8px !important;  
    left: 15px !important;
    z-index: 2100; /* 必须高于 Header (2000) */
    
    /* 稍微缩小一点尺寸以适应 Header */
    width: 44px !important;
    height: 44px !important;
    font-size: 1.2rem !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3) !important;
}

/* 展开状态 (长条菜单) */
.floating-toolbar-expanded {
    position: fixed !important;
    /* 与收起图标对齐 */
    top: 8px !important;
    left: 15px !important;
    transform: none !important; /* 左对齐 */
    z-index: 2100; /* 必须高于 Header */
    
    /* 样式微调，使其看起来像 Header 的一部分 */
    height: 44px !important; /* 限制高度 */
    padding: 0 12px 0 54px !important; /* 左侧留出圆钮位置 */
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid #e0e0e0 !important;
}

/* 展开时，确保它盖住后面的项目标题 (防止文字重叠干扰) */
.floating-toolbar-expanded.active {
    /* 确保背景不透明 */
    background: #fff !important; 
}

/* 4. 微调 Header 左侧区域，确保不遮挡其他可能存在的元素 */
.header-left {
    /* 给工具栏留出至少 60px 的宽度，虽然现在左侧是空的 */
    min-width: 60px; 
}