/* 药物递送模块样式 */

/* 统一配色变量（与主页面/ADMET/生成页对齐） */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --background-color: #f8f9fa;
    --primary-blue: #005bac;
    --secondary-blue: #0077cc;
    --light-blue: #e6f2ff;
    --dark-blue: #003d7a;
    --accent-green: #00a896;
    --accent-orange: #ff6b35;
    --accent-purple: #6a4c93;
    --accent-teal: #118ab2;
    --accent-cyan: #06d6a0;
    --accent-red: #e63946;
    --text-dark: #333;
    --text-light: #333;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    --transition: all 0.4s ease;
    --border-radius: 16px;
}

/* 页面标题样式 */
.page-title {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
}

.page-title h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--primary-blue);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-title p {
    font-size: 1.1rem;
    color: #666;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
}

/* 面板布局 */
.panel-layout {
    display: grid;
    grid-template-columns: minmax(350px, 480px) 1fr;
    gap: clamp(15px, 3vw, 30px);
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - 300px); /* 确保面板有足够高度 */
    align-items: start; /* 确保面板顶部对齐 */
}

/* 确保页面不会过长 */
.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 40px 50px;
}

/* 配置面板 */
.config-panel {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.05);
    height: fit-content;
    min-height: 650px; /* 增加最小高度，确保与右侧结果框完全对齐 */
    display: flex;
    flex-direction: column;
}

/* 表单样式调整 */
.config-panel form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 配置面板填充区域 */
.config-panel-filler {
    flex: 1;
    min-height: 0;
    /* 计算填充区域的最小高度，确保在全部折叠时与右侧面板对齐 */
    min-height: calc(650px - 2rem - 4rem - 60px - 60px - 60px - 60px - 2rem);
    /* 650px(面板最小高度) - 2rem(上内边距) - 4rem(头部高度) - 4个折叠面板高度 - 2rem(下内边距) */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--light-blue);
}

.panel-header h2 {
    color: var(--primary-blue);
    margin: 0;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-indicator {
    background: var(--light-blue);
    color: var(--primary-blue);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* 表单组样式 */
.form-group {
    margin-bottom: 1.5rem;
    flex-shrink: 0; /* 防止表单组被压缩 */
}

/* 表单组头部样式（用于没有label的表单组） */
.form-group-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
    align-items: center;
}

.form-group-header .tooltip {
    margin-left: 0; /* 重置tooltip的左边距 */
}

/* 当表单组没有label时，调整select和input的样式 */
.form-group:has(.form-group-header) select,
.form-group:has(.form-group-header) input {
    margin-top: 0; /* 移除顶部边距 */
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.95rem;
}

.form-group label i {
    color: var(--primary-blue);
    width: 16px;
}

/* 工具提示样式 */
.tooltip {
    position: relative;
    display: inline-block;
    margin-left: auto;
}

.tooltip i {
    color: #999;
    cursor: help;
}

.tooltiptext {
    visibility: hidden;
    width: 250px;
    background-color: #333;
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -125px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    line-height: 1.4;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* 输入框样式 */
.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--secondary-blue);
    box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.15);
}

/* 单选按钮组样式 */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-option {
    position: relative;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-option label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.radio-option input[type="radio"]:checked + label {
    border-color: var(--secondary-blue);
    background: var(--light-blue);
    box-shadow: 0 2px 8px rgba(0, 119, 204, 0.15);
}

.radio-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.radio-desc {
    color: #666;
    font-size: 0.85rem;
}

/* 按钮组样式 */
.btn-group {
    display: flex;
    gap: 0.8rem; /* 稍微减少按钮之间的间距 */
    margin-top: 2rem;
    margin-bottom: 0; /* 确保按钮组紧贴表单底部 */
    flex-shrink: 0; /* 防止按钮组被压缩 */
    flex-wrap: nowrap; /* 防止按钮换行 */
}

.action-btn {
    flex: 1 1 auto; /* 允许按钮根据内容调整宽度 */
    padding: 1rem 1.2rem; /* 稍微减少左右内边距 */
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap; /* 防止文字换行 */
    min-width: 110px; /* 稍微减少最小宽度 */
    overflow: hidden; /* 隐藏溢出内容 */
    text-overflow: ellipsis; /* 如果文字过长，显示省略号 */
}

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

.btn-primary:hover {
    background: var(--secondary-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 91, 172, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: var(--text-dark);
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* 可视化面板 */
.visualization-panel {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.05);
    min-height: 650px; /* 与左侧配置面板保持一致的最小高度 */
    display: flex;
    flex-direction: column;
    height: 100%; /* 确保面板占满可用高度 */
}

/* 结果容器样式 */
.results-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.visualization-panel .panel-header {
    margin-bottom: 1.5rem;
}

.refresh-btn {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    background: #008f7a;
    transform: translateY(-1px);
}

/* 占位符样式 */
.placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #999;
    min-height: 500px; /* 增加最小高度，确保与左侧面板在全部折叠时对齐 */
}

.placeholder i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: var(--light-blue);
}

.placeholder h3 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.placeholder p {
    color: #666;
    line-height: 1.5;
}

/* 进度内容样式 */
.progress-content,
.results-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.progress-content h3,
.results-content h3 {
    color: var(--primary-blue);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 阶段指示器样式 */
.stage-indicators {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    position: relative;
}

.stage-indicators::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 25px;
    right: 25px;
    height: 2px;
    background: #e0e0e0;
    z-index: 1;
}

.stage-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
}

.stage-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 3px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.stage-icon i {
    font-size: 1rem;
    color: #999;
    transition: all 0.3s ease;
}

.stage-label {
    font-size: 0.8rem;
    color: #666;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.stage-indicator.active .stage-icon {
    border-color: var(--primary-blue);
    background: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(0, 91, 172, 0.1);
}

.stage-indicator.active .stage-icon i {
    color: white;
}

.stage-indicator.completed .stage-icon {
    border-color: var(--accent-green);
    background: var(--accent-green);
}

.stage-indicator.completed .stage-icon i {
    color: white;
}

.stage-indicator.completed .stage-label {
    color: var(--accent-green);
    font-weight: 600;
}

/* 进度条样式 */
.progress-container {
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #f0f0f0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 5px;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

#progressPercent {
    font-weight: 600;
    color: var(--primary-blue);
}

#progressStage {
    color: #666;
}

.elapsed-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
}

.elapsed-time i {
    color: var(--primary-blue);
}

/* 阶段描述样式 */
.stage-description {
    background: var(--light-blue);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-blue);
}

.stage-desc-text {
    color: #555;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

/* 进度日志样式 */
.progress-logs {
    max-height: 150px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
}

.log-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.85rem;
}

.log-item:last-child {
    border-bottom: none;
}

.log-item i {
    color: var(--primary-blue);
    font-size: 0.8rem;
}

.log-item span {
    color: #555;
}

/* 结果内容样式 */
.results-content {
    flex: 1;
}

#resultsContent {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    min-height: 200px;
}

/* 结果网格布局 */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* 结果卡片样式 */
.result-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.result-card h4 {
    color: var(--primary-blue);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-blue);
}

.result-card h4 i {
    color: var(--secondary-blue);
}

/* 剂量序列样式 */
.dose-sequence {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dose-item {
    background: var(--light-blue);
    color: var(--primary-blue);
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(0, 91, 172, 0.2);
}

/* 指标网格样式 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.metric-item {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.metric-label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.metric-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
}

.metric-value.success {
    color: var(--accent-green);
}

.metric-value.info {
    color: var(--secondary-blue);
}

.metric-value.warning {
    color: var(--accent-orange);
}

/* 训练参数样式 */
.training-params {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.param-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.param-value {
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 600;
}

/* 操作按钮样式 */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-buttons .btn-secondary {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.action-buttons .btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 制备步骤样式 */
.manufacturing-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-item {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--primary-blue);
    font-size: 0.9rem;
    line-height: 1.4;
    color: #555;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.step-item:hover {
    background: #f8f9fa;
    border-left-color: var(--secondary-blue);
    transform: translateX(2px);
    transition: all 0.2s ease;
}

/* 折叠面板样式 */
.collapsible-section {
    border: none;
    padding: 0;
    margin: 0;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    min-height: 60px; /* 确保折叠状态下有足够的高度 */
}

.collapsible-section[open] {
    margin-bottom: 20px;
}

.collapsible-section:not([open]) {
    margin-bottom: 10px;
}

/* 折叠状态下的内容区域 */
.collapsible-section:not([open]) .collapsible-content {
    display: none;
}

/* 确保折叠面板在折叠状态下有足够的视觉重量 */
.collapsible-section:not([open]) .collapsible-header {
    background: rgba(230, 242, 255, 0.3); /* 轻微的背景色 */
    border-radius: 8px;
    padding: 15px 10px;
    margin: 0 -10px;
}

/* 折叠面板头部样式 */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--dark-blue);
    font-weight: bold;
    cursor: pointer;
    padding: 15px 0;
    gap: 10px;
    border-bottom: 2px solid var(--light-blue);
    transition: all 0.3s ease;
    min-height: 50px; /* 确保折叠状态下头部有足够高度 */
}

.collapsible-header:hover {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

.collapsible-header .collapse-icon {
    transition: transform 0.3s ease;
    font-weight: bold;
    color: var(--primary-blue);
    margin-left: auto;
}

.collapsible-section[open] .collapse-icon {
    transform: rotate(90deg);
}

.collapsible-content {
    margin-top: 15px;
    padding: 15px 0;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .panel-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        align-items: stretch; /* 在小屏幕上拉伸面板 */
    }
    
    .config-panel,
    .visualization-panel {
        min-height: auto; /* 在小屏幕上取消最小高度限制 */
    }
}

@media (max-width: 768px) {
    .page-title h1 {
        font-size: 2rem;
    }
    
    .panel-layout {
        gap: 1rem;
    }
    
    .config-panel,
    .visualization-panel {
        padding: 1.5rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .tooltiptext {
        width: 200px;
        margin-left: -100px;
    }
}

/* 新增：剂量图表相关样式 */
.dose-chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e0e0e0;
    min-height: 250px; /* 确保容器有足够高度 */
}

/* 确保canvas元素正确显示 */
.dose-chart-container canvas {
    display: block !important;
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

/* 如果canvas不可见，添加调试样式 */
.dose-chart-container canvas:not([width]) {
    border: 2px solid red !important;
    background: #ffe6e6 !important;
}

.dose-summary {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.dose-summary-item {
    background: var(--light-blue);
    color: var(--primary-blue);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(0, 91, 172, 0.2);
    text-align: center;
    min-width: 120px;
}

/* 新增：紧凑的参数展示样式 */
.formulation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.training-params-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.param-item-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.param-item-compact:hover {
    background: #e9ecef;
    border-color: var(--secondary-blue);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 119, 204, 0.1);
}

.param-label-compact {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
    flex: 1;
}

.param-value-compact {
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 600;
    text-align: right;
    margin-left: 0.5rem;
}

/* 优化结果卡片布局 */
.result-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.result-card h4 {
    color: var(--primary-blue);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-blue);
}

.result-card h4 i {
    color: var(--secondary-blue);
}

/* 优化指标网格布局 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.metric-item {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.metric-item:hover {
    background: #e9ecef;
    border-color: var(--secondary-blue);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 119, 204, 0.1);
}

.metric-label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.metric-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
}

.metric-value.success {
    color: var(--accent-green);
}

.metric-value.info {
    color: var(--secondary-blue);
}

.metric-value.warning {
    color: var(--accent-orange);
}
