/* ===========================
   DESIGN SYSTEM — ZMIENNE
   =========================== */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --accent: #4361ee;
  --accent-hover: #3651d4;
  --accent-light: #eef1ff;
  --text: #2d3436;
  --text-muted: #636e72;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 24px rgba(67, 97, 238, 0.18);
  --radius-card: 14px;
  --radius-btn: 8px;
  --radius-sm: 6px;
  --font: system-ui, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --transition: 0.2s ease;
}

/* ===========================
   DARK MODE
   =========================== */
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #1e2130;
  --accent-light: #1a2040;
  --text: #e8eaf0;
  --text-muted: #8892a4;
  --border: #2a2f45;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 8px 24px rgba(67, 97, 238, 0.28);
}
[data-theme="dark"] .qb-field input:focus,
[data-theme="dark"] .qb-field textarea:focus {
  background: var(--surface);
}

/* ===========================
   RESET & BASE
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }

/* ===========================
   HEADER / NAVBAR
   =========================== */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.navbar-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color var(--transition);
}
.navbar-back:hover { color: var(--accent); }
.navbar-sep { color: var(--border); }
.navbar-page { font-weight: 600; color: var(--text); font-size: 0.95rem; }
.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  width: 36px;
  height: 36px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--text);
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ===========================
   MAIN WRAPPER
   =========================== */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* ===========================
   HERO (strona główna)
   =========================== */
.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.5px;
}
.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ===========================
   TILES GRID (strona główna)
   =========================== */
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  box-shadow: var(--shadow);
}
.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}
.tile-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.tile-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.tile-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.tile-tag {
  margin-top: auto;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

/* ===========================
   PAGE HEADER (podstrony)
   =========================== */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 0.25rem;
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ===========================
   TABS
   =========================== */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 0.25rem;
  margin-bottom: 1.75rem;
  width: fit-content;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: calc(var(--radius-btn) - 2px);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
}
.tab-btn.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===========================
   DIALECT COLUMNS (SQL Basics)
   =========================== */
.dialect-section { margin-bottom: 2rem; }
.dialect-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dialect-section h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.dialects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.875rem;
}
.dialect-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.dialect-card-header {
  background: var(--accent);
  color: white;
  padding: 0.5rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dialect-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(255,255,255,0.2);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}
.dialect-card pre {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  padding: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: var(--surface);
  margin: 0;
}

/* Różne kolory dla dialektów */
.dialect-card[data-dialect="mysql"] .dialect-card-header { background: #e67e22; }
.dialect-card[data-dialect="postgresql"] .dialect-card-header { background: #336791; }
.dialect-card[data-dialect="mariadb"] .dialect-card-header { background: #003545; }
.dialect-card[data-dialect="tsql"] .dialect-card-header { background: #cc2927; }
.dialect-card[data-dialect="plsql"] .dialect-card-header { background: #f80000; }

/* ===========================
   QUERY BUILDER
   =========================== */
.qb-container { display: flex; flex-direction: column; gap: 1.5rem; }

/* Selector kółek */
.qb-type-selector {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.qb-type-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.qb-type-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.qb-type-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-hover);
}

/* Panel pól */
.qb-fields {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.qb-fields h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}
.qb-form { display: flex; flex-direction: column; gap: 0.875rem; }
.qb-field { display: flex; flex-direction: column; gap: 0.3rem; }
.qb-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.qb-field .hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.qb-field input, .qb-field textarea {
  font-family: var(--mono);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color var(--transition);
  width: 100%;
  resize: vertical;
}
.qb-field input:focus, .qb-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
}

/* Wynik */
.qb-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.qb-result-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface-2);
}
.qb-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0;
}
.qb-dialect-result {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.qb-dialect-result:last-child { border-right: none; }
.qb-dialect-result-header {
  padding: 0.45rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.qb-dialect-result pre {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.65;
  padding: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  margin: 0;
}
.copy-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition);
}
.copy-btn:hover { background: rgba(255,255,255,0.35); }
.placeholder-msg {
  grid-column: 1 / -1;
  padding: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ===========================
   FOOTER
   =========================== */
.footer {
  text-align: center;
  padding: 2rem;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 640px) {
  .main { padding: 1.5rem 1rem; }
  .hero h1 { font-size: 1.5rem; }
  .dialects-grid { grid-template-columns: 1fr; }
  .qb-result-grid { grid-template-columns: 1fr; }
  .qb-dialect-result { border-right: none; }
  .qb-type-btn { width: 70px; height: 70px; font-size: 0.7rem; }
}
