/* =====================================================
   Finanse Bez Owijania — Stitch Components (ETAP 1)
   Wspólne komponenty oparte na tokenach z stitch-tokens.css.
   Wzorce: stitch_finansebezowijania/<katalog>/code.html
   ("Deep Terminal" / developer-fintech).

   Klasy używają prefiksu .stitch- — dodawane równolegle do
   istniejącego UI; nie zmieniają ID/struktury DOM-owej.
   Mały glow zamiast cieni, monospace dla danych, ALL-CAPS
   etykiety (label-caps), 8px karty z 1px obramowaniem.
   ===================================================== */

/* --- KONTENER / LAYOUT --- */
.stitch-container {
  max-width: var(--stitch-container-max);
  margin: 0 auto;
  padding-left: var(--stitch-margin-mobile);
  padding-right: var(--stitch-margin-mobile);
}
@media (min-width: 768px) {
  .stitch-container {
    padding-left: var(--stitch-margin-desktop);
    padding-right: var(--stitch-margin-desktop);
  }
}

/* 12-kolumnowa siatka dashboardu */
.stitch-grid-12 { display: grid; grid-template-columns: 1fr; gap: var(--stitch-spacing-gutter); }
.stitch-col-8 { grid-column: span 1; }
.stitch-col-4 { grid-column: span 1; }
@media (min-width: 768px) {
  .stitch-grid-12 { grid-template-columns: repeat(12, 1fr); }
  .stitch-col-8 { grid-column: span 8; }
  .stitch-col-4 { grid-column: span 4; }
}

/* --- TYPOGRAFIA --- */
.stitch-h1 {
  font-family: var(--stitch-font-display);
  font-size: var(--stitch-font-display-xl);
  line-height: var(--stitch-font-display-xl-lh);
  letter-spacing: var(--stitch-font-display-xl-ls);
  font-weight: var(--stitch-font-display-xl-w);
  color: var(--stitch-on-surface);
  margin: 0;
}
.stitch-h2 {
  font-family: var(--stitch-font-display);
  font-size: var(--stitch-font-display-lg);
  line-height: var(--stitch-font-display-lg-lh);
  font-weight: var(--stitch-font-display-lg-w);
  color: var(--stitch-on-surface);
  margin: 0;
}
.stitch-h3 {
  font-family: var(--stitch-font-display);
  font-size: var(--stitch-font-display-md);
  line-height: var(--stitch-font-display-md-lh);
  font-weight: var(--stitch-font-display-md-w);
  color: var(--stitch-on-surface);
  margin: 0;
}
.stitch-body-lg {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-body-lg);
  line-height: var(--stitch-font-body-lg-lh);
  color: var(--stitch-on-surface-variant);
}
.stitch-body-md {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-body-md);
  line-height: var(--stitch-font-body-md-lh);
  color: var(--stitch-on-surface);
}
.stitch-label-caps {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-label-caps);
  line-height: var(--stitch-font-label-caps-lh);
  letter-spacing: var(--stitch-font-label-caps-ls);
  font-weight: var(--stitch-font-label-caps-w);
  text-transform: uppercase;
  color: var(--stitch-on-surface-variant);
}
.stitch-data-display {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-data-display);
  line-height: var(--stitch-font-data-display-lh);
  letter-spacing: var(--stitch-font-data-display-ls);
  font-weight: var(--stitch-font-data-display-w);
  color: var(--stitch-on-surface);
}

/* --- PRZYCISKI --- */
.stitch-btn {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-label-caps);
  font-weight: var(--stitch-font-label-caps-w);
  letter-spacing: var(--stitch-font-label-caps-ls);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--stitch-spacing-2);
  padding: var(--stitch-spacing-3) var(--stitch-spacing-2);
  border-radius: var(--stitch-radius-btn);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
  line-height: 1;
}
.stitch-btn:focus-visible { outline: 2px solid var(--stitch-primary); outline-offset: 2px; }

.stitch-btn-primary {
  background: var(--stitch-primary-container);
  color: var(--stitch-on-primary-container);
  font-weight: 700;
}
.stitch-btn-primary:hover {
  background: var(--stitch-primary-fixed);
  color: var(--stitch-on-primary-fixed);
}

.stitch-btn-secondary {
  background: transparent;
  border-color: var(--stitch-surface-light);
  color: var(--stitch-secondary);
  font-weight: 700;
}
.stitch-btn-secondary:hover { background: var(--stitch-surface-light); }

.stitch-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--stitch-on-surface-variant);
}
.stitch-btn-ghost:hover { background: var(--stitch-surface-bright); color: var(--stitch-on-surface); }

.stitch-btn-sm { padding: var(--stitch-spacing-1) var(--stitch-spacing-2); }
.stitch-btn-lg { padding: var(--stitch-spacing-3) var(--stitch-spacing-4); }

/* --- KARTY --- */
.stitch-card {
  background: var(--stitch-surface-deep);
  border: 1px solid var(--stitch-surface-light);
  border-radius: var(--stitch-radius-card);
  padding: var(--stitch-spacing-4);
}
.stitch-card-surface {
  background: var(--stitch-surface-container);
  border: 1px solid var(--stitch-surface-light);
  border-radius: var(--stitch-radius-card);
  padding: var(--stitch-spacing-4);
}
.stitch-card-terminal {
  background: var(--stitch-terminal-black);
  border: 1px solid var(--stitch-surface-light);
  border-radius: var(--stitch-radius-card);
  padding: var(--stitch-spacing-2);
}

/* Karta KPI: label-caps + data-display + cienki progress bar */
.stitch-kpi {
  background: var(--stitch-surface-deep);
  border: 1px solid var(--stitch-surface-light);
  border-radius: var(--stitch-radius-card);
  padding: var(--stitch-spacing-4);
  display: flex;
  flex-direction: column;
  gap: var(--stitch-spacing-2);
}
.stitch-kpi-label { order: 1; }
.stitch-kpi-value { font-size: var(--stitch-font-data-display); order: 2; }
.stitch-kpi-delta {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-body-md);
  display: inline-flex;
  align-items: center;
  gap: var(--stitch-spacing-1);
}

/* --- PROGRESS BAR (ostre, 2px, bez zaokrągleń) --- */
.stitch-bar-track {
  height: 2px;
  width: 100%;
  background: var(--stitch-surface-container);
  border-radius: 0;
  overflow: hidden;
}
.stitch-bar-fill {
  height: 100%;
  background: var(--stitch-primary-container);
  border-radius: 0;
}

/* --- INPUTY / FORMUŁARZE --- */
.stitch-input,
.stitch-select,
.stitch-textarea {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-body-md);
  color: var(--stitch-on-surface);
  background: var(--stitch-terminal-black);
  border: 1px solid var(--stitch-surface-light);
  border-radius: var(--stitch-radius-btn);
  padding: var(--stitch-spacing-2) var(--stitch-spacing-3);
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.stitch-input:focus,
.stitch-select:focus,
.stitch-textarea:focus {
  outline: none;
  border-color: var(--stitch-primary);
  box-shadow: 0 0 0 1px var(--stitch-primary-container);
}
.stitch-input::placeholder { color: var(--stitch-neutral-slate); }
.stitch-label {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-label-caps);
  font-weight: var(--stitch-font-label-caps-w);
  letter-spacing: var(--stitch-font-label-caps-ls);
  text-transform: uppercase;
  color: var(--stitch-on-surface-variant);
  display: block;
  margin-bottom: var(--stitch-spacing-2);
}

/* --- BADGE / PIGUŁKA --- */
.stitch-badge {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-label-caps);
  font-weight: var(--stitch-font-label-caps-w);
  letter-spacing: var(--stitch-font-label-caps-ls);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: var(--stitch-spacing-1);
  padding: var(--stitch-spacing-1) var(--stitch-spacing-2);
  border-radius: var(--stitch-radius-xl);
  border: 1px solid var(--stitch-outline-variant);
  color: var(--stitch-on-surface-variant);
  background: var(--stitch-surface-container);
  width: fit-content;
}
.stitch-badge-success { color: var(--stitch-success); border-color: var(--stitch-primary-container); }
.stitch-badge-danger { color: var(--stitch-danger); border-color: var(--stitch-danger); }
.stitch-badge-warning { color: var(--stitch-warning); border-color: var(--stitch-warning); }

/* Pigułka filtra (np. kategorie) */
.stitch-pill {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-label-caps);
  font-weight: 700;
  letter-spacing: var(--stitch-font-label-caps-ls);
  text-transform: uppercase;
  padding: var(--stitch-spacing-2) var(--stitch-spacing-3);
  border-radius: var(--stitch-radius-full);
  border: 1px solid var(--stitch-outline-variant);
  color: var(--stitch-on-surface-variant);
  background: transparent;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.stitch-pill:hover { border-color: var(--stitch-primary); color: var(--stitch-primary); }
.stitch-pill-active {
  border-color: var(--stitch-primary);
  background: rgba(136, 217, 130, 0.1);
  color: var(--stitch-primary);
}

/* --- WIERSZ LISTY (transakcji) --- */
.stitch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--stitch-spacing-3);
  padding: var(--stitch-spacing-2) var(--stitch-spacing-3);
  border-bottom: 1px solid var(--stitch-surface-light);
}
.stitch-row:hover { background: var(--stitch-surface-container-highest); }
.stitch-row-icon {
  width: 32px; height: 32px;
  border-radius: var(--stitch-radius-card);
  background: var(--stitch-surface-container);
  color: var(--stitch-neutral-slate);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* --- NAWIGACJA TOP (desktop) --- */
.stitch-topnav {
  display: none;
  background: var(--stitch-surface);
  border-bottom: 1px solid var(--stitch-outline-variant);
  position: sticky;
  top: 0;
  z-index: 50;
}
@media (min-width: 768px) { .stitch-topnav { display: block; } }
.stitch-topnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--stitch-spacing-4);
  height: var(--stitch-nav-height);
}
.stitch-topnav-left { display: flex; align-items: center; gap: var(--stitch-spacing-5); }
.stitch-topnav-brand {
  font-family: var(--stitch-font-display);
  font-size: var(--stitch-font-display-md);
  font-weight: 700;
  color: var(--stitch-on-surface);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--stitch-spacing-2);
}
.stitch-topnav-links { display: flex; align-items: center; gap: var(--stitch-spacing-4); }
.stitch-topnav-link {
  font-family: var(--stitch-font-body);
  font-size: var(--stitch-font-body-md);
  color: var(--stitch-on-surface-variant);
  text-decoration: none;
  transition: color .15s ease;
}
.stitch-topnav-link:hover { color: var(--stitch-primary); }
.stitch-topnav-link-active { color: var(--stitch-primary); font-weight: 700; }

/* --- NAWIGACJA BOTTOM (mobile) --- */
.stitch-bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: var(--stitch-spacing-2) var(--stitch-spacing-4);
  background: var(--stitch-surface-container);
  border-top: 1px solid var(--stitch-outline-variant);
  min-height: var(--stitch-bottom-nav-height);
  padding-bottom: calc(var(--stitch-spacing-2) + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 768px) { .stitch-bottomnav { display: none; } }
.stitch-bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--stitch-spacing-1);
  padding: var(--stitch-spacing-2);
  color: var(--stitch-on-surface-variant);
  text-decoration: none;
  min-width: 56px;
  min-height: 48px;
  border-radius: var(--stitch-radius-xl);
  transition: background-color .15s ease, color .15s ease;
}
.stitch-bn-item:hover { background: var(--stitch-surface-bright); }
.stitch-bn-item-active {
  background: var(--stitch-primary-container);
  color: var(--stitch-on-primary-container);
}
.stitch-bn-item span:last-child {
  font-family: var(--stitch-font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--stitch-font-label-caps-ls);
  text-transform: uppercase;
}
.stitch-bn-fab {
  width: 56px; height: 56px;
  border-radius: var(--stitch-radius-full);
  background: var(--stitch-primary);
  color: var(--stitch-on-primary);
  border: 2px solid var(--stitch-surface-container);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* --- IKONY (Material Symbols) --- */
.stitch-icon {
  font-family: 'Material Symbols Outlined';
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  line-height: 1;
  user-select: none;
}
.stitch-icon-fill { font-variation-settings: 'FILL' 1; }

/* Ikony wypełnione (wzorzec Stitch: filled-icon w nav/tabelach) */
.filled-icon { font-variation-settings: 'FILL' 1; }

/* --- GLOW / podświetlenie aktywnego CTA --- */
.stitch-glow:hover {
  box-shadow: var(--stitch-glow-primary);
  border-color: var(--stitch-primary);
}

/* --- STANY (loading/empty/error/offline) --- */
.stitch-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--stitch-spacing-2);
  padding: var(--stitch-spacing-5);
  text-align: center;
  color: var(--stitch-on-surface-variant);
}
.stitch-skeleton {
  background: var(--stitch-surface-container-high);
  border-radius: var(--stitch-radius-btn);
  animation: stitch-pulse 1.4s ease-in-out infinite;
}
@keyframes stitch-pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* --- MODALE --- */
.stitch-modal {
  background: var(--stitch-surface-deep);
  border: 1px solid var(--stitch-surface-light);
  border-radius: var(--stitch-radius-card);
  color: var(--stitch-on-surface);
  max-width: 560px;
  width: 100%;
}