/* =============================================
   KB Template: syntax — v1.0
   Skonsolidowane style szablonu syntax.
   Zawiera: layout, typografia, dark mode, WCAG focus,
   formularze, SVG, style migracyjne z S1 (Fakturownia).
   ============================================= */

/* --- Layout & Scroll --- */
* {
  scroll-padding-top: 100px;
  scroll-behavior: smooth;
}

/* --- Szersza treść artykułu na dużych ekranach --- */
@media (min-width: 1450px) {
  .syntax-wide-container {
    max-width: 100rem;
  }
}

/* --- Font display (Lexend headings) --- */
.font-display,
h1, h2, h3, h4, h5 {
  font-family: 'Lexend', sans-serif;
}


/* =============================================
   syntax-content — typografia treści artykułu
   ============================================= */

.syntax-content h1,
.syntax-content h2,
.syntax-content h3,
.syntax-content h4,
.syntax-content h5 {
  color: #0f172a;
}

.syntax-content h2 {
  font-size: 1.25rem;
  padding: 0.65rem 0;
}

.syntax-content p {
  color: #475569;
  padding-bottom: 0 !important;
}

.syntax-content a {
  display: inline;
  font-weight: 500;
  color: #2563eb;
  transition: .1s;
}

.syntax-content a:hover {
  color: #1d4ed8;
}

.syntax-content strong,
.syntax-content b {
  font-weight: 500;
  color: #334155;
}

/* --- Listy --- */
.syntax-content ul {
  list-style: disc !important;
  padding-left: 1.5em !important;
  padding-bottom: 0 !important;
}

.syntax-content ul li {
  padding-left: 0.3em !important;
  position: static !important;
}

.syntax-content ul li:before,
.syntax-content ul li:after {
  display: none !important;
}

.syntax-content ol {
  padding-bottom: 0 !important;
}

/* li > p — usunięcie marginesów (migracja S1 wstawia <p> w <li>) */
.syntax-content li > p {
  margin: 0 !important;
}

/* --- Obrazki --- */
.syntax-content img {
  max-width: 100%;
  height: auto;
  margin: 1.25rem 0;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  border-radius: 10px;
}

/* --- Bloki kodu --- */
.syntax-content pre {
  background-color: #1e293b;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.875rem;
  line-height: 1.7;
}

.syntax-content pre code {
  background: none;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.syntax-content code {
  background-color: #f1f5f9;
  color: #0f172a;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.syntax-content pre[class*="language-"] {
  padding: 0 !important;
}

.syntax-content pre[style*="background"] {
  padding: 12px 16px !important;
  border-radius: 8px !important;
  margin: 16px 0 !important;
  color: #1e293b !important;
  overflow-x: auto;
}

/* --- Search results grid --- */
.syntax-search-results ul {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .syntax-search-results ul {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =============================================
   Dark mode — syntax-content
   ============================================= */

.dark .syntax-content h1,
.dark .syntax-content h2,
.dark .syntax-content h3,
.dark .syntax-content h4,
.dark .syntax-content h5 {
  color: #f8fafc;
}

.dark .syntax-content p {
  color: #d1d5db;
}

.dark .syntax-content strong,
.dark .syntax-content b {
  color: #e2e8f0;
}

.dark .syntax-content code {
  background-color: #1e293b;
  color: #e2e8f0;
}

.dark .syntax-content a {
  color: #60a5fa;
}

.dark .syntax-content a:hover {
  color: #93bbfd;
}

.dark .syntax-content pre[style*="background"] {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

/* Override slate colors in dark mode for custom HTML content */
.dark .text-slate-900 { color: #f8fafc !important; }
.dark .text-slate-800 { color: #f1f5f9 !important; }
.dark .text-slate-700 { color: #e2e8f0 !important; }
.dark .text-slate-600 { color: #d1d5db !important; }
.dark .text-slate-500 { color: #cbd5e1 !important; }

/* =============================================
   to-instruction box (CTA z konfiguratorem itp.)
   ============================================= */

.syntax-content .to-instruction {
  display: flex;
  flex-direction: column;
  align-items: start;
  border: 1px solid #3861E5;
  border-radius: 8px;
  padding: 16px 20px;
  gap: 8px;
  margin: 20px 0;
  background: #f0f4ff;
}

@media (min-width: 640px) {
  .syntax-content .to-instruction {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.syntax-content .to-instruction p {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.875rem;
  color: #475569;
}

.syntax-content .to-instruction-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.syntax-content .to-instruction-content-text {
  display: flex;
  align-items: center;
  gap: 6px;
}

.syntax-content .to-instruction-content-text span {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.syntax-content .instruction-cta {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 8px 20px;
  background: #3861E5;
  color: #fff !important;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 6px;
  text-decoration: none !important;
  transition: background 0.15s;
}

.syntax-content .instruction-cta:hover {
  background: #2d4ec4;
  color: #fff !important;
}

.dark .syntax-content .to-instruction {
  background: #0f172a;
  border-color: #3b82f6;
}

.dark .syntax-content .to-instruction-content-text span {
  color: #e2e8f0;
}

.dark .syntax-content .to-instruction p {
  color: #94a3b8;
}

.dark .syntax-content .instruction-cta {
  background: #2563eb;
}

.dark .syntax-content .instruction-cta:hover {
  background: #3b82f6;
}

/* =============================================
   above-instruction (wariant z ramką szarą)
   ============================================= */

.syntax-content .above-instruction {
  display: flex;
  flex-direction: column;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 16px;
  gap: 8px;
  margin: 15px 0;
}

.syntax-content .instruction-content {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 600;
}

.dark .syntax-content .above-instruction {
  background: #0f172a;
  border-color: #374151;
}

.dark .syntax-content .instruction-content {
  color: #e2e8f0;
}

/* =============================================
   Ikony (stars-icon, info-icon)
   ============================================= */

.syntax-content .stars-icon,
.syntax-content .info-icon {
  width: 24px;
  height: 24px;
  color: #2563eb;
}

.dark .syntax-content .stars-icon,
.dark .syntax-content .info-icon {
  color: #60a5fa;
}

/* =============================================
   Style migracyjne z S1 — boxy kolorowe
   (inline style background overrides)
   ============================================= */

/* --- Szary box WAŻNE/UWAGA (background:#eeeeee) --- */
.syntax-content div[style*="background:#eeeeee"],
.syntax-content div[style*="background: #eeeeee"],
.syntax-content div[style*="background:#eee"],
.syntax-content div[style*="background:rgb(238"],
.syntax-content div[style*="background: rgb(238"] {
  background: #fef3c7 !important;
  border: 1px solid #f59e0b !important;
  border-left: 4px solid #f59e0b !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  margin: 16px 0 !important;
  color: #1e293b !important;
  font-size: 0.9rem;
  line-height: 1.6;
}

.syntax-content div[style*="background:#eeeeee"] p,
.syntax-content div[style*="background: #eeeeee"] p,
.syntax-content div[style*="background:#eee"] p {
  margin: 0 !important;
  padding: 0 !important;
}

.syntax-content div[style*="background:#eeeeee"] span[style*="color:#e74c3c"],
.syntax-content div[style*="background:#eeeeee"] span[style*="color: #e74c3c"] {
  color: #b45309 !important;
}

.dark .syntax-content div[style*="background:#eeeeee"],
.dark .syntax-content div[style*="background: #eeeeee"],
.dark .syntax-content div[style*="background:#eee"],
.dark .syntax-content div[style*="background:rgb(238"],
.dark .syntax-content div[style*="background: rgb(238"] {
  background: #451a03 !important;
  border-color: #d97706 !important;
  color: #fef3c7 !important;
}

.dark .syntax-content div[style*="background:#eeeeee"] span[style*="color:#e74c3c"],
.dark .syntax-content div[style*="background:#eeeeee"] span[style*="color: #e74c3c"] {
  color: #fbbf24 !important;
}

.dark .syntax-content div[style*="background:#eeeeee"] strong {
  color: #fef3c7 !important;
}

/* --- Niebieski info box (#d9edf7, #F0F8FF) --- */
.syntax-content div[style*="background:#d9edf7"],
.syntax-content div[style*="background:#F0F8FF"],
.syntax-content div[style*="background: #d9edf7"],
.syntax-content div[style*="background: #F0F8FF"] {
  background: #eff6ff !important;
  border: 1px solid #3b82f6 !important;
  border-left: 4px solid #3b82f6 !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  margin: 16px 0 !important;
  color: #1e293b !important;
  font-size: 0.9rem;
  line-height: 1.6;
}

.syntax-content div[style*="background:#d9edf7"] p,
.syntax-content div[style*="background:#F0F8FF"] p {
  margin: 0 !important;
  padding: 0 !important;
}

.dark .syntax-content div[style*="background:#d9edf7"],
.dark .syntax-content div[style*="background:#F0F8FF"],
.dark .syntax-content div[style*="background: #d9edf7"],
.dark .syntax-content div[style*="background: #F0F8FF"] {
  background: #0c1a3d !important;
  border-color: #2563eb !important;
  color: #dbeafe !important;
}

.dark .syntax-content div[style*="background:#d9edf7"] strong,
.dark .syntax-content div[style*="background:#F0F8FF"] strong {
  color: #dbeafe !important;
}

/* --- Zielony box PODSUMOWANIE (background:#00000) --- */
.syntax-content div[style*="background:#00000"] {
  background: #f0fdf4 !important;
  border: 1px solid #22c55e !important;
  border-left: 4px solid #22c55e !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  margin: 16px 0 !important;
  color: #1e293b !important;
  font-size: 0.9rem;
  line-height: 1.6;
}

.syntax-content div[style*="background:#00000"] p {
  margin: 0 !important;
  padding: 0 !important;
}

.dark .syntax-content div[style*="background:#00000"] {
  background: #052e16 !important;
  border-color: #166534 !important;
  color: #bbf7d0 !important;
}

.dark .syntax-content div[style*="background:#00000"] strong {
  color: #bbf7d0 !important;
}

/* =============================================
   Fancy numerowane kroki OL (z S1)
   ============================================= */

.syntax-content ol {
  counter-reset: myCounter;
  margin-left: 0;
  padding-left: 5px;
}

.syntax-content ol li {
  position: relative;
  padding-left: 3em;
  margin: .45em 0;
  list-style: none;
  line-height: 1.8em;
  transition: all .2s ease-in-out;
}

.syntax-content ol li:before {
  content: counter(myCounter);
  counter-increment: myCounter;
  position: absolute;
  top: 0;
  left: 0;
  width: 1.8em;
  height: 1.8em;
  line-height: 1.8em;
  padding: 0;
  color: #fff;
  background: #2980b9;
  font-weight: 700;
  text-align: center;
  border-radius: .9em;
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.3);
  z-index: 1;
  transition: all .3s ease-in-out;
}

.syntax-content ol li li:before {
  background-color: #3498db;
}

.syntax-content ol li:after {
  position: absolute;
  top: 2.1em;
  left: .9em;
  width: 2px;
  height: calc(100% - 2em);
  content: "";
  background-color: #cbcbcb;
  z-index: 0;
}

.syntax-content ol li:last-child:after {
  display: none;
}

.syntax-content ol li li {
  font-size: .85em;
}

.dark .syntax-content ol li:before {
  background: #2563eb;
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.5);
}

.dark .syntax-content ol li li:before {
  background-color: #3b82f6;
}

.dark .syntax-content ol li:after {
  background-color: #475569;
}

/* =============================================
   img-desc — podpisy pod obrazkami (25 wpisów)
   ============================================= */

.syntax-content .img-desc {
  display: block;
  text-align: center;
  font-size: 0.85em;
  color: #64748b;
  margin-top: 4px;
  margin-bottom: 8px;
  font-style: italic;
}

.dark .syntax-content .img-desc {
  color: #94a3b8;
}

/* =============================================
   image-list — grid obrazków
   ============================================= */

.syntax-content .image-list {
  list-style: none !important;
  padding: 0 !important;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin: 16px 0;
  counter-reset: none;
}

.syntax-content .image-list li {
  text-align: center;
  padding-left: 0 !important;
}

.syntax-content .image-list li:before,
.syntax-content .image-list li:after {
  display: none !important;
}

.syntax-content .image-list img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.dark .syntax-content .image-list img {
  border-color: #334155;
}

/* =============================================
   table + table-bordered
   ============================================= */

.syntax-content .table-bordered,
.syntax-content .table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.95em;
}

.syntax-content .table-bordered th,
.syntax-content .table-bordered td,
.syntax-content .table th,
.syntax-content .table td {
  border: 1px solid #d1d5db;
  padding: 8px 12px;
  text-align: left;
}

.syntax-content .table-bordered thead,
.syntax-content .table thead {
  background: #f3f4f6;
}

.dark .syntax-content .table-bordered th,
.dark .syntax-content .table-bordered td,
.dark .syntax-content .table th,
.dark .syntax-content .table td {
  border-color: #374151;
  color: #e2e8f0;
}

.dark .syntax-content .table-bordered thead,
.dark .syntax-content .table thead {
  background: #1e293b !important;
}

/* =============================================
   mobile-app-badge (CTA do pobrania apki)
   ============================================= */

.syntax-content .mobile-app-badge {
  display: flex !important;
  flex-direction: column !important;
  align-items: start !important;
  border: 1px solid #3861E5 !important;
  border-radius: 8px !important;
  padding: 16px !important;
  gap: 12px !important;
  margin: 15px 0 !important;
  background: transparent !important;
}

@media (min-width: 600px) {
  .syntax-content .mobile-app-badge {
    flex-direction: row !important;
    align-items: center !important;
  }
}

.syntax-content .mobile-app-badge-content {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}

.syntax-content .mobile-app-badge-content-heading {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-weight: 600 !important;
  font-size: 18px !important;
  margin: 0 !important;
}

.syntax-content .mobile-app-badge-content-heading span {
  font-size: 18px !important;
  font-weight: 600 !important;
}

.syntax-content svg.mobile-app-icon {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  color: #2563eb !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
}

.syntax-content .mobile-app-badge-content p,
.syntax-content .mobile-app-badge-content div p {
  margin: 0 !important;
  color: #475569 !important;
  font-size: 0.95em !important;
}

.dark .syntax-content .mobile-app-badge {
  background: #0f172a !important;
  border-color: #3b82f6 !important;
}

.dark .syntax-content svg.mobile-app-icon {
  color: #60a5fa !important;
}

.dark .syntax-content .mobile-app-badge-content-heading span {
  color: #e2e8f0 !important;
}

.dark .syntax-content .mobile-app-badge-content p,
.dark .syntax-content .mobile-app-badge-content div p {
  color: #94a3b8 !important;
}

/* =============================================
   Dark mode — kolorowy tekst czytelność
   ============================================= */

.dark .syntax-content span[style*="color:#e74c3c"],
.dark .syntax-content span[style*="color: #e74c3c"] {
  color: #fca5a5 !important;
}

.dark .syntax-content span[style*="color:#27ae60"],
.dark .syntax-content span[style*="color: #27ae60"] {
  color: #86efac !important;
}

.dark .syntax-content span[style*="color:#2980b9"],
.dark .syntax-content span[style*="color: #2980b9"] {
  color: #93c5fd !important;
}

/* --- Tabele z kolorowym tłem (ZUS, #c9daf8) dark mode --- */
.dark .syntax-content td[style*="background:#c9daf8"],
.dark .syntax-content td[style*="background: #c9daf8"],
.dark .syntax-content td[style*="background: rgb(201, 218, 248)"],
.dark .syntax-content td[style*="background:rgb(201"] {
  background: #1e3a5f !important;
  color: #bfdbfe !important;
}

/* --- inv_to_pay (faktura dwuwalutowa) --- */
.syntax-content .inv_to_pay {
  font-weight: 600;
  padding: 4px 8px;
  background: #fef3c7;
  border-radius: 4px;
  display: inline-block;
}

.dark .syntax-content .inv_to_pay {
  background: #78350f;
  color: #fde68a;
}

/* =============================================
   SVG stroke fix (migracja)
   ============================================= */

html body .mb-4 > svg {
  stroke-width: 1;
}

/* =============================================
   Ukryj nazwiska operatorów w komentarzach
   ============================================= */

h3.font-medium.text-gray-900 {
  word-spacing: 100vw;
  overflow: hidden;
  height: 1.5em;
  line-height: 1.5em;
}

/* =============================================
   #entry-content.prose code (wspólne z _head.html.erb)
   ============================================= */

#entry-content.prose code {
  font-family: 'Courier New', monospace;
  line-height: 1.7;
  white-space: pre;
  overflow-x: auto;
  display: block;
  border-left: 4px solid #6366f1;
  background-color: #161616;
  padding: 16px 20px;
  font-size: 0.875rem;
  color: #fff;
  border-radius: 9px;
  max-width: 100%;
  font-weight: normal;
}

@media print {
  .kb-widget-tab,
  .kb-widget-overlay,
  .kb-widget-panel {
    display: none !important;
  }
}

/* =============================================
   Focus management (WCAG 2.4.7)
   ============================================= */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="combobox"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 2px;
}

.dark a:focus-visible,
.dark button:focus-visible,
.dark input:focus-visible,
.dark textarea:focus-visible,
.dark select:focus-visible {
  outline-color: #60a5fa;
}

/* =============================================
   Dark mode — formularze (@tailwindcss/forms)
   ============================================= */

.dark textarea,
.dark input[type="text"],
.dark input[type="email"],
.dark input[type="search"],
.dark select {
  background-color: #1f2937;
  border-color: #4b5563;
  color: #f3f4f6;
}

.dark textarea::placeholder,
.dark input::placeholder {
  color: #6b7280;
}

/* =============================================
   Dark mode — SVG z currentColor
   ============================================= */

.dark svg { color: #e5e7eb; }
.dark svg[stroke="currentColor"] { stroke: #e5e7eb !important; }
.dark .stroke-gray-900 { stroke: #e5e7eb !important; }
