/* ============================================================
   panel-theme.css — Mieszkania Silesia — wspólny motyw panelu
   Źródło prawdy dla tokenów i komponentów.
   Font self-hosted (RODO — bez zapytań do zewnętrznych CDN).
   ============================================================ */

/* ── Inter — latin ── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/inter-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/inter-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/inter-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/inter-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Inter — latin-ext (polskie znaki: ą ę ś ż ź ć ń ó ł) ── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/inter-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/inter-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/inter-latin-ext-600-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/inter-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* ── Marka ── */
  --accent:         #8B0000;
  --accent-hover:   #7a0000;
  --accent-active:  #660000;
  --accent-light:   #fdf4f4;
  --accent-text:    #ffffff;

  /* ── Tło i powierzchnie ── */
  --bg:             #faf9f7;
  --surface:        #ffffff;
  --surface-hover:  #f7f6f4;

  /* ── Neutralne (ciepłe, spójne z --bg) ── */
  --gray-50:        #faf9f7;
  --gray-100:       #f2f0ed;
  --gray-200:       #e6e3de;
  --gray-300:       #d4d0ca;
  --gray-400:       #a8a49d;
  --gray-500:       #7c7873;
  --gray-600:       #5c5955;
  --gray-700:       #423f3c;
  --gray-800:       #2b2927;
  --gray-900:       #1a1917;

  /* ── Tekst ── */
  --text:           #1a1917;
  --text-muted:     #5c5955;
  --text-subtle:    #7c7873;

  /* ── Statusy ── */
  --success:        #1a7a45;
  --success-light:  #f0faf4;
  --warning:        #b06f14;
  --warning-light:  #fff8ed;
  --danger:         #c0392b;
  --danger-light:   #fff5f5;
  --info:           #1565c0;
  --info-light:     #e8f0fd;

  /* ── Obramowania ── */
  --border:         #e6e3de;
  --border-strong:  #d4d0ca;

  /* ── Typografia ── */
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
  --text-xs:        12px;
  --text-sm:        13px;
  --text-base:      14px;
  --text-lg:        16px;
  --text-xl:        20px;
  --text-2xl:       24px;
  --leading-tight:  1.3;
  --leading:        1.55;

  /* ── Odstępy (skala 4-punktowa) ── */
  --space-1:        4px;
  --space-2:        8px;
  --space-3:        12px;
  --space-4:        16px;
  --space-5:        20px;
  --space-6:        24px;
  --space-7:        32px;
  --space-8:        48px;

  /* ── Zaokrąglenia ── */
  --radius-sm:      6px;
  --radius:         8px;
  --radius-lg:      12px;
  --radius-full:    999px;

  /* ── Cienie (dwuwarstwowe) ── */
  --shadow-sm:      0 1px 2px rgba(26,25,23,0.05);
  --shadow:         0 1px 2px rgba(26,25,23,0.04), 0 2px 8px rgba(26,25,23,0.06);
  --shadow-lg:      0 2px 4px rgba(26,25,23,0.04), 0 12px 32px rgba(26,25,23,0.10);

  /* ── Pierścień focus ── */
  --ring:           0 0 0 3px rgba(139,0,0,0.18);
}

/* ============================================================
   Style bazowe
   ============================================================ */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
}

/* ── Przyciski ── */
.theme-btn-primary,
.theme-btn-secondary,
.theme-btn-ghost,
.theme-btn-danger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius);
  padding: 9px var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.theme-btn-primary:focus-visible,
.theme-btn-secondary:focus-visible,
.theme-btn-ghost:focus-visible,
.theme-btn-danger:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.theme-btn-primary { background: var(--accent); color: var(--accent-text); }
.theme-btn-primary:hover { background: var(--accent-hover); }
.theme-btn-primary:active { background: var(--accent-active); }
.theme-btn-primary:disabled {
  background: var(--gray-200); color: var(--gray-500); cursor: not-allowed;
}

.theme-btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.theme-btn-secondary:hover { background: var(--surface-hover); border-color: var(--gray-400); }
.theme-btn-secondary:active { background: var(--gray-100); }
.theme-btn-secondary:disabled {
  background: var(--gray-100); color: var(--gray-400);
  border-color: var(--border); cursor: not-allowed;
}

.theme-btn-ghost { background: none; color: var(--text-muted); }
.theme-btn-ghost:hover { background: var(--gray-100); color: var(--text); }
.theme-btn-ghost:disabled { color: var(--gray-400); cursor: not-allowed; }

.theme-btn-danger { background: var(--danger); color: #fff; }
.theme-btn-danger:hover { background: #a93226; }
.theme-btn-danger:disabled {
  background: var(--gray-200); color: var(--gray-500); cursor: not-allowed;
}

.theme-btn-sm { padding: 6px var(--space-3); font-size: var(--text-xs); }

/* ── Karty ── */
.theme-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.theme-card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.theme-card-body { padding: var(--space-5); }
/* Karta trzymająca treść bezpośrednio (bez osobnego -body).
   Global Constraints zabraniają dodawania wrappera DOM, więc padding
   dokłada modyfikator, nie zagnieżdżony element. */
.theme-card-pad { padding: var(--space-6); }

/* ── Tabele ── */
.theme-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--surface);
}
.theme-table th {
  background: var(--gray-100);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.theme-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.theme-table tbody tr:last-child td { border-bottom: none; }
.theme-table tbody tr { transition: background .12s; }
.theme-table tbody tr:hover { background: var(--surface-hover); }

/* Kwoty i liczby — do prawej, cyfry o równej szerokości */
.theme-table .theme-num,
.theme-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Zgodność wsteczna — stara klasa nagłówka tabeli */
.theme-table-header {
  background: var(--gray-100);
}

/* ── Formularze ── */
.theme-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.theme-input,
.theme-select {
  width: 100%;
  box-sizing: border-box;
  padding: 9px var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.theme-input::placeholder { color: var(--gray-400); }
.theme-input:hover,
.theme-select:hover { border-color: var(--gray-400); }
.theme-input:focus-visible,
.theme-select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.theme-input:disabled,
.theme-select:disabled {
  background: var(--gray-100); color: var(--gray-500); cursor: not-allowed;
}
.theme-input.theme-invalid,
.theme-select.theme-invalid { border-color: var(--danger); }
.theme-field-error {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--danger);
}

/* ── Badge statusów ── */
.theme-badge-success,
.theme-badge-warning,
.theme-badge-danger,
.theme-badge-info,
.theme-badge-neutral {
  display: inline-block;
  padding: 3px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.theme-badge-success { background: var(--success-light); color: var(--success); }
.theme-badge-warning { background: var(--warning-light); color: var(--warning); }
.theme-badge-danger  { background: var(--danger-light);  color: var(--danger); }
.theme-badge-info    { background: var(--info-light);    color: var(--info); }
.theme-badge-neutral { background: var(--gray-100);      color: var(--text-muted); }

/* ── Nagłówek modala (klasa istniejąca; bordo schodzi z płaszczyzny) ── */
.theme-modal-header {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.theme-modal-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

/* ── Nawigacja ── */
.theme-navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.theme-navbar-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px var(--space-3);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.theme-navbar-back:hover {
  background: var(--surface-hover);
  border-color: var(--gray-400);
  color: var(--text);
}
.theme-navbar-back:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── Stany puste i ładowanie ── */
.theme-empty {
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--text-subtle);
  font-size: var(--text-sm);
}
.theme-loading {
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--text-subtle);
  font-size: var(--text-sm);
}

/* ============================================================
   Ujednolicony modal instrukcji (help-modal.js)
   Jedno źródło rozmiaru dla wszystkich modułów panelu.
   Dedykowane nazwy klas `help-modal-*` aby nie kolidować
   z modalami danych w poszczególnych modułach.
   ============================================================ */
.help-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 9000; display: none; align-items: center; justify-content: center; padding: 24px;
}
.help-modal-overlay.open { display: flex; }
.help-modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 1000px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.1);
  display: flex; flex-direction: column;
}
.help-modal-box::-webkit-scrollbar { width: 6px; }
.help-modal-box::-webkit-scrollbar-track { background: var(--gray-100); border-radius: 0 16px 16px 0; }
.help-modal-box::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 6px; }
.help-modal-box::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

.help-header {
  background: var(--surface); border-bottom: 1px solid var(--border); border-radius: 16px 16px 0 0; padding: 20px 24px;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0; position: sticky; top: 0; z-index: 1;
}
.help-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.help-header-actions { display: flex; gap: 10px; align-items: center; }
.help-btn-pdf {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 6px var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 600;
  background: var(--surface); color: var(--text); text-decoration: none;
  border: 1px solid var(--border-strong);
  transition: background .15s, border-color .15s; white-space: nowrap;
}
.help-btn-pdf:hover { background: var(--surface-hover); border-color: var(--gray-400); }
.help-btn-pdf:focus-visible { outline: none; box-shadow: var(--ring); }
.help-btn-close {
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: none;
  background: none; color: var(--text-muted); font-size: 18px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s; flex-shrink: 0;
}
.help-btn-close:hover { background: var(--gray-100); color: var(--text); }
.help-btn-close:focus-visible { outline: none; box-shadow: var(--ring); }

.help-body { padding: 24px; }
.help-loading { padding: 48px 24px; text-align: center; color: var(--text-muted); font-size: 14px; }
.help-section {
  margin-bottom: 16px; border-left: 3px solid var(--accent); background: var(--accent-light);
  border-radius: 0 10px 10px 0; padding: 14px 16px;
}
.help-section:last-child { margin-bottom: 0; }
.help-section-title {
  font-weight: 700; font-size: 12px; color: var(--accent); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.help-status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; line-height: 1.5; }
.help-status-row:last-child { margin-bottom: 0; }
.help-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(0,0,0,0.08); }
.help-list { list-style: none; padding: 0; margin: 4px 0; font-size: 13px; line-height: 1.7; }
.help-list li { padding: 4px 0 4px 22px; position: relative; color: #2a2a2a; }
.help-list li::before { content: "→"; position: absolute; left: 0; color: var(--accent); font-weight: 700; font-size: 12px; top: 5px; }
ol.help-list { list-style: none; counter-reset: help-counter; }
ol.help-list li { counter-increment: help-counter; padding-left: 28px; }
ol.help-list li::before {
  content: counter(help-counter); background: var(--accent); color: #fff; border-radius: 50%;
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; top: 4px;
}
.help-section p { font-size: 13px; margin: 6px 0; line-height: 1.65; color: #2a2a2a; }
.help-section p:first-child { margin-top: 0; }
.help-section p:last-child { margin-bottom: 0; }
.help-section strong { color: #1a1a1a; }
.help-section h4 { font-size: 13px; font-weight: 700; color: #333; margin: 12px 0 6px; }
.help-section h4:first-child { margin-top: 0; }

/* Tabele wewnątrz instrukcji */
.help-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.help-body th { background: var(--gray-100); padding: 7px 10px; text-align: left; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.help-body td { padding: 7px 10px; border-bottom: 1px solid var(--border); color: #444; vertical-align: top; }

/* Wskazówka / tip */
.help-tip { background: #fff8f0; border-left: 3px solid #f59e0b; padding: 10px 14px; border-radius: 4px; margin: 12px 0; font-size: 12px; color: #555; }
.help-tip strong { color: #b45309; }

/* Małe badge w treści instrukcji */
.help-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; margin: 0 2px; }
.help-badge.purple { background: var(--info-light); color: var(--info); }
.help-badge.green  { background: var(--success-light); color: var(--success); }
.help-badge.yellow { background: var(--warning-light); color: var(--warning); }
.help-badge.red    { background: var(--danger-light); color: var(--danger); }

@media (max-width: 640px) {
  .help-modal-overlay { padding: 10px; }
  .help-modal-box { max-height: 92vh; }
  .help-header { padding: 16px 18px; }
  .help-header h3 { font-size: 14px; }
  .help-body { padding: 18px; }
}
