@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ===== Tokens ============================================================ */
:root {
  --color-bg: #021a23;          /* panel de marca */
  --color-surface: #072b36;      /* panel de formulario */
  --color-surface-raised: #0c3543; /* inputs, tarjetas dentro del panel */
  --color-text: #e7f1f2;
  --color-text-muted: rgba(231, 241, 242, 0.62);
  --color-text-faint: rgba(231, 241, 242, 0.4);
  --color-accent: #7a9e7e;
  --color-accent-strong: #96b699;
  --color-accent-contrast: #04141a;
  --color-border: rgba(231, 241, 242, 0.14);
  --color-border-soft: rgba(231, 241, 242, 0.08);
  --color-danger: #ff8577;
  --color-danger-bg: rgba(255, 133, 119, 0.12);
  --color-danger-border: rgba(255, 133, 119, 0.35);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --shadow-modal: 0 24px 48px -12px rgba(0, 0, 0, 0.45);

  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Foco visible en todo elemento interactivo — nunca outline:none sin reemplazo */
:focus-visible {
  outline: 2px solid var(--color-accent-strong);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ===== Shell: split-screen ================================================= */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .auth-shell {
    grid-template-columns: 44% 56%;
  }
}

/* ---- Panel de marca (izquierda en desktop) -------------------------------- */
.brand-panel {
  position: relative;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  overflow: hidden;
}

.brand-panel::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 20% 15%, rgba(122, 158, 126, 0.16), transparent 55%),
    radial-gradient(circle at 85% 80%, rgba(122, 158, 126, 0.10), transparent 50%);
  pointer-events: none;
}

.brand-panel__content {
  position: relative;
  z-index: 1;
  max-width: 360px;
  margin: 0 auto;
  width: 100%;
  opacity: 0;
  animation: rise var(--duration-base) var(--ease-standard) 80ms forwards;
}

.brand-logo {
  display: block;
  width: 220px;
  aspect-ratio: 942 / 490;
  height: auto;
  margin: 0 auto 40px;
}

.brand-panel__eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent-strong);
  margin-bottom: 12px;
}

.brand-panel__title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 16px;
}

.brand-panel__subtitle {
  font-size: 0.975rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
}

.brand-trust {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-trust li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.brand-trust i {
  color: var(--color-accent);
  font-size: 0.9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.brand-panel__footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 32px;
  z-index: 1;
  padding: 0 32px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-faint);
}

/* ---- Panel de formulario (derecha en desktop) ------------------------------ */
.form-panel {
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.form-card {
  width: 100%;
  max-width: 400px;
  opacity: 0;
  animation: rise var(--duration-base) var(--ease-standard) 160ms forwards;
}

.form-card__eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: 10px;
}

.form-card__title {
  font-size: 1.625rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.form-card__subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

/* ===== Formulario ============================================================ */
.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.field input[type='text'],
.field input[type='email'],
.field input[type='password'] {
  width: 100%;
  padding: 13px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.field input::placeholder {
  color: var(--color-text-faint);
}

.field input:hover {
  border-color: rgba(231, 241, 242, 0.28);
}

.field input:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(122, 158, 126, 0.25);
}

.field input[aria-invalid='true'] {
  border-color: var(--color-danger-border);
}

.input-group {
  position: relative;
}

.input-group input {
  padding-right: 46px;
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: color var(--duration-fast) var(--ease-standard);
}

.toggle-password:hover {
  color: var(--color-text);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.link-muted {
  font-size: 0.825rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}

.link-muted:hover {
  color: var(--color-accent-strong);
  border-color: currentColor;
}

/* ---- Error inline ------------------------------------------------------------ */
.error-message {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--color-danger);
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 20px;
}

.error-message.is-visible {
  display: flex;
}

.error-message.is-shaking {
  animation: shake 320ms var(--ease-standard);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ---- Botón principal ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard),
    opacity var(--duration-fast) var(--ease-standard);
  text-decoration: none;
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-accent-strong);
}

.btn--primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--color-text-muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(4, 20, 26, 0.35);
  border-top-color: var(--color-accent-contrast);
  display: none;
  animation: spin 700ms linear infinite;
}

.btn.is-loading .spinner {
  display: inline-block;
}

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

.form-card__footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.form-card__footer a {
  color: var(--color-accent-strong);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid rgba(150, 182, 153, 0.4);
}

.form-card__footer a:hover {
  border-color: currentColor;
}

/* ===== Modal ================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 12, 16, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 32px;
  position: relative;
  animation: rise var(--duration-base) var(--ease-standard);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.modal-close:hover {
  color: var(--color-text);
  background: var(--color-surface-raised);
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-danger-bg);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.modal h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.modal p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions .btn--accent {
  background: #25d366;
  color: #04140a;
}

.modal-actions .btn--accent:hover {
  background: #33e075;
}

/* ===== Responsive ============================================================= */
@media (max-width: 1023px) {
  .brand-panel {
    padding: 36px 24px 28px;
  }

  .brand-panel__content {
    max-width: 480px;
  }

  .brand-logo {
    width: 128px;
    margin-bottom: 20px;
  }

  .brand-panel__title {
    font-size: 1.375rem;
  }

  .brand-trust {
    display: none;
  }

  .brand-panel__footer {
    display: none;
  }

  .form-panel {
    padding: 8px 20px 48px;
  }
}

@media (max-width: 480px) {
  .modal {
    padding: 24px 20px;
  }
}

/* ===== Motion ================================================================= */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .brand-panel__content,
  .form-card,
  .modal {
    opacity: 1;
    transform: none;
  }
}
