/* ===== Global Styles ===== */
body {
  margin: 0;
  font-family: 'IBM Plex Sans', 'Roboto Mono', sans-serif;
  background: linear-gradient(135deg, #eaf1f8, #cfd9df);
  color: #1b2735;
  display: flex;
  flex-direction: column;
  /* allow the whole page to scroll */
  overflow-x: hidden;
  overflow-y: auto;
}

/* ===== Top Menu Bar ===== */
.menu-bar {
  background: linear-gradient(90deg, #283e51, #485563);
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 100;
  position: sticky;
  top: 0;
}

.menu-title {
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.5px;
}

/* ===== Enhanced Top Navigation Buttons ===== */
.menu-bar-right ul {
  list-style: none;
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 0;
}

.menu-bar-right ul li a {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 30px;
  font-weight: 500;
  font-size: 0.95rem;
  color: #ecf0f1;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.05),
              0 0 8px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
  backdrop-filter: blur(6px);
}

.menu-bar-right ul li a:hover {
  background: linear-gradient(135deg, rgba(93,173,226,0.3), rgba(52,152,219,0.4));
  border-color: rgba(93,173,226,0.7);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(93,173,226,0.5);
}

.menu-bar-right ul li a[aria-current="page"],
.menu-bar-right ul li a.active {
  background: linear-gradient(135deg, #5dade2, #3498db);
  border-color: #5dade2;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(93,173,226,0.7);
}

.menu-bar-right ul li a:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(93,173,226,0.6);
}

.menu-bar-right ul li a[aria-current="page"]::after {
  content: "";
  display: block;
  height: 2px;
  background: #5dade2;
  margin-top: 6px;
  border-radius: 1px;
  animation: activePulse 1.5s infinite alternate;
}

@keyframes activePulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* ===== Toolbar (Horizontal Replacement for Sidebar) ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  background: linear-gradient(90deg, #3a6073, #16222a);
  color: white;
  padding: 12px 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border-bottom: 2px solid rgba(93,173,226,0.25);
  position: sticky;
  top: 60px; /* below menu-bar */
  z-index: 99;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-section h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #d5d8dc;
  letter-spacing: 0.4px;
}

/* ===== Toolbar Buttons ===== */
.component-button {
  padding: 8px 14px;
  border: none;
  background: linear-gradient(135deg, #3498db, #2471a3);
  color: white;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  transition: all 0.25s ease;
}

.component-button:hover {
  background: linear-gradient(135deg, #2e86c1, #1f618d);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(93,173,226,0.4);
}

/* ===== Main Layout ===== */
.main-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  /* let the whole page scroll naturally */
}

/* ===== Workspace ===== */
.content {
  flex: 1;
  padding: 20px;
  scroll-behavior: smooth;
  /* remove inner scroll so page scrolls */
}

/* ===== Canvas ===== */
.canvas {
  position: relative;
  min-width: 1200px; /* enables horizontal scroll if needed */
  min-height: 800px; /* enables vertical scroll naturally */
  background: linear-gradient(120deg, #ffffff, #e9eef4);
  border: 2px dashed #5dade2;
  border-radius: 15px;
  box-shadow: inset 0 0 15px rgba(93,173,226,0.2);
  margin-top: 20px;
  transition: all 0.3s ease;
  cursor: grab;
  overflow: auto; /* keeps canvas internal scroll if content overflows */
}

/* ===== Scrollbar Styling ===== */
.content::-webkit-scrollbar,
.canvas::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.content::-webkit-scrollbar-track,
.canvas::-webkit-scrollbar-track {
  background: #dbe3eb;
  border-radius: 10px;
}

.content::-webkit-scrollbar-thumb,
.canvas::-webkit-scrollbar-thumb {
  background: #5dade2;
  border-radius: 10px;
}

.content::-webkit-scrollbar-thumb:hover,
.canvas::-webkit-scrollbar-thumb:hover {
  background: #3498db;
}

/* ===== Components ===== */
.input-component,
.gate-component,
.output-component {
  position: absolute;
  width: 130px;
  height: 90px;
  background: #ffffff;
  border: 2px solid #5dade2;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  cursor: grab;
  user-select: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.input-component:active,
.gate-component:active,
.output-component:active {
  cursor: grabbing;
  transform: scale(1.05);
  border-color: #1abc9c;
  box-shadow: 0 6px 18px rgba(26,188,156,0.4);
}

/* ===== Connectors ===== */
.connector {
  width: 14px;
  height: 14px;
  background: #3498db;
  border-radius: 50%;
  position: absolute;
  cursor: pointer;
  transition: all 0.2s ease;
}

.connector:hover {
  background: #48c9b0;
  transform: scale(1.2);
}

/* ===== LED Indicator ===== */
.led-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-bottom: 6px;
  background-color: #99a3a4;
  transition: all 0.3s ease;
}

.led-indicator.on {
  background-color: #2ecc71;
  box-shadow: 0 0 8px #2ecc71;
}

.led-indicator.off {
  background-color: #e74c3c;
  box-shadow: 0 0 8px #e74c3c;
}

/* ===== Wires ===== */
.wire {
  stroke: #5dade2;
  stroke-width: 3;
  fill: none;
  transition: all 0.25s ease;
}

.wire:hover {
  stroke: #48c9b0;
  stroke-width: 4;
  cursor: pointer;
}

/* ===== Info Panel ===== */
.info-panel {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 260px;
  max-height: 400px;
  overflow-y: auto;
  background: rgba(255,255,255,0.95);
  border: 2px solid #5dade2;
  padding: 15px;
  font-size: 13px;
  color: #1b2735;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(27, 39, 53, 0.7);
  animation: fadeIn 0.3s;
}

.modal-content {
  background: #fff;
  margin: 5% auto;
  padding: 25px;
  border-radius: 15px;
  border: 2px solid #5dade2;
  width: 70%;
  max-height: 80%;
  overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 25px;
  right: 25px;
  background: #5dade2;
  color: #fff;
  padding: 14px 26px;
  border-radius: 12px;
  font-weight: bold;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  transition: all 0.3s ease;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
