/* Design tokens Estate Checker — złoty brand + czarne/grafitowe powierzchnie. */

:root {
  color-scheme: light;
  --brand: 36.8 69.6% 66.5%; /* #e5b76e */
  --brand-foreground: 240 10% 3.9%;
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --primary: var(--brand);
  --primary-foreground: var(--brand-foreground);
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 36.8 58% 46%;
  --radius: 0.5rem;
}

.dark {
  color-scheme: dark;
  /* Ciemny tryb zachowuje czarne/grafitowe warstwy, a złoty brand prowadzi
     akcje, fokus i elementy identyfikacji. Kolory statusów pozostają osobne. */
  --background: 240 6% 4%;
  --foreground: 0 0% 96%;
  --card: 240 5% 7.5%;
  --card-foreground: 0 0% 96%;
  --primary: var(--brand);
  --primary-foreground: var(--brand-foreground);
  --secondary: 240 4% 12%;
  --secondary-foreground: 0 0% 96%;
  --muted: 240 4% 11%;
  --muted-foreground: 240 5% 65%;
  --accent: 240 4% 14%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62% 55%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 4% 15%;
  --input: 240 4% 16%;
  --ring: 36.8 69.6% 66.5%;
}

::selection {
  background: hsl(var(--primary) / 0.15);
}

/* delikatny scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}

/* Ledwo wyczuwalny złoty blask u góry tła w trybie ciemnym — głębia bez
   kolorowej plamy na całej powierzchni. */
.dark body {
  background-image: radial-gradient(1400px 520px at 50% -160px, hsl(var(--brand) / 0.1), transparent 70%);
}

/* Autorski znak marki: jednolity złoty kolor zachowuje czytelność logo
   na czarnej oprawie niezależnie od tła i trybu motywu. */
.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(77%) sepia(28%) saturate(800%)
          hue-rotate(359deg) brightness(96%) contrast(90%);
}

/* karty: delikatne podświetlenie krawędzi przy najechaniu */
.card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: hsl(var(--ring) / 0.45);
}
.dark .card:hover {
  border-color: hsl(0 0% 100% / 0.16);
}

/* Auth ma własny język wizualny Estate Checker: neutralna powierzchnia,
   złoty akcent i delikatna siatka kojarząca się z monitorowaniem danych. */
.auth-shell {
  background-color: hsl(var(--background));
  background-image: radial-gradient(700px 360px at 50% -180px,
    hsl(var(--brand) / 0.08), transparent 72%);
}
.auth-grid {
  background-image: linear-gradient(hsl(var(--border) / 0.32) 1px, transparent 1px),
                    linear-gradient(90deg, hsl(var(--border) / 0.32) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 76%);
}
.dark .auth-grid {
  opacity: 0.3;
}

/* Tabele paneli organizacji nie mogą rozszerzać karty przez długie adresy
   e-mail ani tokeny zaproszeń. Na telefonie tabela pozostaje przewijalna,
   zamiast ściskać kolumny do nieczytelnego rozmiaru. */
.org-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.org-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.org-table th,
.org-table td {
  min-width: 0;
}
.org-table td {
  overflow-wrap: anywhere;
}
.org-members-table {
  min-width: 620px;
}
.org-invitations-table {
  min-width: 640px;
}
.org-invitations-table .invite-email-col { width: 31%; }
.org-invitations-table .invite-role-col { width: 9%; }
.org-invitations-table .invite-status-col { width: 18%; }
.org-invitations-table .invite-link-col { width: 32%; }
.org-invitations-table .invite-actions-col { width: 10%; }
.org-invite-code {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

@media (max-width: 639px) {
  .org-members-table,
  .org-invitations-table {
    min-width: 600px;
  }
}

/*Stan "obejrzane": wyraźne przygaszenie całej karty i odszarzenie miniatury.
 Klasa doklejana przez HTMX po kliknięciu — celowo w statycznym CSS (a nie
 w klasie Tailwind), żeby działała od razu bez oczekiwania na JIT Play CDN.*/
article.seen-dim {
  opacity: 0.55;
}
article.seen-dim img {
  filter: grayscale(0.75);
}
article.seen-dim:hover {
  opacity: 0.85;
}
/* wyłączone przygaszanie (ustawienie „Przygaszaj obejrzane", /settings) */
body.no-seen-dim article.seen-dim,
body.no-seen-dim article.seen-dim:hover {
  opacity: 1;
}
body.no-seen-dim article.seen-dim img {
  filter: none;
}

/* Status „nowa”: zielona ramka analogiczna do oznaczenia ulubionej oferty.
   Klasa jest statyczna, więc działa również po podmianie karty przez HTMX. */
article.new-offer {
  background-color: hsl(var(--card));
  box-shadow: 0 0 0 2px hsl(142 65% 42% / 0.68);
}
.dark article.new-offer {
  background-color: hsl(var(--card));
  box-shadow: 0 0 0 1px hsl(142 55% 45% / 0.58);
}

/* Przełącznik segmentowy (typ / sprzedający / okres publikacji).
   Radiokamery ukryte pod pillami — klik zmienia wartość, a zdarzenie change
   bąbelkuje do formularza i odpala auto-submit HTMX-owi. */
.seg {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  height: 40px;
  padding: 3px;
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: var(--radius);
  background: hsl(var(--muted) / 0.5);
}
.seg label {
  position: relative;
  display: inline-flex;
}
.seg input[type="radio"] {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.seg span {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.seg label:hover span {
  color: hsl(var(--foreground));
}
.seg input:checked + span {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}
.dark .seg input:checked + span {
  background: hsl(240 5% 18%);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
}
.seg input:focus-visible + span {
  outline: 2px solid hsl(var(--ring) / 0.5);
  outline-offset: 1px;
}

/* Zakładki widoku (Do sprawdzenia / Obejrzane / …) — linki w tej samej
   obudowie co .seg; aktywna zakładka zaznacza się jak wciśnięty segment. */
.seg a {
  position: relative;
  display: inline-flex;
  text-decoration: none;
}
.seg a:hover span {
  color: hsl(var(--foreground));
}
.seg input:checked + span,
.seg a.is-on span {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}
.dark .seg input:checked + span,
.dark .seg a.is-on span {
  background: hsl(240 5% 18%);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
}
.tab-count {
  font-style: normal;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.07);
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}
.seg a.is-on .tab-count {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--foreground));
}

/* Menu wielokrotnego wyboru („Kategorie” w filtrach) — natywny <details>/
   <summary> wystylowany jak pole formularza (własne style zamiast .input,
   które ma w-full i rozciągałoby przycisk w wierszu filtra). */
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  min-width: 168px;
  padding: 0 12px;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--foreground));
  white-space: nowrap;
  user-select: none;
  list-style: none;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.menu-btn::-webkit-details-marker,
.menu-btn::marker {
  display: none;
  content: "";
}
details[data-menu][open] > .menu-btn {
  border-color: hsl(var(--ring) / 0.6);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
details[data-menu][open] > .menu-btn svg {
  transform: rotate(180deg);
}

/* Chip kategorii (ROD, kamienica, …) na karcie i w wierszu listy —
   statyczna klasa, bo treść kart podmienia HTMX i Play CDN może nie
   zdążyć skompilować świeżych klas Tailwinda. */
.cat-chip {
  padding: 1px 7px;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.07);
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

/* Grupa zakresu „od – do" (cena, metraż): jedna obwódka, etykieta
   i jednostka wbudowane w pole — zamiast dwóch luźnych inputów. */
.range {
  display: inline-flex;
  align-items: center;
  height: 40px;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: transparent;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.range:focus-within {
  border-color: hsl(var(--ring) / 0.6);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
.range-label {
  padding-left: 12px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.range input {
  flex: 1 1 40px;
  width: auto;
  min-width: 0;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0 6px;
  text-align: center;
  font-size: 13px;
  color: hsl(var(--foreground));
  outline: none;
}
.range input::placeholder {
  color: hsl(var(--muted-foreground) / 0.7);
  font-size: 12px;
}
.range-dash {
  color: hsl(var(--muted-foreground) / 0.6);
  font-size: 12px;
}
.range-unit {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding: 0 12px 0 10px;
  margin-left: 2px;
  border-left: 1px solid hsl(var(--border) / 0.6);
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

/* Przełącznik on/off (/settings): checkbox ukryty pod pigułką z suwakiem. */
.switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: hsl(var(--muted-foreground) / 0.35);
  transition: background-color 0.15s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  transition: transform 0.15s ease;
}
.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch:has(input:checked) {
  background: hsl(var(--primary));
}
.switch:has(input:checked)::after {
  transform: translateX(18px);
}
/* w dark primary jest biały — gałka musiałaby zniknąć na białym torze */
.dark .switch:has(input:checked)::after {
  background: hsl(var(--primary-foreground));
}
.switch:has(input:focus-visible) {
  outline: 2px solid hsl(var(--ring) / 0.5);
  outline-offset: 2px;
}
