/* ==========================================
   研究生项目管理 - 甘特图样式系统
   ========================================== */

/* CSS 变量 - 设计系统 */
:root {
    /* 主题色 */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;

    /* 背景色 */
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: rgba(26, 26, 46, 0.8);
    --bg-hover: rgba(99, 102, 241, 0.1);

    /* 文字色 */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* 边框 */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-hover: rgba(99, 102, 241, 0.3);

    /* 状态色 */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* 动画 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* 布局 */
    --sidebar-width: 260px;
    --toolbar-height: 60px;
    --task-row-height: 48px;
    --gantt-cell-width: 40px;
}

/* 全局重置 */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* 背景渐变效果 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(20, 184, 166, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ==========================================
   布局结构
   ========================================== */

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.projects-section {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-icon {
    width: 24px;
    height: 24px;
    border: none;
    background: var(--bg-hover);
    color: var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.project-list {
    list-style: none;
}

.project-item {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-fast);
    margin-bottom: 4px;
    position: relative;
}

.project-item:hover {
    background: var(--bg-hover);
}

.project-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.15));
    border: 1px solid var(--border-hover);
}

.project-item .project-icon {
    font-size: 1.1rem;
}

.project-item .project-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item .project-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
}

.project-item .project-menu {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.project-item:hover .project-menu {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-sync,
.btn-settings {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.btn-sync {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-sync:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-sync.syncing .sync-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.btn-settings {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-settings:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 工具栏 */
.toolbar {
    height: var(--toolbar-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.current-project-name {
    font-size: 1.25rem;
    font-weight: 600;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.view-controls {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.btn-view {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-view:hover {
    color: var(--text-primary);
}

.btn-view.active {
    background: var(--primary);
    color: white;
}

.btn-primary {
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    padding: 10px 20px;
    border: none;
    background: var(--danger);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-danger:hover {
    background: #dc2626;
}

/* ==========================================
   甘特图区域
   ========================================== */

.gantt-container {
    flex: 1;
    overflow: auto;
    padding: 24px;
    position: relative;
}

/* 空状态 */
.gantt-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) translateY(0);
    }
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.gantt-empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.gantt-empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* 甘特图头部 */
.gantt-header {
    display: flex;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: 1px solid var(--border-color);
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.gantt-task-header {
    width: 250px;
    min-width: 250px;
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
}

.gantt-timeline-header {
    flex: 1;
    display: flex;
    overflow-x: auto;
}

.timeline-cell {
    min-width: var(--gantt-cell-width);
    padding: 8px 4px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
}

.timeline-cell.today {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    font-weight: 600;
}

.timeline-cell .day-name {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.timeline-cell .day-num {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
}

/* 甘特图主体 */
.gantt-body {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border: 1px solid var(--border-color);
    border-top: none;
    min-height: 300px;
}

.gantt-tasks {
    position: relative;
}

/* 任务行 */
.gantt-task-row {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.gantt-task-row:hover {
    background: var(--bg-hover);
}

.gantt-task-row:last-child {
    border-bottom: none;
}

.task-info {
    width: 250px;
    min-width: 250px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-right: 1px solid var(--border-color);
    cursor: pointer;
}

.task-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.task-checkbox:hover {
    border-color: var(--primary);
}

.task-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
}

.task-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 0.7rem;
}

.task-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-name.completed {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-timeline {
    flex: 1;
    position: relative;
    min-height: var(--task-row-height);
    overflow: hidden;
}

/* 甘特条 */
.gantt-bar {
    position: absolute;
    height: 28px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    overflow: hidden;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.gantt-bar:hover {
    transform: translateY(-50%) scale(1.02);
    box-shadow: var(--shadow-md);
    z-index: 5;
}

.gantt-bar-progress {
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 6px 0 0 6px;
    transition: width var(--transition-normal);
}

.gantt-bar-label {
    position: absolute;
    left: 10px;
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 时间网格线 */
.timeline-grid {
    display: flex;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
}

.grid-line {
    min-width: var(--gantt-cell-width);
    border-right: 1px solid var(--border-color);
}

.grid-line.today {
    background: rgba(99, 102, 241, 0.05);
}

/* 拖拽手柄 */
.gantt-bar-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: ew-resize;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.gantt-bar:hover .gantt-bar-handle {
    opacity: 1;
}

.gantt-bar-handle::before {
    content: '';
    width: 3px;
    height: 14px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 2px;
}

.gantt-bar-handle-left {
    left: 0;
    border-radius: 6px 0 0 6px;
}

.gantt-bar-handle-right {
    right: 0;
    border-radius: 0 6px 6px 0;
}

.gantt-bar-handle:hover::before {
    background: white;
}

/* 正在拖拽时的样式 */
.gantt-bar.dragging {
    opacity: 0.9;
    box-shadow: var(--shadow-lg), 0 0 0 2px var(--primary);
    z-index: 100 !important;
}

.gantt-bar.dragging .gantt-bar-handle {
    opacity: 1;
}

/* 拖拽时禁用选择 */
body.resizing {
    cursor: ew-resize !important;
    user-select: none;
}

body.resizing * {
    cursor: ew-resize !important;
}

/* 日期提示气泡 */
.gantt-bar-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.gantt-bar.dragging .gantt-bar-tooltip {
    opacity: 1;
}

/* ==========================================
   模态框
   ========================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-hint a {
    color: var(--primary);
    text-decoration: none;
}

.form-hint a:hover {
    text-decoration: underline;
}

/* 颜色选择器 */
.color-picker {
    display: flex;
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.active {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary);
}

/* 同步状态 */
.sync-status {
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    display: none;
}

.sync-status.success {
    display: block;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.sync-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ==========================================
   Toast 通知
   ========================================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
}

/* ==========================================
   响应式设计
   ========================================== */

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
        --gantt-cell-width: 32px;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 100;
        transition: left var(--transition-normal);
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        width: 100%;
    }

    .toolbar {
        padding: 0 16px;
    }

    .toolbar-left::before {
        content: '☰';
        margin-right: 12px;
        font-size: 1.2rem;
        cursor: pointer;
    }

    .gantt-container {
        padding: 16px;
    }

    .gantt-task-header,
    .task-info {
        width: 150px;
        min-width: 150px;
        padding: 12px;
    }

    .modal {
        width: 95%;
        margin: 20px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 选择文本禁用（甘特图区域） */
.gantt-container {
    user-select: none;
}

.task-name,
.modal-body {
    user-select: text;
}