/* ═══════════════════════════════════════════════════════
   SYSTEM REKLAMACJI — Główny arkusz stylów
   Motyw: Przemysłowy / Precyzyjny / Profesjonalny
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --c-bg:          #F5F4F1;
  --c-surface:     #FFFFFF;
  --c-surface-2:   #F0EEE9;
  --c-border:      #D8D5CE;
  --c-border-2:    #C4C0B8;

  --c-text:        #1A1917;
  --c-text-muted:  #6B6860;
  --c-text-light:  #9B9890;

  --c-accent:      #1A3A5C;
  --c-accent-2:    #24527F;
  --c-accent-light:#E8EFF6;

  --c-nowa:        #1A3A5C;
  --c-wtoku:       #7A4F00;
  --c-oczekuje:    #005566;
  --c-zamknieta:   #1A4A2A;
  --c-odrzucona:   #5C1A1A;

  --c-nowa-bg:     #E8EFF6;
  --c-wtoku-bg:    #FFF5D6;
  --c-oczekuje-bg: #D6F5F9;
  --c-zamknieta-bg:#D6F0DC;
  --c-odrzucona-bg:#F6E8E8;

  --font-sans: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--c-accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--c-accent);
  color: #CBD8E6;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 8px;
}
.sidebar-brand-name {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.3;
}
.sidebar-brand-sub {
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.nav-section {
  padding: 6px 12px 2px;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  margin-top: 8px;
}

.nav-item { display: block; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  font-weight: 400;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: #fff; }
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .8rem;
  color: rgba(255,255,255,.45);
}
.sidebar-footer a { color: rgba(255,255,255,.6); }
.sidebar-footer a:hover { color: #fff; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 500; color: var(--c-text); flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-content { padding: 28px; flex: 1; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: .9rem; font-weight: 600; color: var(--c-text); }
.card-body { padding: 20px; }

/* ── Stat Cards (Dashboard) ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.s-total::before  { background: var(--c-accent); }
.stat-card.s-nowa::before   { background: var(--c-nowa); }
.stat-card.s-wtoku::before  { background: #C88A00; }
.stat-card.s-ok::before     { background: #1A6A32; }
.stat-card.s-rej::before    { background: #8C1A1A; }

.stat-label { font-size: .72rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--c-text-muted); margin-bottom: 8px; }
.stat-value { font-size: 2.2rem; font-weight: 300; color: var(--c-text); font-family: var(--font-mono); line-height: 1; }

/* ── Badges / Status ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }

.badge-nowa      { background: var(--c-nowa-bg);      color: var(--c-nowa); }
.badge-w_toku    { background: var(--c-wtoku-bg);     color: var(--c-wtoku); }
.badge-oczekuje  { background: var(--c-oczekuje-bg);  color: var(--c-oczekuje); }
.badge-zamknieta { background: var(--c-zamknieta-bg); color: var(--c-zamknieta); }
.badge-odrzucona { background: var(--c-odrzucona-bg); color: var(--c-odrzucona); }

/* Wynik pozycji */
.badge-zasadna_wymiana { background: #D6F0DC; color: #1A4A2A; }
.badge-zasadna_naprawa { background: #D6F5F9; color: #005566; }
.badge-bezzasadna      { background: #F6E8E8; color: #5C1A1A; }
.badge-w_trakcie       { background: #FFF5D6; color: #7A4F00; }
.badge-empty           { background: var(--c-surface-2); color: var(--c-text-muted); }

/* ── Tabela ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--c-surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--c-accent-light); }
tbody tr:last-child td { border-bottom: none; }

.nr-rek {
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 500;
  color: var(--c-accent-2);
}

/* ── Przyciski ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.btn-primary:hover { background: var(--c-accent-2); border-color: var(--c-accent-2); color: #fff; text-decoration: none; }

.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-2); }
.btn-secondary:hover { background: var(--c-surface-2); text-decoration: none; }

.btn-danger { background: #5C1A1A; color: #fff; border-color: #5C1A1A; }
.btn-danger:hover { background: #7A2020; color: #fff; text-decoration: none; }

.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-icon { padding: 6px; }

/* ── Formularze ───────────────────────────────────────── */
.form-label { font-size: .82rem; font-weight: 500; color: var(--c-text); margin-bottom: 4px; }

.form-control, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: .875rem;
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--c-accent-2);
  box-shadow: 0 0 0 3px rgba(26,90,140,.12);
}

textarea.form-control { resize: vertical; min-height: 90px; }

fieldset.border {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--radius-lg);
  padding: 16px 20px !important;
  margin-bottom: 20px;
}
legend.w-auto { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-muted); padding: 0 8px; }

/* ── Formset (pozycje) ────────────────────────────────── */
.pozycja-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
}
.pozycja-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border);
}
.pozycja-nr { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-muted); }

/* ── Filtry ───────────────────────────────────────────── */
.filter-bar {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-muted); }
.filter-group .form-control,
.filter-group .form-select { min-width: 160px; }
.filter-group.flex-1 { flex: 1; min-width: 200px; }

/* ── Alerts / Messages ────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
  border-left: 3px solid currentColor;
}
.alert-success { background: var(--c-zamknieta-bg); color: var(--c-zamknieta); }
.alert-error,
.alert-danger  { background: var(--c-odrzucona-bg); color: var(--c-odrzucona); }
.alert-warning { background: var(--c-wtoku-bg); color: var(--c-wtoku); }
.alert-info    { background: var(--c-accent-light); color: var(--c-accent); }

/* ── Pagination ───────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-link {
  padding: 6px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .82rem;
  color: var(--c-text);
  background: var(--c-surface);
  transition: all .15s;
}
.page-link:hover { background: var(--c-accent-light); border-color: var(--c-accent-2); color: var(--c-accent-2); text-decoration: none; }
.page-link.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── Historia zmian ───────────────────────────────────── */
.history-list { list-style: none; }
.history-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: .82rem;
}
.history-item:last-child { border-bottom: none; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-border-2); flex-shrink: 0; margin-top: 5px; }
.history-time { color: var(--c-text-muted); font-family: var(--font-mono); font-size: .75rem; white-space: nowrap; }

/* ── Szczegóły reklamacji ─────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-row { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: .7rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--c-text-muted); }
.detail-value { font-size: .9rem; color: var(--c-text); }
.detail-mono  { font-family: var(--font-mono); font-size: .85rem; }

/* ── Login ────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
}
.login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 360px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: 8px;
}
.login-title { font-size: 1.4rem; font-weight: 300; color: var(--c-text); margin-bottom: 28px; }

/* ── Utils ────────────────────────────────────────────── */
.text-muted { color: var(--c-text-muted); }
.text-mono  { font-family: var(--font-mono); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .col-4, .col-6, .col-8 { grid-column: span 12; }
}
