/**
 * Cyber Logic Gate Runner Stylesheet
 * Cyberpunk Digital Circuit Board, Neon Conduits, Tactile Switches, and Truth Table Modal
 */

.logic-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px;
  box-sizing: border-box;
  background: linear-gradient(135deg, #050b14 0%, #0a1120 50%, #030712 100%);
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
  overflow-y: auto;
}

/* --- HUD BAR --- */
.logic-hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
  gap: 12px;
}

.logic-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logic-badge {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid #10b981;
  color: #34d399;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.logic-heading {
  font-size: 16px;
  font-weight: 800;
  color: #f1f5f9;
}

.logic-desc-bar {
  background: rgba(30, 41, 59, 0.6);
  border-left: 4px solid #10b981;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  color: #cbd5e1;
  margin-bottom: 12px;
}

/* --- MAIN CIRCUIT BOARD LAYOUT --- */
.logic-circuit-board {
  flex: 1;
  background: radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.06) 0%, rgba(15, 23, 42, 0.9) 100%);
  border-radius: 16px;
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 16px;
  overflow-y: auto;
}

.logic-board-layout {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 16px;
  min-height: 100%;
}

.logic-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logic-col-header {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 4px;
}

/* --- SWITCH CARDS (INPUTS) --- */
.logic-switch-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: rgba(30, 41, 59, 0.7);
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.logic-switch-card:hover:not(.fixed) {
  transform: translateY(-2px);
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}

.logic-switch-card.on {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
}

.logic-switch-card.fixed {
  cursor: not-allowed;
  opacity: 0.8;
  border-style: dashed;
}

.switch-label {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 6px;
}

.switch-toggle-pill {
  padding: 6px;
  border-radius: 8px;
  background: #1e293b;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
  transition: all 0.2s;
}

.switch-toggle-pill.active {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.switch-locked-badge {
  font-size: 10px;
  color: #f59e0b;
  font-weight: 700;
  margin-top: 4px;
}

/* --- GATE CARDS (MIDDLE COLUMN) --- */
.logic-gate-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 14px;
  border: 2px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}

.logic-gate-card.active {
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.gate-type-badge {
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 2px;
}

.gate-symbol {
  font-size: 16px;
  font-weight: 900;
  color: #f1f5f9;
  margin-bottom: 6px;
}

.gate-io-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  background: rgba(30, 41, 59, 0.6);
  padding: 4px 8px;
  border-radius: 6px;
}

.gate-in-text {
  color: #94a3b8;
}

.gate-arrow {
  color: #64748b;
}

.gate-out-text {
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.gate-out-text.high {
  background: #10b981;
  color: #fff;
}

.gate-out-text.low {
  background: #475569;
  color: #cbd5e1;
}

/* --- TARGET TERMINALS (RIGHT COLUMN) --- */
.logic-target-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: rgba(30, 41, 59, 0.6);
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s;
}

.logic-target-card.satisfied {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

.target-title {
  font-size: 13px;
  font-weight: 800;
  color: #f1f5f9;
  margin-bottom: 6px;
}

.target-status-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
}

.target-val-box.high {
  color: #34d399;
}

.target-val-box.low {
  color: #94a3b8;
}

.target-goal-box {
  color: #fbbf24;
}

.target-indicator {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: center;
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.target-indicator.active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

/* --- TRUTH TABLE MODAL --- */
.truth-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
}

.truth-table-card {
  background: rgba(30, 41, 59, 0.8);
  border-radius: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.truth-table-title {
  font-size: 13px;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 6px;
  text-align: center;
}

.truth-table-raw {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.truth-table-raw th, .truth-table-raw td {
  padding: 4px 6px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.truth-table-raw th {
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
}

/* --- LEVEL SELECT GRID --- */
.logic-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.logic-lvl-grid-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s;
}

.logic-lvl-grid-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  transform: translateY(-2px);
}

.logic-lvl-grid-btn.current {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
}

.grid-btn-num {
  font-size: 18px;
  font-weight: 900;
  color: #38bdf8;
}

.grid-btn-title {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  margin: 4px 0;
}

.grid-btn-tier {
  font-size: 10px;
  color: #94a3b8;
}

/* --- RESPONSIVE IPAD & MOBILE --- */
@media (max-width: 768px) {
  .logic-board-layout {
    grid-template-columns: 1fr;
  }
}
