/* 工程计算中心主页面样式 - 保留原页面UI版本 */
/* 作者: chengliang */
/* 版本: 4.0.0 */

:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 60px;
    --transition-speed: 0.3s;
}

/* 全局页面样式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* 侧边栏样式 */
.sidebar {
    background: #ffffff;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    border-right: 1px solid #e9ecef;
    transition: all var(--transition-speed) ease;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: var(--sidebar-width);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-content {
    display: none;
}

/* 主内容区 */
.content-area {
    background: #ffffff;
    min-height: 100vh;
    padding: 0;
    position: relative;
    transition: all var(--transition-speed) ease;
    margin-left: var(--sidebar-width);
}

.content-area.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

.content-area.ai-panel-open {
    margin-right: 400px;
}

/* 侧边栏头部 */
.sidebar-header {
    background: linear-gradient(135deg, var(--primary-color), #1a2530);
    color: white;
    padding: 1.5rem 1rem;
    margin: -1rem -1rem 1rem -1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar.collapsed .sidebar-header {
    flex-direction: column;
    padding: 1rem 0.5rem;
}

.sidebar.collapsed .sidebar-header h4,
.sidebar.collapsed .sidebar-header p {
    display: none;
}

/* 切换按钮 */
.toggle-sidebar {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-sidebar:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

/* 文件夹节点 */
.folder-node {
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    padding: 12px 15px;
    border-radius: 8px;
    margin: 4px 0;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    user-select: none;
}

.folder-node:hover {
    background-color: #e9ecef;
    border-left-color: var(--accent-color);
    transform: translateX(3px);
}

.folder-node.active {
    background-color: #e3f2fd;
    border-left-color: var(--accent-color);
    font-weight: 500;
}

/* 文件列表 */
.file-list {
    transition: all var(--transition-speed) ease;
    overflow: hidden;
}

.file-item {
    padding: 10px 15px 10px 35px;
    color: #495057;
    transition: all 0.2s;
    border-radius: 6px;
    margin: 2px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    user-select: none;
}

.file-item:hover {
    background-color: #f1f3f5;
    transform: translateX(3px);
}

.file-item.active {
    background-color: #e3f2fd;
    color: var(--accent-color);
    font-weight: 500;
}

.file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 搜索高亮 */
.search-highlight {
    background-color: var(--warning-color);
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* 预览框架 - 关键修改：确保iframe完整显示 */
.preview-frame {
    border: none;
    background: white;
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.fullscreen-iframe {
    width: 100%;
    height: 100vh;
    border: none;
    display: block;
    visibility: visible !important;
}

/* 确保iframe内的内容完全显示 */
.fullscreen-iframe body {
    margin: 0;
    padding: 20px;
    overflow: auto;
}

/* 加载状态 */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    color: #6c757d;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.loading-text {
    font-size: 1.1rem;
    margin-top: 1rem;
}

/* 错误状态 */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    text-align: center;
    padding: 2rem;
}

.error-icon {
    font-size: 3rem;
    color: var(--danger-color);
    margin-bottom: 1rem;
}

/* 无结果状态 */
.no-results {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

/* 徽章样式 */
.badge-count {
    background: var(--accent-color);
    min-width: 28px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* 搜索框 */
.search-box {
    border-radius: 20px;
    border: 1px solid #e9ecef;
    padding: 10px 15px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-box:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    color: #6c757d;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: #e9ecef;
}

/* 内容标题栏 */
.content-header {
    display: none;
}

/* AI助手样式 */
.ai-mini-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), #1a2530);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    transition: all 0.3s ease;
}

.ai-mini-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.ai-mini-icon.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        height: auto;
        max-height: 50vh;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1030;
        width: 100%;
    }
    
    .sidebar.collapsed {
        height: 60px;
    }
    
    .content-area {
        margin-top: 60px;
        margin-left: 0 !important;
    }
    
    .content-area.ai-panel-open {
        margin-right: 0;
    }
    
    .file-item {
        padding: 8px 12px 8px 25px;
    }
    
    .folder-node {
        padding: 10px 12px;
    }
    
    .ai-mini-icon {
        bottom: 10px;
        right: 10px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    :root {
        --sidebar-width: 100%;
    }
    
    .welcome-message {
        padding: 2rem 1rem;
    }
    
    .welcome-icon {
        font-size: 3rem;
    }
}

/* 打印样式 */
@media print {
    .sidebar {
        display: none;
    }
    
    .content-area {
        width: 100% !important;
        margin-left: 0 !important;
    }
    
    .ai-mini-icon {
        display: none;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .sidebar {
        background: #2d3748;
        border-right-color: #4a5568;
    }
    
    .folder-node:hover {
        background-color: #4a5568;
    }
    
    .file-item:hover {
        background-color: #4a5568;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* 滚动条样式 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 进度条动画 */
.progress-bar-striped {
    background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
}

.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}