/* Base styles */
body { 
  margin: 0; 
  background-color: #212121; /* Dark background for better contrast */
  overflow: hidden;
  font-family: Arial, sans-serif;
}

/* Sidebar styles */
#sidebar {
  position: fixed;
  top: 0;
  left: -400px; /* Hidden by default */
  width: 400px;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  color: white;
  z-index: 1001;
  transition: left 0.3s ease;
  border-right: 1px solid #444;
  backdrop-filter: blur(10px);
  overflow-y: auto;
}

#sidebar.open {
  left: 0;
}

/* Mobile responsive sidebar */
@media (max-width: 768px) {
  #sidebar {
    width: 100vw;
    left: -100vw;
  }
  
  #sidebar.open {
    left: 0;
  }
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #444;
  background: rgba(102, 204, 255, 0.1);
}

.sidebar-title {
  font-size: 18px;
  font-weight: bold;
  color: #66ccff;
  margin: 0 0 8px 0;
}

.sidebar-subtitle {
  font-size: 14px;
  color: #aaa;
  margin: 0;
}

.sidebar-content {
  padding: 20px;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-section-title {
  font-size: 14px;
  font-weight: bold;
  color: #66ccff;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid #333;
}

.sidebar-item {
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.sidebar-label {
  color: #99ff66;
  font-weight: bold;
  display: inline-block;
  min-width: 120px;
}

.sidebar-value {
  color: #fff;
}

.sidebar-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: #66ccff;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile responsive sidebar close button */
@media (max-width: 768px) {
  .sidebar-close {
    top: 10px;
    right: 10px;
    font-size: 28px;
    min-width: 48px;
    min-height: 48px;
  }
}

.sidebar-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.sidebar-label-item {
  background: rgba(102, 204, 255, 0.2);
  color: #66ccff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  border: 1px solid rgba(102, 204, 255, 0.3);
}

.sidebar-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  display: inline-block;
}

.status-running { background: rgba(68, 255, 68, 0.2); color: #44ff44; }
.status-failed { background: rgba(255, 68, 68, 0.2); color: #ff4444; }
.status-pending { background: rgba(255, 136, 68, 0.2); color: #ff8844; }
.status-default { background: rgba(170, 170, 170, 0.2); color: #aaa; }

.legend-line {
  width: 20px;
  height: 3px;
  margin-right: 8px;
  border-radius: 1px;
}

.relationship-count {
  font-size: 9px;
  color: #888;
  margin-left: auto;
}

.legend-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #333;
}

/* Connection status */
#connection-status {
  position: fixed;
  top: 10px;
  left: 10px;
  padding: 8px 12px;
  border-radius: 4px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  z-index: 1000;
}

/* Mobile responsive connection status */
@media (max-width: 768px) {
  #connection-status {
    top: 5px;
    left: 5px;
    padding: 6px 8px;
    font-size: 10px;
    border-radius: 3px;
  }
}

/* Legend styles */
#legend {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-family: Arial, sans-serif;
  font-size: 11px;
  max-width: 220px;
  z-index: 1000;
  border: 1px solid #444;
  backdrop-filter: blur(5px);
  max-height: 80vh;
  overflow-y: auto;
}

/* Custom scrollbar for legend */
#legend::-webkit-scrollbar {
  width: 6px;
}

#legend::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

#legend::-webkit-scrollbar-thumb {
  background: rgba(102, 204, 255, 0.6);
  border-radius: 3px;
}

#legend::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 204, 255, 0.8);
}

/* Firefox scrollbar styling */
#legend {
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 204, 255, 0.6) rgba(255, 255, 255, 0.1);
}

/* Mobile legend toggle button */
#legend-toggle {
  display: none;
  position: fixed;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  z-index: 1001;
  backdrop-filter: blur(5px);
}

#legend-toggle:hover {
  background: rgba(102, 204, 255, 0.2);
}

/* Mobile responsive legend */
@media (max-width: 768px) {
  #legend-toggle {
    display: block;
    z-index: 999; /* Lower than sidebar close button */
  }
  
  #legend {
    top: 50px;
    right: 5px;
    left: 5px;
    max-width: none;
    width: auto;
    font-size: 10px;
    padding: 8px;
    max-height: 50vh;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999; /* Lower than sidebar close button */
  }
  
  #legend.mobile-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }
  
  /* Hide legend toggle when sidebar is open */
  #sidebar.open ~ #legend-toggle {
    display: none;
  }
  
  #sidebar.open ~ #legend {
    display: none;
  }
}

.legend-item {
  padding: 4px 6px;
  margin-bottom: 6px;
  font-size: 11px;
  display: flex;
  align-items: center;
}

.legend-controls {
  flex-direction: column;
  gap: 4px;
}

.legend-button {
  padding: 6px 8px;
  font-size: 9px;
}

.help-text {
  font-size: 8px;
  line-height: 1.2;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  user-select: none;
}

.legend-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.legend-item.disabled {
  opacity: 0.4;
  background-color: rgba(255, 0, 0, 0.1);
}

.legend-item.disabled:hover {
  background-color: rgba(255, 0, 0, 0.2);
}

.legend-color {
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #66ccff;
  text-align: center;
}

.legend-controls {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #444;
  display: flex;
  gap: 8px;
}

.legend-button {
  background: rgba(102, 204, 255, 0.2);
  border: 1px solid #66ccff;
  color: #66ccff;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s ease;
  flex: 1;
  text-align: center;
}

.legend-button:hover {
  background: rgba(102, 204, 255, 0.3);
  color: white;
}

.preset-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preset-button {
  background: rgba(153, 255, 102, 0.2);
  border: 1px solid #99ff66;
  color: #99ff66;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s ease;
  text-align: center;
}

.preset-button:hover {
  background: rgba(153, 255, 102, 0.3);
  color: white;
}

.preset-button.active {
  background: rgba(153, 255, 102, 0.4);
  color: white;
  border-color: white;
}

.resource-count {
  font-size: 9px;
  color: #888;
  margin-left: auto;
}

.help-text {
  font-size: 9px;
  color: #666;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #333;
  text-align: center;
  line-height: 1.3;
}

/* Loading overlay styles */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(33, 33, 33, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(5px);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Rendering dialog styles */
#rendering-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95);
  color: white;
  padding: 20px 30px;
  border-radius: 12px;
  font-family: Arial, sans-serif;
  z-index: 1500;
  border: 1px solid #444;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 15px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#rendering-dialog.visible {
  opacity: 1;
  visibility: visible;
}

.rendering-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(102, 204, 255, 0.3);
  border-top: 2px solid #66ccff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.rendering-text {
  color: #66ccff;
  font-size: 16px;
  font-weight: bold;
}

/* Mobile responsive rendering dialog */
@media (max-width: 768px) {
  #rendering-dialog {
    padding: 15px 20px;
    border-radius: 8px;
  }
  
  .rendering-spinner {
    width: 20px;
    height: 20px;
  }
  
  .rendering-text {
    font-size: 14px;
  }
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(102, 204, 255, 0.3);
  border-top: 4px solid #66ccff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: #66ccff;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
  text-align: center;
}

.loading-subtext {
  color: #aaa;
  font-size: 14px;
  text-align: center;
  max-width: 300px;
  line-height: 1.4;
}

/* Mobile responsive loading */
@media (max-width: 768px) {
  .loading-spinner {
    width: 50px;
    height: 50px;
    border-width: 3px;
  }
  
  .loading-text {
    font-size: 16px;
  }
  
  .loading-subtext {
    font-size: 12px;
    max-width: 250px;
  }
}
