/* Atut CRM: ekrany bramy (logowanie, rejestracja, reset hasła, zaproszenia, wybór organizacji, komunikaty).
 *
 * Układ jak w logowaniu Google: duża zaokrąglona karta; po lewej logo, duży tytuł i jedno zdanie, po prawej treść
 * (pola, lista kont, ilustracja) i przyciski. Na telefonie kolumny układają się jedna pod drugą.
 * Wyłącznie tokeny Aurora + paleta Atut (atut-palette.css).
 * Ekrany bramy są ZAWSZE w jasnym motywie (wymaganie produktu), niezależnie od ustawień systemu i motywu wybranego w aplikacji:
 * strony z serwera mają <html data-theme="light">, ekrany budowane w JS wywołują forceLight() (js/gate.js).
 * Ładowany po connect-ds.css, atut-palette.css i crm.css. Kod HTML: js/gate.js (ekrany w JS) i crm_gate_page() w bootstrap.php.
 */

.ag { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg-subtle); }
.ag-wrap { width: 100%; max-width: 1040px; }
.ag-card {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 56px; row-gap: 24px;
  min-height: 420px; padding: 44px 48px 40px; background: var(--surface); border-radius: var(--r-2xl);
  animation: ag-in .32s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes ag-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* lewa kolumna */
.ag-left { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.ag-logo .lk { height: 44px; width: auto; display: block; }
.ag-title { margin: 32px 0 14px; font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem); font-weight: 400; line-height: 1.15; letter-spacing: -.02em; color: var(--text); overflow-wrap: anywhere; }
.ag-sub { margin: 0; font-size: var(--fs-md); line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }
.ag-sub + .ag-sub { margin-top: 10px; color: var(--text-2); font-size: var(--fs-base); }
.ag-chip { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; margin-top: 22px; padding: 4px 16px 4px 4px; border: 1px solid var(--border); border-radius: var(--r-full); font-size: var(--fs-sm); color: var(--text); }
.ag-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* prawa kolumna */
/* pola zaczynają się na wysokości tytułu po lewej (logo 44 px + odstęp 32 px), jak w logowaniu Google */
.ag-right { display: flex; flex-direction: column; min-width: 0; padding-top: 76px; }
.ag-body { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.ag-form { display: flex; flex-direction: column; margin: 0; }
.ag-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; }
.ag-actions.end { justify-content: flex-end; }
.ag-actions.push { margin-top: auto; padding-top: 24px; }

/* pola z pływającą etykietą */
.ag .ag-field { position: relative; margin: 0 0 18px; }
.ag .ag-field input {
  display: block; width: 100%; height: 56px; min-height: 56px; padding: 23px 16px 7px; font-size: var(--fs-md); line-height: 1.2;
  color: var(--text); background: transparent; border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: none;
  transition: border-color .12s, box-shadow .12s;
}
.ag .ag-field.has-eye input { padding-right: 52px; }
.ag .ag-field input:hover { border-color: var(--text-2); }
.ag .ag-field input:focus { outline: none; border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.ag .ag-field input[readonly] { color: var(--text-2); cursor: default; }
.ag .ag-field label {
  position: absolute; left: 17px; top: 18px; max-width: calc(100% - 34px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-md); line-height: 1.2; color: var(--text-2); pointer-events: none; transition: top .14s, font-size .14s, color .14s;
}
.ag .ag-field input:focus + label,
.ag .ag-field input:not(:placeholder-shown) + label,
.ag .ag-field input:-webkit-autofill + label { top: 8px; font-size: var(--fs-xs); }
.ag .ag-field input:focus + label { color: var(--brand); }
.ag .ag-field.has-err input { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.ag .ag-field.has-err input + label { color: var(--danger); }
.ag-fhint { margin: 6px 4px 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2); }
.ag-ferr { display: none; align-items: flex-start; gap: 6px; margin: 6px 4px 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--danger); }
.ag-ferr::before {
  content: ""; flex: none; width: 16px; height: 16px; margin-top: 1px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7.5v5.5M12 16h.01' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7.5v5.5M12 16h.01' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ag-field.has-err .ag-ferr, .ag-ferr.show { display: flex; }
.ag-eye { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); }
.ag-eye:hover { background: var(--surface-2); color: var(--text); }
.ag-eye:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.ag-eye .ic { width: 20px; height: 20px; }
.ag-eye .ic:last-child { display: none; }
.ag-eye[aria-pressed="true"] .ic:first-child { display: none; }
.ag-eye[aria-pressed="true"] .ic:last-child { display: block; }
.ag-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

/* przyciski i odnośniki */
.ag-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 40px; padding: 0 24px; border: 1px solid transparent; border-radius: var(--r-full);
  font-size: var(--fs-base); font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background .12s, box-shadow .12s, border-color .12s, opacity .12s;
}
.ag-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.ag-btn.pri { background: var(--brand); color: var(--brand-on); }
.ag-btn.pri:hover { background: var(--brand-hover); box-shadow: var(--elev-1); }
.ag-btn.txt { margin-left: -12px; padding: 0 12px; background: none; color: var(--brand); }
.ag-btn.txt:hover { background: var(--brand-soft); }
.ag-btn.out { width: 100%; height: 48px; background: transparent; border-color: var(--border-strong); color: var(--text); }
.ag-btn.out:hover { background: var(--surface-2); }
.ag-btn.out img, .ag-btn.out .ic { width: 22px; height: 22px; }
.ag-btn.wide { width: 100%; }
.ag-btn:disabled, .ag-btn.busy { opacity: .6; pointer-events: none; }
.ag-btn.busy::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: ag-spin .7s linear infinite; }
@keyframes ag-spin { to { transform: rotate(360deg); } }
.ag-link { display: inline-block; padding: 4px 0; background: none; border: 0; font-size: var(--fs-sm); font-weight: 500; color: var(--brand); text-decoration: none; cursor: pointer; }
.ag-link:hover { text-decoration: underline; }
.ag-link:focus-visible { outline: none; border-radius: 4px; box-shadow: 0 0 0 3px var(--brand-ring); }
/* wiersz pod hasłem: „Zapamiętaj mnie” po lewej, „Nie pamiętasz hasła?” po prawej (na wąskim ekranie jeden pod drugim) */
.ag-optrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; margin: -4px 0 0; }
.ag .ag-optrow .ag-check { margin: 0; }
.ag-optrow .ag-check-wrap { margin: 0; }
.ag-or { display: flex; align-items: center; gap: 14px; margin: 24px 0 18px; font-size: var(--fs-sm); color: var(--text-3); }
.ag-or::before, .ag-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* pole wyboru (regulamin) */
.ag .ag-check { display: flex; align-items: flex-start; gap: 12px; margin: 2px 0 6px; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-2); cursor: pointer; }
.ag .ag-check input {
  appearance: none; -webkit-appearance: none; flex: none; display: grid; place-content: center; width: 20px; height: 20px; min-height: 20px; margin: 1px 0 0; padding: 0;
  border: 2px solid var(--border-strong); border-radius: 5px; background: transparent; cursor: pointer; transition: background .12s, border-color .12s;
}
.ag .ag-check input:checked { background: var(--brand); border-color: var(--brand); }
.ag .ag-check input:checked::after { content: ""; width: 9px; height: 5px; margin-top: -2px; border-left: 2px solid var(--brand-on); border-bottom: 2px solid var(--brand-on); transform: rotate(-45deg); }
.ag .ag-check input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.ag .ag-check a { color: var(--brand); font-weight: 500; }
.ag-check-wrap.has-err .ag-check input { border-color: var(--danger); }
.ag-check-wrap .ag-ferr { margin-left: 32px; }
.ag-check-wrap.has-err .ag-ferr { display: flex; }

/* komunikaty w prawej kolumnie */
.ag-note { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 18px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--success-border); background: var(--success-bg); font-size: var(--fs-sm); line-height: 1.45; color: var(--text); }
.ag-note .ic { width: 18px; height: 18px; margin-top: 1px; color: var(--success); }
.ag-note.warn { border-color: var(--warning-border); background: var(--warning-bg); }
.ag-note.warn .ic { color: var(--warning); }
.ag-note.err { border-color: var(--danger-border); background: var(--danger-bg); }
.ag-note.err .ic { color: var(--danger); }
.ag-formerr { margin: -6px 0 14px; font-size: var(--fs-sm); line-height: 1.45; color: var(--danger); }
.ag-formerr:empty { display: none; }
.ag-small { margin: 14px 0 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-2); }

/* ilustracja (komunikaty, skrzynka e-mail) */
.ag-illus { display: grid; place-items: center; width: 136px; height: 136px; margin: auto; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.ag-illus .ic { width: 58px; height: 58px; stroke-width: 1.4; }
.ag-illus.danger { background: var(--danger-bg); color: var(--danger); }
.ag-illus.warn { background: var(--warning-bg); color: var(--warning); }
.ag-illus.ok { background: var(--success-bg); color: var(--success); }
.ag-center { flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 8px 0; }
.ag-center p { margin: 0; max-width: 34ch; font-size: var(--fs-base); line-height: 1.5; color: var(--text-2); }

/* lista (wybór organizacji) */
.ag-list { margin: 0 -12px; border-top: 1px solid var(--border); }
.ag-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background: none; color: var(--text); text-align: left; text-decoration: none; cursor: pointer; transition: background .12s;
}
.ag-row:hover { background: var(--surface-2); }
.ag-row:focus-visible { outline: none; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--brand-ring); }
.ag-row b { display: block; font-size: var(--fs-base); font-weight: 500; line-height: 1.3; }
.ag-row small { display: block; font-size: var(--fs-sm); line-height: 1.3; color: var(--text-2); }
.ag-row > .ic:last-child { margin-left: auto; color: var(--text-3); }
.ag-av { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--atut-gradient); color: #fff; font-size: var(--fs-sm); font-weight: 600; }
.ag-av.sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.ag-av.sq { border-radius: 10px; }
.ag-av .ic { width: 18px; height: 18px; }

/* stopka pod kartą */
.ag-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 18px 24px 0; font-size: var(--fs-xs); color: var(--text-2); }
.ag-foot nav { display: flex; gap: 20px; }
.ag-foot a { color: var(--text-2); text-decoration: none; }
.ag-foot a:hover { color: var(--text); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) { .ag-card { animation: none; } .ag .ag-field label, .ag-btn { transition: none; } }

@media (max-width: 820px) {
  .ag { padding: 12px; }
  .ag-card { grid-template-columns: minmax(0, 1fr); row-gap: 18px; min-height: 0; padding: 28px 22px 26px; border-radius: var(--r-xl); }
  .ag-logo .lk { height: 38px; }
  .ag-title { margin-top: 22px; }
  .ag-right { padding-top: 0; }
  .ag-illus { width: 104px; height: 104px; } .ag-illus .ic { width: 46px; height: 46px; }
  .ag-foot { padding: 14px 10px 0; }
}
