.simulation-container {
    max-width: 100%;
    margin: 1rem 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.simulation-header {
    background: #f5f5f5;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.simulation-header h4 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.simulation-header p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

.simulation-controls {
    display: flex;
    gap: 2rem;
    align-items: center;
    padding: 1rem;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.playback-controls {
    display: flex;
    gap: 0.5rem;
}

.control-button {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.control-button:hover {
    background: #1976D2;
}

.control-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.time-scrubber {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.time-scrubber label {
    font-weight: 500;
    white-space: nowrap;
}

.slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: none;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.speed-control .slider {
    width: 80px;
}

#current-time-display, #speed-display {
    font-weight: 500;
    color: #333;
    min-width: 50px;
}

.simulation-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    padding: 1rem;
}

.gantt-chart-container {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.gantt-chart-container h5 {
    margin: 0;
    padding: 0.75rem;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.gantt-chart {
    position: relative;
    background: white;
    min-height: 300px;
    overflow-x: auto;
}

.timeline-header {
    position: relative;
    height: 30px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
}

.time-marker {
    position: absolute;
    font-size: 0.75rem;
    color: #666;
    transform: translateX(-50%);
    padding: 0.25rem;
    white-space: nowrap;
}

.gantt-actor-row {
    display: flex;
    border-bottom: 1px solid #f0f0f0;
    min-height: 40px;
}

.actor-label {
    width: 150px;
    padding: 0.5rem;
    font-weight: 500;
    background: #f5f5f5;
    border-right: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.task-lane {
    flex: 1;
    position: relative;
    background: white;
}

.task-bar {
    position: absolute;
    height: 32px;
    top: 4px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.task-bar.task-pending {
    opacity: 0.5;
    border-color: #ccc;
}

.task-bar.task-active {
    border-color: #FFD700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.task-bar.task-completed {
    opacity: 0.8;
}

.task-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.time-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #FF0000;
    z-index: 100;
    box-shadow: 0 0 4px rgba(255, 0, 0, 0.5);
    pointer-events: none;
}

.resource-panel {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.resource-panel h5 {
    margin: 0;
    padding: 0.75rem;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.resource-counters {
    padding: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.resource-item {
    margin-bottom: 1rem;
    padding: 0.5rem;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    background: white;
}

.resource-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.resource-name {
    font-weight: 500;
    color: #333;
}

.resource-unit {
    font-size: 0.8rem;
    color: #666;
}

.resource-bar-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.resource-bar {
    flex: 1;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.resource-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.resource-fill.resource-high {
    background: #4CAF50;
}

.resource-fill.resource-medium {
    background: #FF9800;
}

.resource-fill.resource-low {
    background: #F44336;
}

.resource-amount {
    font-size: 0.8rem;
    white-space: nowrap;
    color: #666;
}

.resource-status {
    font-size: 0.75rem;
    font-weight: 500;
}

.resource-status.ok {
    color: #4CAF50;
}

.resource-status.low {
    color: #FF9800;
}

.resource-status.shortage {
    color: #F44336;
}

.efficiency-panel {
    grid-column: 1 / -1;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-top: 1rem;
    overflow: hidden;
}

.efficiency-panel h5 {
    margin: 0;
    padding: 0.75rem;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.efficiency-metrics {
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.metric-item {
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    padding: 0.75rem;
    background: white;
}

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

.actor-utilization-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.actor-name {
    width: 120px;
    font-size: 0.8rem;
    color: #666;
}

.utilization-bar {
    flex: 1;
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}

.utilization-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

.utilization-fill.utilization-low {
    background: #F44336;
}

.utilization-fill.utilization-medium {
    background: #FF9800;
}

.utilization-fill.utilization-high {
    background: #4CAF50;
}

.utilization-percentage {
    font-size: 0.8rem;
    color: #666;
    min-width: 40px;
    text-align: right;
}

.efficiency-indicators {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.efficiency-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.indicator-label {
    flex: 1;
    font-size: 0.9rem;
    color: #666;
}

.indicator-value {
    font-weight: 500;
    color: #333;
}

.indicator-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid currentColor;
}

.indicator-dot.low {
    background: #4CAF50;
    color: #4CAF50;
}

.indicator-dot.medium {
    background: #FF9800;
    color: #FF9800;
}

.indicator-dot.high {
    background: #F44336;
    color: #F44336;
}

/* Actor-based timeline styling */
.timeline-container {
    width: 100%;
    margin: 20px 0;
    position: relative;
}

.timeline-header {
    position: relative;
    height: 30px;
    margin-bottom: 10px;
}

.timeline-time-axis {
    position: relative;
    height: 20px;
    background: linear-gradient(to right, #f0f0f0 0%, #f0f0f0 100%);
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
}

.timeline-time-markers {
    position: absolute;
    top: 0;
    left: 130px; /* Offset by actor label width */
    right: 0;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px;
    font-size: 10px;
    color: #666;
}

.timeline-actors {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.actor-timeline-row {
    display: flex;
    align-items: center;
    min-height: 40px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
    padding: 5px;
}

.actor-label {
    min-width: 120px;
    max-width: 120px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    text-align: center;
    margin-right: 10px;
    border: 1px solid #ddd;
}

.actor-tasks-container {
    flex: 1;
    position: relative;
    height: 30px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.task-block {
    position: absolute;
    height: 28px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.task-block:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    filter: brightness(1.1);
}

.task-block.active {
    border-color: #D84315 !important;
    color: white !important;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 10px rgba(255, 87, 34, 0.5);
    z-index: 10;
}

.task-block.completed {
    background: #757575 !important;
    border-color: #616161 !important;
    color: #e0e0e0 !important;
    animation: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

@keyframes pulse {
    0% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.02);
    }
    100% { 
        opacity: 1; 
        transform: scale(1);
    }
}

/* Actor color coding with improved specificity */
.actor-timeline-row .task-block:not(.active):not(.completed) {
    border-color: var(--primary-color);
}

/* Ensure completed and active states override actor colors */
.actor-timeline-row .task-block.completed {
    background: #cecece !important;
    border-color: #8d8d8d !important;
    color: #e0e0e0 !important;
}

.actor-timeline-row .task-block.active {
    border-color: #D84315 !important;
    color: white !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .simulation-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .simulation-content {
        grid-template-columns: 1fr;
    }
    
    .efficiency-metrics {
        grid-template-columns: 1fr;
    }
    
    .actor-label {
        width: 100px;
        font-size: 0.8rem;
    }
    
    .actor-name {
        width: 80px;
    }
    
    .actor-label {
        min-width: 80px;
        max-width: 80px;
        font-size: 10px;
        padding: 2px 4px;
    }
    
    .task-block {
        font-size: 9px;
        height: 24px;
    }
    
    .actor-tasks-container {
        height: 26px;
    }
}

/* Expanded Tree Timeline Styles */
.expanded-timeline-section {
    margin-top: 2rem;
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
}

.expanded-timeline-section h5 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

.expanded-tree-content {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: white;
    padding: 0.25rem;
}

.tree-node {
    margin: 0.25rem 0;
    transition: background-color 0.2s ease;
}

.tree-node:hover {
    background-color: #f8f9fa;
    border-radius: 3px;
}

.tree-step {
    margin: 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #333;
    border-left: 4px solid transparent;
    border-radius: 2px;
}

/* Collapsible tree step header layout */
.tree-step-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.tree-collapse-btn {
    background: none;
    border: none;
    padding: 0.2rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #666;
    border-radius: 2px;
    transition: background-color 0.15s ease;
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.tree-collapse-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.tree-collapse-btn:focus {
    outline: 2px solid #2196F3;
    outline-offset: 1px;
}

.collapse-icon {
    display: inline-block;
    transition: transform 0.2s ease;
}

.tree-collapse-btn[aria-expanded="false"] .collapse-icon {
    transform: rotate(-90deg);
}

.tree-step.collapsible {
    flex: 1;
    margin: 0;
}

.tree-children {
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    max-height: none;
}

.tree-children.collapsed {
    max-height: 0 !important;
}

/* Ensure proper spacing for tree children */
.tree-children > .tree-node {
    margin-top: 0.2rem;
}

.tree-children > .tree-node:first-child {
    margin-top: 0.4rem;
}

.tree-children > .tree-node:last-child {
    margin-bottom: 0.4rem;
}

/* Indentation classes for different levels with progressive color bars */
.tree-node.indent-0 .tree-step {
    font-weight: 600;
    font-size: 1rem;
    border-left-color: #2196F3;
    background-color: #f0f7ff;
    border-left-width: 6px;
}

.tree-node.indent-1 .tree-step {
    font-weight: 500;
    border-left-color: #4CAF50;
    border-left-width: 5px;
    background-color: #f8fff8;
}

.tree-node.indent-2 .tree-step {
    border-left-color: #FF9800;
    border-left-width: 4px;
    font-size: 0.85rem;
    background-color: #fff8f0;
}

.tree-node.indent-3 .tree-step {
    border-left-color: #9C27B0;
    border-left-width: 4px;
    font-size: 0.8rem;
    color: #555;
    background-color: #faf5ff;
}

.tree-node.indent-4 .tree-step {
    border-left-color: #607D8B;
    border-left-width: 3px;
    font-size: 0.75rem;
    color: #666;
    background-color: #f5f7f8;
}

.tree-node.indent-5 .tree-step,
.tree-node.indent-6 .tree-step,
.tree-node.indent-7 .tree-step,
.tree-node.indent-8 .tree-step,
.tree-node.indent-9 .tree-step {
    border-left-color: #795548;
    border-left-width: 3px;
    font-size: 0.7rem;
    color: #777;
    background-color: #f7f6f5;
}

/* Remove distracting hover animations - only subtle feedback */
.tree-node:hover .tree-step:not(.collapsible) {
    background-color: #f8f9fa;
}

/* Responsive design for expanded tree */
@media (max-width: 768px) {
    .expanded-tree-content {
        max-height: 300px;
    }
    
    .tree-step {
        font-size: 0.8rem;
    }
    
    .tree-node.indent-0 .tree-step {
        font-size: 0.9rem;
    }
    
    .tree-node.indent-2 .tree-step,
    .tree-node.indent-3 .tree-step,
    .tree-node.indent-4 .tree-step {
        font-size: 0.75rem;
    }
    
    .tree-node.indent-5 .tree-step,
    .tree-node.indent-6 .tree-step,
    .tree-node.indent-7 .tree-step,
    .tree-node.indent-8 .tree-step,
    .tree-node.indent-9 .tree-step {
        font-size: 0.65rem;
    }
}

/* Robot Mode Toggle Styles */
.expanded-timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.expanded-timeline-header h5 {
    margin: 0;
}

.robot-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #2196F3;
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px #2196F3;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    user-select: none;
}

/* Tree Dataset Visibility */
.tree-dataset {
    display: none;
}

.tree-dataset.active {
    display: block;
}

/* Enhanced tree styling for better visibility */
.expanded-tree-content {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 1rem;
    background: #fafafa;
    max-height: 600px;
    overflow-y: auto;
}

.tree-node {
    margin-bottom: 0.5rem;
}

.tree-step {
    background: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border-left: 4px solid #2196F3;
    margin: 0.25rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tree-step-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.tree-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 2px;
    color: #666;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.tree-collapse-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.collapse-icon {
    transition: transform 0.2s ease;
}

.tree-collapse-btn[aria-expanded="false"] .collapse-icon {
    transform: rotate(-90deg);
}

.tree-children {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.tree-children.collapsed {
    max-height: 0;
}
