/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    overflow: hidden;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header Styles */
#control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid #00ff88;
    z-index: 1000;
}

.controls-left h1 {
    font-size: 1.5em;
    margin-bottom: 5px;
    background: linear-gradient(45deg, #00ff88, #00d4ff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.simulation-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 8px 16px;
    background: linear-gradient(145deg, #2d4a73, #1e3c72);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: linear-gradient(145deg, #3d5a83, #2e4c82);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.location-tabs {
    display: flex;
    gap: 2px;
}

.tab-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
    border-radius: 6px 6px 0 0;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tab-btn.active {
    background: #00ff88;
    color: #1e3c72;
    font-weight: bold;
}

/* Main Content Area - Split Layout */
#main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Canvas Container (2/3 width) */
#canvas-container {
    flex: 0 0 66.67%;
    position: relative;
    background: linear-gradient(45deg, #0a0a0a, #1a1a1a);
    border-right: 2px solid #00ff88;
    overflow: auto;
    min-width: 1200px;
    min-height: 800px;
}

/* Information Panels Area (1/3 width) */
#info-panels {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px 20px 15px 15px;
    background: rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #00ff88 rgba(0, 0, 0, 0.3);
    max-width: 450px;
}

/* Webkit scrollbar styling for info panels - Always visible */
#info-panels::-webkit-scrollbar {
    width: 12px;
    background: rgba(0, 0, 0, 0.5);
}

#info-panels::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

#info-panels::-webkit-scrollbar-thumb {
    background: linear-gradient(145deg, #00ff88, #00d4ff);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#info-panels::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(145deg, #00d4ff, #00ff88);
    box-shadow: 0 2px 6px rgba(0, 255, 136, 0.4);
}

/* Simple right-edge scroll indicator */
#right-edge-scroll-indicator {
    position: fixed;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 40px;
    background: rgba(0, 255, 136, 0.8);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: #1e3c72;
    font-weight: bold;
    font-size: 16px;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: grab;
    display: block;
}

#background-canvas { z-index: 1; }
#entity-canvas { z-index: 2; }
#ui-canvas { z-index: 3; }
#effect-canvas { z-index: 4; pointer-events: none; }

/* Panel Styles for Stacked Layout */
.panel {
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #00ff88;
    border-radius: 8px;
    padding: 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.2);
    margin-bottom: 0;
    flex-shrink: 0;
}

#ai-status-panel {
    min-height: 140px;
}

#ai-current-task {
    color: #ffffff;
    font-style: italic;
    margin-bottom: 10px;
    animation: aiStatusPulse 2s ease-in-out infinite;
}

@keyframes aiStatusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* AI Status animation for dynamic updates */
.ai-status-updating {
    background: linear-gradient(90deg, rgba(0, 255, 136, 0.1), rgba(0, 212, 255, 0.1), rgba(0, 255, 136, 0.1));
    background-size: 200% 100%;
    animation: aiStatusGlow 1.5s ease-in-out infinite;
}

@keyframes aiStatusGlow {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#metrics-panel {
    min-height: 140px;
}

#ai-decisions-panel { 
    min-height: 180px;
    max-height: 220px;
    overflow-y: auto;
}

#planning-panel {
    min-height: 160px;
    max-height: 200px;
    overflow-y: auto;
}

#notifications-panel {
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    flex: 1;
    /* Make scrollbar always visible for better UX */
    scrollbar-width: thin;
    scrollbar-color: #00ff88 rgba(0, 0, 0, 0.3);
}

/* Enhanced scrollbar styling for notifications panel */
#notifications-panel::-webkit-scrollbar {
    width: 12px;
}

#notifications-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
}

#notifications-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #00ff88, #00d4ff);
    border-radius: 6px;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
}

#notifications-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #00d4ff, #00ff88);
}

.panel h3 {
    margin-bottom: 10px;
    color: #00ff88;
    font-size: 1.1em;
    border-bottom: 1px solid rgba(0, 255, 136, 0.3);
    padding-bottom: 5px;
}

.scroll-indicator {
    float: right;
    font-size: 0.8em;
    opacity: 0.7;
    animation: scrollIndicatorPulse 2s ease-in-out infinite;
}

@keyframes scrollIndicatorPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.9; }
}

/* Individual panel content styling */
#ai-decision-list {
    max-height: 150px;
    overflow-y: auto;
}

.decision-item {
    padding: 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.82em;
    background: rgba(0, 255, 136, 0.05);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.decision-item:hover {
    background: rgba(0, 255, 136, 0.1);
}

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

.decision-time {
    color: #00d4ff;
    font-size: 0.75em;
    float: right;
}

.decision-type {
    font-weight: bold;
    color: #00ff88;
    display: block;
    margin-bottom: 2px;
}

.decision-context {
    color: #ffffff;
    font-size: 0.9em;
    opacity: 0.8;
    line-height: 1.2;
}

/* Plan item styling */
.plan-item {
    padding: 8px;
    margin-bottom: 6px;
    background: rgba(0, 212, 255, 0.08);
    border-left: 3px solid #00d4ff;
    border-radius: 0 4px 4px 0;
    font-size: 0.82em;
    transition: all 0.3s ease;
}

.plan-item:hover {
    background: rgba(0, 212, 255, 0.15);
    border-left-width: 4px;
}

.plan-title {
    font-weight: bold;
    color: #00d4ff;
    margin-bottom: 3px;
}

.plan-status {
    color: #ffffff;
    font-size: 0.9em;
    margin-bottom: 2px;
}

.plan-progress {
    color: #ffaa00;
    font-size: 0.85em;
    font-style: italic;
}

/* Scrollbar styling for individual panels - Always visible and prominent */
.panel::-webkit-scrollbar,
#ai-decision-list::-webkit-scrollbar,
#active-plans::-webkit-scrollbar,
#notification-list::-webkit-scrollbar {
    width: 10px;
    background: rgba(0, 0, 0, 0.4);
}

.panel::-webkit-scrollbar-track,
#ai-decision-list::-webkit-scrollbar-track,
#active-plans::-webkit-scrollbar-track,
#notification-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.panel::-webkit-scrollbar-thumb,
#ai-decision-list::-webkit-scrollbar-thumb,
#active-plans::-webkit-scrollbar-thumb,
#notification-list::-webkit-scrollbar-thumb {
    background: linear-gradient(145deg, #00ff88, #00d4ff);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.panel::-webkit-scrollbar-thumb:hover,
#ai-decision-list::-webkit-scrollbar-thumb:hover,
#active-plans::-webkit-scrollbar-thumb:hover,
#notification-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(145deg, #00d4ff, #00ff88);
    box-shadow: 0 2px 5px rgba(0, 255, 136, 0.4);
}



.metric-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.metric-label { color: #cccccc; }
.metric-value {
    color: #00ff88;
    font-weight: bold;
}

.notification {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-left: 4px solid;
    border-radius: 6px;
    font-size: 0.9em;
    width: 100%;
    box-sizing: border-box;
}

.notification.info {
    background: rgba(0, 100, 255, 0.1);
    border-color: #0064ff;
    color: #87ceeb;
}

.notification.warning {
    background: rgba(255, 165, 0, 0.1);
    border-color: #ffa500;
    color: #ffd700;
}

.notification.error {
    background: rgba(255, 0, 0, 0.1);
    border-color: #ff0000;
    color: #ff6b6b;
}

.notification.success {
    background: rgba(0, 255, 136, 0.1);
    border-color: #00ff88;
    color: #00ff88;
}

.notification.emergency {
    background: rgba(139, 0, 0, 0.3);
    border-color: #8b0000;
    color: #ff4444;
    font-weight: bold;
    animation: emergencyPulse 1s infinite alternate;
}

@keyframes emergencyPulse {
    from { box-shadow: 0 0 5px rgba(139, 0, 0, 0.5); }
    to { box-shadow: 0 0 15px rgba(255, 68, 68, 0.8); }
}

@keyframes notificationSlideIn {
    from { 
        transform: translateX(100%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

@keyframes notificationHighlight {
    0%, 100% { background-color: rgba(255, 0, 0, 0.1); }
    50% { background-color: rgba(255, 0, 0, 0.3); }
}

.notification-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.8em;
}

.priority-icon {
    margin-right: 6px;
    font-size: 1.1em;
}

.timestamp {
    color: rgba(255, 255, 255, 0.6);
    margin-right: 8px;
    font-size: 0.85em;
}

.emergency-badge {
    background: #8b0000;
    color: #ff4444;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: bold;
    margin-left: auto;
    animation: emergencyBadgePulse 1s infinite alternate;
}

@keyframes emergencyBadgePulse {
    from { background: #8b0000; }
    to { background: #ff0000; }
}

.notification-content {
    font-size: 0.9em;
    line-height: 1.3;
}

/* Responsive Design */
@media (max-width: 1200px) {
    #main-content {
        flex-direction: column;
    }
    
    #canvas-container {
        flex: 0 0 60%;
        border-right: none;
        border-bottom: 2px solid #00ff88;
    }
    
    #info-panels {
        flex: 0 0 40%;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px;
    }
    
    .panel {
        min-width: 250px;
        margin-right: 15px;
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    #canvas-container {
        flex: 0 0 50%;
    }
    
    #info-panels {
        flex: 0 0 50%;
    }
    
    .control-btn {
        padding: 6px 12px;
        font-size: 0.8em;
    }
    
    .simulation-controls {
        gap: 5px;
    }
}

/* Planning Panel Styles */
.plan-item {
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(0, 255, 136, 0.05);
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 6px;
    font-size: 0.85em;
}

.plan-item.commissioning {
    border-color: rgba(0, 212, 255, 0.5);
    background: rgba(0, 212, 255, 0.08);
}

.plan-item.emergency {
    border-color: rgba(231, 76, 60, 0.7);
    background: rgba(231, 76, 60, 0.1);
    animation: pulse-emergency 2s infinite;
}

.plan-title {
    font-weight: bold;
    color: #00ff88;
    margin-bottom: 4px;
}

.plan-status {
    font-size: 0.8em;
    color: #cccccc;
    margin-bottom: 6px;
}

.plan-parts-list {
    font-size: 0.75em;
    color: #87ceeb;
}

.plan-action {
    font-size: 0.8em;
    color: #ffd700;
    font-style: italic;
}

@keyframes pulse-emergency {
    0% { border-color: rgba(231, 76, 60, 0.7); }
    50% { border-color: rgba(231, 76, 60, 1); }
    100% { border-color: rgba(231, 76, 60, 0.7); }
}

.notification.success {
    background: rgba(0, 255, 136, 0.1);
    border-color: #00ff88;
    color: #00ff88;
}

/* AI Decision Items */
.decision-item {
    padding: 6px;
    margin-bottom: 4px;
    border-left: 3px solid #00d4ff;
    border-radius: 3px;
    font-size: 0.8em;
    background: rgba(0, 212, 255, 0.1);
    color: #87ceeb;
}

.decision-item.completed {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
}

.decision-item.analyzing {
    border-color: #ffaa00;
    background: rgba(255, 170, 0, 0.1);
    color: #ffd700;
}

/* Thought Bubble */
.thought-bubble {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    color: #1e3c72;
    border-radius: 15px;
    padding: 12px;
    margin-top: 10px;
    max-width: 250px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transform: scale(0);
    transition: transform 0.3s ease;
}

.thought-bubble:not(.hidden) {
    transform: scale(1);
}

.thought-bubble::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid rgba(255, 255, 255, 0.95);
}

/* Status Bar */
#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid #333;
    font-size: 0.85em;
    z-index: 1000;
}

.status-left, .status-center, .status-right {
    display: flex;
    gap: 20px;
}

#current-view {
    color: #00ff88;
    font-weight: bold;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-content {
    text-align: center;
    max-width: 400px;
}

.loading-content h2 {
    margin-bottom: 20px;
    color: #00ff88;
}

.loading-bar {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 15px;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #00ff88, #00d4ff);
    width: 0%;
    transition: width 0.3s ease;
}

#loading-status {
    color: #ccc;
    font-size: 0.9em;
}

/* Utility Classes */
.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.5s ease-in; }
.pulse { animation: pulse 2s infinite; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls-left h1 { font-size: 1.2em; }
    .simulation-controls { flex-wrap: wrap; }
    .location-tabs { flex-wrap: wrap; }
    .panel {
        font-size: 0.85em;
        padding: 10px;
        min-width: 150px;
    }
    .status-left, .status-center, .status-right { gap: 10px; }
}

/* Enhanced Planning Panel Styles */
.plan-item {
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(0, 20, 40, 0.8);
    border: 1px solid #00ff88;
    border-radius: 5px;
}

.plan-title {
    font-weight: bold;
    color: #00ff88;
    margin-bottom: 3px;
}

.plan-priority {
    font-size: 11px;
    margin-bottom: 2px;
}

.plan-status {
    color: #00d4ff;
    font-size: 12px;
    margin-bottom: 3px;
}

.plan-cost, .plan-impact, .plan-eta {
    font-size: 11px;
    color: #ffffff;
    margin-bottom: 2px;
}



.plan-action {
    font-size: 11px;
    color: #ffaa00;
    font-style: italic;
}

