/* components.css — przyciski, karty, tabele, tagi, modale, toasty, zakładki */

/* ---------- przyciski ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-strong);
  font: 600 13px var(--font); border-radius: var(--r-sm); padding: 9px 15px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  box-shadow: var(--sh-1);
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(0); box-shadow: var(--sh-1); }
.btn.primary {
  background: var(--grad-brand); border: none; color: #fff;
  box-shadow: 0 4px 14px rgba(27,63,230,.32);
}
.btn.primary:hover { box-shadow: 0 8px 22px rgba(27,63,230,.42); filter: brightness(1.04); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text-strong); background: var(--surface-3); box-shadow: none; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--surface); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.ghost.danger { border-color: transparent; }
.btn.ghost.danger:hover { background: var(--danger-bg); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: var(--r-xs); }
.btn.wide { width: 100%; justify-content: center; padding: 11px 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

/* ---------- karty ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 20px 22px; box-shadow: var(--sh-1);
  transition: box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}

/* ---------- tabele ---------- */
table.grid {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); overflow: hidden; box-shadow: var(--sh-1);
}
table.grid th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--muted); text-align: left; padding: 12px 13px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.grid td { padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr { transition: background var(--t-fast) var(--ease); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover { background: var(--info-bg); }
table.grid .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 650; color: var(--text-strong); }
.cell-sub { font-size: 11.5px; color: var(--muted); }
.inactive-row { opacity: .5; }
th.sortable { cursor: pointer; user-select: none; transition: color var(--t-fast); }
th.sortable:hover { color: var(--accent); }
th.sortable .arr { color: var(--accent); margin-left: 3px; }

/* ---------- tagi / statusy ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 650; border-radius: var(--r-pill);
  padding: 3px 10px; background: var(--surface-3); color: var(--muted);
  border: 1px solid transparent; line-height: 1.5;
}
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.tag.draft { background: var(--info-bg); color: var(--info); }
.tag.sent { background: var(--warn-bg); color: var(--warn); }
.tag.accepted { background: var(--ok-bg); color: var(--ok); }
.tag.rejected { background: var(--danger-bg); color: var(--danger); }
.tag.archived { background: var(--surface-3); color: var(--faint); }
.tag.mode-monthly { background: #E0F2FE; color: #0369A1; }
.tag.mode-oneTime { background: var(--surface-3); color: var(--muted); }
.tag.kind-product { background: var(--grad-brand-soft); color: var(--violet); }
.tag.kind-service { background: var(--info-bg); color: var(--info); }
.tag.tag-internal { background: var(--warn-bg); color: var(--warn); }
.tag.tag-internal::before, .tag.mode-oneTime::before { display: none; }
:root[data-theme="dark"] .tag.mode-monthly { background: rgba(3,105,161,.22); color: #7DD3FC; }

/* ---------- toasty ---------- */
#toast { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast-msg {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-left: 4px solid var(--ok); border-radius: var(--r-sm);
  padding: 12px 16px; box-shadow: var(--sh-3); font-size: 13px; font-weight: 500;
  max-width: 380px; animation: toast-in var(--t) var(--ease-out);
}
.toast-msg.error { border-left-color: var(--danger); }

/* ---------- modale ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(14,23,46,.5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 18px; overflow-y: auto; animation: fade-in var(--t-fast) var(--ease);
}
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 26px 28px; width: 720px; max-width: 100%;
  box-shadow: var(--sh-4); animation: pop-in var(--t) var(--ease-out);
}
/* szersze okno dla zawartości tabelarycznej (logi, rozbicie pozycji) */
.modal.wide { width: min(1060px, 96vw); }
.modal h2 { font-size: 19px; margin-bottom: 16px; }
.modal h3, .modal-sub { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 18px 0 8px; }
.modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.modal-actions .right { display: flex; gap: 8px; }
.confirm-num {
  display: inline-block; font-family: var(--font-mono); font-weight: 700; font-size: 17px;
  color: var(--danger); background: var(--danger-bg); padding: 7px 14px; border-radius: var(--r-sm);
  letter-spacing: .04em; user-select: all;
}

/* ---------- siatka formularzy w modalach ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; }
.form-grid label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-strong); }
.form-grid label input, .form-grid label select, .form-grid label textarea { width: 100%; margin-top: 5px; font-weight: 400; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label.check, label.check {
  display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--text);
  font-size: 12.5px; cursor: pointer; margin-top: 4px;
}
.form-grid label.check input, label.check input { width: auto; margin-top: 0; }
.group-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.group-checks label { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 12.5px; }

/* ---------- zakładki ---------- */
.tabs { display: flex; gap: 4px; padding: 5px; background: var(--surface-3); border-radius: var(--r-md); margin-bottom: 18px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tabs button {
  border: none; background: transparent; color: var(--muted); font: 600 13px var(--font);
  padding: 8px 15px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.tabs button:hover { color: var(--text-strong); }
.tabs button.active { background: var(--surface); color: var(--accent); box-shadow: var(--sh-1); }

/* nagłówki działów w modalu dostępu */
table.grid tr.acc-group td { background: var(--surface-3); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 7px 13px; }

/* ---------- grupowanie (użytkownicy) ---------- */
.group-head { display: flex; align-items: center; gap: 10px; font-size: 15px; margin: 22px 0 10px; }
.group-head .dash { width: 16px; height: 3px; border-radius: 2px; background: var(--grad-brand); }

/* ---------- skeleton loader ---------- */
.skel-wrap { display: flex; flex-direction: column; gap: 12px; }
.skel {
  position: relative; overflow: hidden; border-radius: var(--r-sm);
  background: var(--surface-3); height: 46px;
}
.skel::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
.skel.lg { height: 120px; }

/* ---------- spinner ---------- */
.spinner {
  width: 18px; height: 18px; border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block; vertical-align: -3px;
}

.margin-pos { color: var(--ok); font-weight: 650; }
.margin-neg { color: var(--danger); font-weight: 650; }

.svc-desc { font-size: 12.5px; color: var(--text); line-height: 1.55; }
.svc-desc p { margin: 3px 0; }
.svc-desc ul { margin: 3px 0 3px 18px; }
.svc-desc.preview { background: var(--surface-inset); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; }
