/* ═══════════════════════════════════════════════
   UTK Lab Solver – Styl główny
   ═══════════════════════════════════════════════ */

:root {
  --bg:        #0F172A;
  --sidebar:   #1E293B;
  --card:      #FFFFFF;
  --accent:    #3B82F6;
  --accent2:   #8B5CF6;
  --green:     #10B981;
  --amber:     #F59E0B;
  --red:       #EF4444;
  --cyan:      #06B6D4;
  --text:      #1E293B;
  --text-light:#64748B;
  --border:    #E2E8F0;
  --hover:     #EFF6FF;

  /* Gate colours */
  --gate-and:  #2563EB;
  --gate-or:   #059669;
  --gate-not:  #D97706;
  --gate-nand: #7C3AED;
  --gate-nor:  #DC2626;
  --gate-xor:  #0891B2;
  --gate-wire: #334155;
  --gate-out:  #EF4444;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #334155;
  overflow: hidden;
}

.logo {
  padding: 20px 16px 12px;
  font-size: 15px;
  font-weight: 700;
  color: #F8FAFC;
  letter-spacing: .5px;
  border-bottom: 1px solid #334155;
  background: linear-gradient(135deg, #1E40AF, #6D28D9);
}
.logo small { display: block; font-size: 10px; font-weight: 400;
  color: #94A3B8; margin-top: 2px; letter-spacing: 1px; }

.ex-tabs { display: flex; border-bottom: 1px solid #334155; }
.ex-tab  {
  flex: 1; padding: 10px 4px; font-size: 12px; font-weight: 600;
  text-align: center; cursor: pointer; color: #94A3B8;
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}
.ex-tab.active { color: var(--accent); border-bottom-color: var(--accent);
  background: #0F172A22; }
.ex-tab:hover:not(.active) { color: #CBD5E1; background: #FFFFFF08; }

.task-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-track { background: transparent; }
.task-list::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }

.task-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; border-radius: 6px;
  margin: 1px 6px; transition: all .15s; position: relative;
}
.task-item:hover { background: #FFFFFF10; }
.task-item.active { background: #1D4ED820; }

.task-num {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  color: white;
}
.task-info { flex: 1; min-width: 0; }
.task-info .task-name { font-size: 12px; color: #CBD5E1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-info .task-sfp { font-size: 10px; color: #64748B; margin-top: 1px; }

.task-item.active .task-name { color: #F8FAFC; }
.task-item.active .task-num  { box-shadow: 0 0 0 2px rgba(255,255,255,.2); }

/* ── Main area ─────────────────────────────────── */
.main {
  flex: 1; display: flex; flex-direction: column;
  background: #F1F5F9; overflow: hidden;
}

.topbar {
  background: white; border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; flex-shrink: 0;
}
.topbar h1 { font-size: 15px; font-weight: 700; color: var(--text); flex: 1; }
.topbar .badge {
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: #EFF6FF; color: var(--accent); border: 1px solid #BFDBFE;
}

.view-tabs { display: flex; gap: 4px; }
.vtab {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; background: transparent; color: var(--text-light);
  transition: all .15s;
}
.vtab.active { background: var(--accent); color: white; }
.vtab:hover:not(.active) { background: var(--border); color: var(--text); }

.content { flex: 1; overflow-y: auto; padding: 20px; }
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

/* ── Cards ─────────────────────────────────────── */
.card {
  background: white; border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  overflow: hidden;
}
.card-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  background: #FAFBFC;
}
.card-header .dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.card-body { padding: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-4   { margin-bottom: 16px; }

/* ── Karnaugh Map ──────────────────────────────── */
.kmap-wrap { overflow-x: auto; }
.kmap-container { display: inline-block; position: relative; }

.kmap-table {
  border-collapse: collapse; user-select: none;
}
.kmap-table th, .kmap-table td {
  border: 1px solid #CBD5E1;
  text-align: center; font-size: 13px;
}
.kmap-table th {
  padding: 6px 14px; background: #1E293B; color: white; font-weight: 600;
}
.kmap-table td {
  width: 54px; height: 54px; font-weight: 700; font-size: 18px; cursor: default;
  position: relative;
}
.kmap-corner { background: #334155 !important; }
.cell-1 { color: #1D4ED8; background: #EFF6FF; }
.cell-0 { color: #94A3B8; background: white; }
.cell-x { color: #9333EA; background: #FAF5FF; font-style: italic; }
.mint-idx {
  position: absolute; top: 2px; right: 3px;
  font-size: 9px; color: #CBD5E1; font-weight: 400;
}

.kmap-svg-overlay {
  position: absolute; top: 0; left: 0; pointer-events: none;
}

/* ── Equations ─────────────────────────────────── */
.eq-block {
  background: #F8FAFC; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 10px;
}
.eq-label { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-light); margin-bottom: 6px; }
.eq-formula {
  font-family: 'Courier New', monospace; font-size: 14px;
  color: var(--text); line-height: 1.6;
}
.eq-formula .op  { color: var(--accent);  font-weight: 700; }
.eq-formula .neg { text-decoration: overline; }
.eq-sfp { background: #EFF6FF; border-color: #BFDBFE; }
.eq-sfp .eq-formula { color: #1D4ED8; }

.steps-list { list-style: none; }
.steps-list li {
  padding: 6px 12px; border-radius: 6px; margin-bottom: 4px;
  font-family: monospace; font-size: 12px; background: #F8FAFC;
  border-left: 3px solid var(--accent);
}

/* ── Truth table ───────────────────────────────── */
.tt-wrap { overflow-x: auto; }
.tt {
  border-collapse: collapse; font-size: 12px; width: 100%;
}
.tt th {
  background: #1E293B; color: white; padding: 7px 12px;
  font-weight: 600; text-align: center; white-space: nowrap;
  border: 1px solid #334155;
}
.tt td {
  padding: 5px 12px; text-align: center; border: 1px solid #E2E8F0;
  font-family: monospace;
}
.tt tr:nth-child(even) td { background: #F8FAFC; }
.tt td.v1 { color: #1D4ED8; font-weight: 700; }
.tt td.v0 { color: #94A3B8; }
.tt td.vx { color: #7C3AED; font-style: italic; }
.tt .sep { border-left: 2px solid #94A3B8 !important; }

/* ── Circuit SVG area ──────────────────────────── */
.circuit-wrap {
  overflow: auto; background: #F8FAFC;
  border-radius: 8px; border: 1px solid var(--border);
  min-height: 300px; display: flex; align-items: flex-start;
  justify-content: flex-start;
}
.circuit-svg { display: block; }

/* Gate legend */
.gate-legend {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-light);
}
.legend-dot {
  width: 12px; height: 12px; border-radius: 2px;
}

/* Output selector (for complex circuits) */
.out-selector {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px;
}
.out-btn {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: white;
  color: var(--text-light); transition: all .15s;
}
.out-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.out-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* Category pills */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}
.pill-koder      { background: #DBEAFE; color: #1D4ED8; }
.pill-dekoder    { background: #D1FAE5; color: #065F46; }
.pill-translator { background: #EDE9FE; color: #5B21B6; }
.pill-mux        { background: #FEF3C7; color: #92400E; }
.pill-sumator    { background: #FCE7F3; color: #9D174D; }

/* 7-segment display */
.seg-display { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-digit { display: flex; flex-direction: column; align-items: center;
  gap: 2px; font-size: 10px; color: var(--text-light); }

/* Info box */
.info-box {
  padding: 10px 14px; border-radius: 8px; font-size: 12px;
  background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF;
  margin-bottom: 12px;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); }
                    to   { opacity: 1; transform: translateY(0); } }
.content > * { animation: fadeIn .2s ease; }

/* Responsive */
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { width: 200px; min-width: 200px; }
}
