/*
  login.css
  Tela de login: login + seleção de organização.
  Layout: foto em coluna cheia + formulário enxuto, usando CSS Grid.
*/

:root {
  color-scheme: light;

  /* Cor */
  --c-bg: #f7faf8;
  --c-surface: #ffffff;
  --c-primary: #0b8a46;
  --c-primary-hover: #076b37;
  --c-blue: #17408b;
  --c-gold: #f2b705;
  --c-ink: #16241d;
  --c-ink-muted: #5c6b62;
  --c-border: #dfe6e1;
  --c-error: #b3261e;
  --c-error-bg: #fbeae8;

  /* Tipografia */
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  /* Espaço */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --sp-6: 48px;

  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.hidden {
  display: none !important;
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  color: var(--c-ink);
  font-family: var(--font);
}

/* ---------- Foto (fundo expandido, tela toda) ---------- */

.auth-photo {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--c-primary-hover);
}

.auth-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 26, 17, 0.28) 0%, rgba(10, 26, 17, 0.1) 45%, rgba(10, 26, 17, 0.45) 100%),
    rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
  pointer-events: none;
}

.auth-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 1;
  filter: blur(10px);
  transform: scale(1.05);
  transition: filter 0.25s ease, transform 0.25s ease;
}

.auth-photo img.is-loaded {
  filter: blur(0);
  transform: scale(1);
}

.auth-form-brand-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  margin: 0 0 var(--sp-3);
}

.auth-form-logo {
  display: block;
  height: 6rem;
  width: auto;
  margin: 0 auto;
}

.auth-form-brand {
  display: block;
  font-weight: 800;
  font-size: 3.2rem;
  letter-spacing: -0.02em;
}

.auth-form-brand--syspro {
  color: var(--c-ink);
}

.auth-form-brand--br {
  color: var(--c-primary);
}

.auth-form-brand-tagline {
  display: block;
  color: var(--c-ink-muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-photo__footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0));
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.auth-photo__footer-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auth-photo__footer-brand {
  font-weight: 300;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0.85;
}

.auth-photo__footer-meta {
  font-weight: 300;
  font-size: 0.65rem;
  letter-spacing: 0.01em;
  opacity: 0.72;
}

.auth-photo__footer-contacts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
}

.auth-photo__contact {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #ffffff;
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.85;
}

.auth-photo__contact:hover {
  opacity: 1;
  text-decoration: underline;
}

.auth-photo__contact svg {
  flex-shrink: 0;
}

/* ---------- Formulário ---------- */

.auth-form-panel {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-5);
  pointer-events: none;
}

.auth-form {
  width: 100%;
  max-width: 400px;
  padding: 44px 36px;
  background: var(--c-surface);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}

@media (min-width: 901px) {
  .auth-form {
    max-width: 480px;
    padding: 56px 48px;
  }
}

/* ---------- Refino visual ---------- */

.auth-form {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 24px 60px rgba(6, 30, 18, 0.35), 0 2px 6px rgba(6, 30, 18, 0.15);
}

.auth-heading {
  margin: 0 0 var(--sp-4);
  text-align: center;
}

.auth-form .auth-heading h1 {
  margin: 0 0 var(--sp-1);
  font-size: 1.5rem;
}

.auth-heading p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--c-ink-muted);
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a9a90;
  pointer-events: none;
  transition: color 0.15s ease;
}

.auth-input-wrap:focus-within .auth-input-icon {
  color: var(--c-primary);
}

.auth-input-wrap .auth-input-icon ~ input {
  padding-left: 42px;
}

.auth-field input {
  min-height: 48px;
  background: #fbfcfb;
}

.auth-field input::placeholder {
  color: #a3afa8;
}

.auth-field input:hover {
  border-color: #c5d0c9;
}

.auth-field input:focus-visible {
  outline: none;
  background: var(--c-surface);
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(11, 138, 70, 0.15);
}

.auth-toggle-visibility {
  color: #8a9a90;
}

.auth-forgot {
  margin: var(--sp-2) 0 0;
  text-align: left;
}

/* ---------- Modal de recuperação (mesmo visual do cartão de login) ---------- */

.auth-modal-overlay {
  font-family: var(--font);
  color: var(--c-ink);
  background: rgba(10, 26, 17, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.auth-modal {
  position: relative;
  max-width: 440px;
  padding: 44px 36px 32px;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(6, 30, 18, 0.35), 0 2px 6px rgba(6, 30, 18, 0.15);
}

.auth-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--c-ink-muted);
  cursor: pointer;
}

.auth-modal__close:hover {
  background: var(--c-bg);
  color: var(--c-ink);
}

.auth-modal__close:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 1px;
}

.auth-modal__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--sp-3);
  border-radius: 50%;
  color: var(--c-primary);
  background: #eaf6ee;
}

.auth-modal .auth-heading h2 {
  margin: 0 0 var(--sp-1);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-modal__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  margin-top: var(--sp-2);
}

.auth-modal__actions .auth-back {
  margin-top: var(--sp-3);
}

.auth-submit {
  min-height: 48px;
  margin-top: var(--sp-2);
  background: var(--c-primary);
  box-shadow: 0 6px 14px rgba(11, 138, 70, 0.25);
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.auth-submit:hover:not([disabled]) {
  background: var(--c-primary-hover);
}

.auth-consent {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--c-border);
}

.auth-form__eyebrow {
  font-size: 0.85rem;
  color: var(--c-ink-muted);
  margin: 0 0 var(--sp-1);
}

.auth-form h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 var(--sp-5);
}

#org-screen h1 {
  text-align: center;
}

.auth-form__subtitle {
  color: var(--c-ink-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 var(--sp-5);
}

.auth-field {
  margin-bottom: var(--sp-3);
}

.auth-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.auth-input-wrap {
  position: relative;
}

.auth-field input {
  width: 100%;
  min-height: 44px;
  padding: 10px var(--sp-3);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--c-ink);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}

.auth-field input:focus-visible {
  outline: 3px solid var(--c-blue);
  outline-offset: 1px;
  border-color: var(--c-blue);
}

.auth-field--password input {
  padding-right: 46px;
}

.auth-toggle-visibility {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--c-ink);
  cursor: pointer;
  border-radius: var(--radius);
}

.auth-toggle-visibility:hover {
  color: var(--c-blue);
}

.auth-toggle-visibility:focus-visible {
  outline: 2px solid var(--c-blue);
  outline-offset: 1px;
}

.auth-submit {
  width: 100%;
  min-height: 44px;
  padding: 10px var(--sp-3);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--c-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.15s ease, transform 0.05s ease;
}

.auth-submit:hover {
  background: var(--c-primary-hover);
}

.auth-submit:active {
  transform: translateY(1px);
}

.auth-submit:focus-visible {
  outline: 2px solid var(--c-blue);
  outline-offset: 2px;
}

.auth-submit[disabled] {
  opacity: 0.65;
  cursor: default;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  animation: btn-spinner-spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes btn-spinner-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-spinner {
    animation: none;
  }
}

.auth-consent {
  margin: var(--sp-3) 0 0;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--c-ink-muted);
}

.auth-consent a {
  color: var(--c-blue);
  font-weight: 600;
  text-decoration: none;
}

.auth-consent a:hover {
  text-decoration: underline;
}

.auth-error {
  display: none;
  padding: 10px var(--sp-3);
  margin-bottom: var(--sp-4);
  background: var(--c-error-bg);
  color: var(--c-error);
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.5;
}

.auth-error.is-visible {
  display: block;
}

.auth-form__footer {
  margin-top: var(--sp-5);
  font-size: 0.8rem;
  color: var(--c-ink-muted);
}

.auth-forgot {
  margin: var(--sp-3) 0 0;
  text-align: left;
  font-size: 0.85rem;
}

.auth-forgot a {
  color: var(--c-blue);
  font-weight: 600;
  text-decoration: none;
}

.auth-forgot a:hover {
  text-decoration: underline;
}

/* ---------- Modal de recuperação de senha ---------- */

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 36, 29, 0.45);
  padding: var(--sp-4);
  z-index: 10;
}

.auth-modal {
  width: 100%;
  max-width: 380px;
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: var(--sp-5);
}

.auth-modal h2 {
  margin: 0 0 var(--sp-2);
  font-size: 1.3rem;
  font-weight: 700;
}

.auth-modal__help {
  margin: 0 0 var(--sp-4);
  color: var(--c-ink-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.auth-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.auth-secondary {
  min-height: 48px;
  padding: 12px var(--sp-3);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-ink);
  background: transparent;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
}

.auth-secondary:hover {
  background: var(--c-bg);
}

.auth-success {
  display: none;
  padding: 10px var(--sp-3);
  margin-bottom: var(--sp-4);
  background: #eaf6ee;
  color: var(--c-primary-hover);
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.5;
}

.auth-success.is-visible {
  display: block;
}

/* ---------- Seleção de organização ---------- */

.auth-org-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
}

.auth-org-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 152px;
  padding: var(--sp-5) var(--sp-3);
  font-family: inherit;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}

.auth-org-option:hover {
  border-color: var(--c-primary);
  background: #f4faf6;
}

.auth-org-option:active {
  transform: translateY(1px);
}

.auth-org-option:focus-visible {
  outline: 2px solid var(--c-blue);
  outline-offset: 2px;
}

.auth-org-option[disabled] {
  opacity: 0.6;
  cursor: default;
}

.auth-org-option__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: 50%;
  color: #ffffff;
}

.auth-org-option--associacao .auth-org-option__icon {
  background: var(--c-blue);
}

.auth-org-option--cooperativa .auth-org-option__icon {
  background: var(--c-primary);
}

.auth-org-option__type {
  font-weight: 700;
  font-size: 0.92rem;
}

.auth-org-option__name {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--c-ink-muted);
  text-align: center;
  line-height: 1.4;
}

.auth-org-option.is-loading .auth-org-option__icon {
  animation: btn-spinner-spin 0.9s linear infinite;
}

@media (max-width: 380px) {
  .auth-org-grid {
    grid-template-columns: 1fr;
  }
}

.auth-back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: var(--c-blue);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-top: var(--sp-4);
}

.auth-back:hover {
  color: var(--c-primary);
}

/* ---------- Responsivo ---------- */

@media (max-width: 900px) {
  .auth-photo__footer {
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    text-align: center;
  }

  .auth-form-logo {
    height: 3.75rem;
  }

  .auth-form-brand {
    font-size: 2rem;
  }

  .auth-form-panel {
    padding: var(--sp-4);
    padding-bottom: 80px;
  }

  .auth-form {
    padding: var(--sp-5) var(--sp-4);
  }
}

@media (max-width: 420px) {
  .auth-form-logo {
    height: 3.2rem;
  }

  .auth-form-brand {
    font-size: 1.7rem;
  }

  .auth-photo__footer {
    padding: var(--sp-3);
  }

  .auth-form h1 {
    font-size: 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-submit,
  .auth-org-option {
    transition: none;
  }

  .auth-org-option.is-loading .auth-org-option__icon {
    animation: none;
  }
}
