@import 'variables.css';
@import 'loading.css';

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

body.login-page {
  font-family: var(--font);
  background-color: var(--white);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

body.psk-loading-active {
  overflow: hidden;
}

.login-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: url('../../imagenes/fondo_login.png') no-repeat center center;
  background-size: cover;
}

.login-wrapper {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 48px 24px;
  align-items: center;
  min-height: calc(100vh - 60px);
}

/* Branding column */
.login-brand {
  padding-right: 24px;
}

.login-brand__logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}

.login-brand__logo img {
  width: auto;
  height: clamp(72px, 11vw, 112px);
  max-width: min(100%, 380px);
  object-fit: contain;
}

.login-brand__headline {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--gray-900);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.login-brand__headline .highlight {
  color: var(--green-accent);
}

.login-brand__desc {
  font-size: 1rem;
  color: var(--gray-500);
  line-height: 1.6;
  max-width: 440px;
  margin-bottom: 40px;
}

/* Imagen de dispositivos */
.device-showcase {
  margin-top: 8px;
  max-width: 100%;
}

.device-showcase__img {
  display: block;
  width: 100%;
  max-width: 580px;
  height: auto;
  object-fit: contain;
}

/* Login card */
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-100);
  padding: 40px;
  max-width: 440px;
  width: 100%;
  margin-left: auto;
}

.login-card__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.login-card__subtitle {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap > svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--gray-400);
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  padding: 12px 14px 12px 44px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 3px rgba(0, 97, 213, 0.12);
}

.input-wrap input::placeholder {
  color: var(--gray-400);
}

.input-wrap--select select {
  width: 100%;
  padding: 12px 14px 12px 44px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  cursor: pointer;
}

.input-wrap--select select:focus {
  outline: none;
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 3px rgba(0, 97, 213, 0.12);
}

.input-wrap--select select:disabled {
  background: var(--gray-50);
  color: var(--gray-400);
  cursor: not-allowed;
}

.input-wrap input[readonly] {
  background: var(--gray-50);
  color: var(--gray-700);
  cursor: default;
}

.login-licencia-msg {
  font-size: 0.875rem;
  line-height: 1.4;
  margin: -8px 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.login-licencia-msg--info {
  color: var(--gray-600);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}

.login-licencia-msg--error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.btn-primary.is-disabled {
  pointer-events: none;
  opacity: 0.55;
  cursor: not-allowed;
}

/* Toasts */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--gray-800);
  background: var(--white);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.28s ease;
}

.toast--success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.toast--error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.toast--info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.toast__text {
  flex: 1;
  min-width: 0;
}

.toast.toast--out {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

@media (max-width: 480px) {
  .toast-container {
    top: auto;
    bottom: 20px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

.input-wrap--password input {
  padding-right: 48px;
}

.input-wrap--password .btn-toggle-pwd {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  flex-shrink: 0;
}

.input-wrap--password .btn-toggle-pwd:hover {
  color: var(--gray-600);
  background: var(--gray-50);
}

.input-wrap--password .btn-toggle-pwd svg {
  position: static;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.input-wrap--password .btn-toggle-pwd .icon-eye-closed[hidden],
.input-wrap--password .btn-toggle-pwd .icon-eye-open[hidden] {
  display: none;
}

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

.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--gray-600);
  cursor: pointer;
}

.checkbox-wrap input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue-primary);
}

.link {
  font-size: 0.875rem;
  color: var(--blue-primary);
  text-decoration: none;
  font-weight: 500;
}

.link:hover {
  text-decoration: underline;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--blue-primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s, opacity 0.2s;
}

button.btn-primary {
  appearance: none;
}

.btn-primary:hover {
  background: var(--blue-700);
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--gray-400);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  font-family: var(--font);
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.2s, border-color 0.2s;
}

.btn-oauth:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-oauth svg {
  width: 20px;
  height: 20px;
}

.login-card__footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Page footer */
.login-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 48px;
  background: var(--blue-primary);
  border-top: none;
  font-size: 0.8rem;
  color: var(--white);
}

.login-footer__links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.login-footer__links a {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--white);
  text-decoration: none;
  transition: opacity 0.2s;
}

.login-footer__links a:hover {
  opacity: 0.85;
}

.login-footer__links svg {
  width: 16px;
  height: 16px;
  color: var(--white);
}

@media (max-width: 1024px) {
  .login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    grid-template-columns: 1fr;
    padding: 28px 24px 24px;
    gap: 28px;
    min-height: calc(100vh - 56px);
  }

  /* El logo sale de la columna brand y queda arriba del formulario */
  .login-brand {
    display: contents;
  }

  .login-brand__logo {
    order: -1;
    width: 100%;
    justify-content: center;
    margin-bottom: 0;
  }

  .login-brand__logo img {
    height: clamp(64px, 18vw, 96px);
    max-width: min(92vw, 320px);
  }

  .login-brand__headline,
  .login-brand__desc,
  .device-showcase {
    display: none;
  }

  .login-card {
    order: 0;
    margin: 0 auto;
    max-width: 440px;
  }
}

@media (max-width: 480px) {
  .login-wrapper {
    padding: 20px 16px 16px;
    gap: 20px;
  }

  .login-brand__logo img {
    height: clamp(56px, 22vw, 80px);
    max-width: 90vw;
  }

  .login-card {
    padding: 28px 20px;
    max-width: 100%;
  }

  .login-footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 16px 24px;
  }
}
