
/* ==================================
   WEIFT — COMMON CSS
   Responsive / Mobile-first
================================== */

:root {
  color-scheme: dark;

  --bg: #101012;
  --card: #17171a;
  --input: #101012;
  --surface: #202024;
  --border: #303036;
  --text: #f7f7f8;
  --muted: #a1a1aa;
  --accent: #c7f36b;
  --accent-text: #15180d;
  --danger: #ff7474;
  --success: #83d66c;
  --shadow: 0 24px 80px rgb(0 0 0 / 28%);

  --page-width: 430px;
  --page-gutter: 16px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f2f2f6;
  --card: #fff;
  --input: #fafafd;
  --surface: #f1f1f5;
  --border: #e0e0e7;
  --text: #17171b;
  --muted: #71717a;
  --accent: #b8e954;
  --accent-text: #171b0e;
  --danger: #c93636;
  --success: #32852b;
  --shadow: 0 24px 70px rgb(20 20 40 / 9%);
}

/* Reset */

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

/*
 * El atributo [hidden] del navegador es una regla de agente de usuario,
 * así que cualquier `display` de autor lo anula (p. ej. .weift-modal con
 * display: grid o .template-name-row). Esta regla devuelve el control al
 * atributo hidden en todas las páginas.
 */
[hidden] {
  display: none !important;
}

/*
 * Clase auxiliar equivalente al atributo hidden, para los elementos que
 * se ocultan y muestran desde el JS (p. ej. estados vacíos).
 */
.hidden {
  display: none !important;
}

html {
  width: 100%;
  min-width: 280px;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;

  background:
    radial-gradient(
      ellipse at top,
      rgb(199 243 107 / 7%),
      transparent 45%
    ),
    var(--bg);

  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-wrap: anywhere;

  transition:
    background-color 0.2s,
    color 0.2s;
}

/* Evita que elementos grandes provoquen scroll horizontal */

img,
video,
svg,
canvas {
  max-width: 100%;
}

img,
video {
  height: auto;
}

button,
input,
textarea,
select {
  max-width: 100%;
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: var(--accent);
  color: var(--accent-text);
}

/* Página de autenticación */

.page {
  display: grid;
  place-items: center;

  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;

  position: relative;
  padding:
    max(24px, env(safe-area-inset-top))
    var(--page-gutter)
    max(90px, calc(75px + env(safe-area-inset-bottom)));
}

/* Tarjeta principal */

.auth-card {
  width: 100%;
  max-width: var(--page-width);
  min-width: 0;

  padding: clamp(20px, 5vw, 32px);

  border: 1px solid var(--border);
  border-radius: 26px;

  background: var(--card);
  box-shadow: var(--shadow);
}

/* Logo y marca */

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: 76px;
  height: 76px;
  max-width: 100%;
  object-fit: contain;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.5;
}

/* Introducción */

.intro {
  min-width: 0;
  margin-bottom: 25px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.intro h1 {
  margin: 10px 0 8px;
  font-size: clamp(1.65rem, 6vw, 2rem);
  letter-spacing: -0.05em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Formulario */

.auth-form {
  display: grid;
  gap: 19px;
  width: 100%;
  min-width: 0;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field > label,
.password-heading > label {
  font-size: 0.86rem;
  font-weight: 600;
}

.field input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 49px;
  padding: 13px 14px;

  border: 1px solid var(--border);
  border-radius: 12px;

  background: var(--input);
  color: var(--text);

  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(199 243 107 / 13%);
}

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

/* Contraseña */

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.password-wrapper input {
  padding-right: 80px;
}

.show-password {
  position: absolute;
  right: 10px;
  padding: 8px 4px;

  border: 0;
  background: transparent;
  color: var(--accent);

  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

/* Encabezado de contraseña y enlace para recuperar */

.password-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.forgot-link {
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
}

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

/* Mensajes */

.hint,
.error {
  font-size: 0.75rem;
  line-height: 1.5;
}

.hint {
  margin: 0;
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.error:empty {
  display: none;
}

.form-message {
  margin: -8px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.form-message:empty {
  display: none;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

/* Botón de envío */

.submit-button {
  display: block;
  width: 100%;
  min-height: 51px;
  padding: 13px 16px;

  border: 0;
  border-radius: 12px;

  background: var(--accent);
  color: var(--accent-text);

  font-weight: 800;
  cursor: pointer;

  transition:
    transform 0.15s,
    opacity 0.15s;
}

.submit-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.submit-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Pie de la tarjeta */

.auth-footer {
  margin-top: 25px;
  padding-top: 21px;

  border-top: 1px solid var(--border);

  color: var(--muted);
  text-align: center;
  font-size: 0.83rem;
  line-height: 1.7;
}

.auth-footer a {
  margin-left: 4px;
  font-weight: 700;
  text-decoration: none;
}

/* Selector de tema */

.theme-toggle {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 42px;
  max-width: calc(100% - 24px);
  padding: 10px 14px;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: var(--card);
  color: var(--text);

  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}

#theme-icon {
  flex-shrink: 0;
  color: var(--accent);
}

/* Móviles */

@media (max-width: 480px) {
  :root {
    --page-gutter: 12px;
  }

  .page {
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(82px, calc(70px + env(safe-area-inset-bottom)));
  }

  .auth-card {
    padding: 25px 20px;
    border-radius: 22px;
  }

  .brand {
    margin-bottom: 24px;
  }

  .intro {
    margin-bottom: 22px;
  }

  .auth-form {
    gap: 17px;
  }
}

/* Móviles estrechos */

@media (max-width: 340px) {
  :root {
    --page-gutter: 10px;
  }

  .auth-card {
    padding: 20px 14px;
    border-radius: 18px;
  }

  .brand-logo {
    width: 64px;
    height: 64px;
  }

  .password-heading {
    align-items: flex-start;
  }

  .auth-footer {
    font-size: 0.78rem;
  }
}

/* PC: tarjeta estrecha y centrada */

@media (min-width: 700px) {
  .page {
    padding-top: 35px;
    padding-bottom: 90px;
  }

  .auth-card {
    max-width: 430px;
  }
}

/* Pantallas bajas: evita que la tarjeta quede recortada */

@media (max-height: 650px) {
  .page {
    place-items: start center;
  }

  .brand {
    margin-bottom: 18px;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }

  .intro {
    margin-bottom: 18px;
  }

  .auth-form {
    gap: 14px;
  }
}

/* Correcciones globales responsive — evita zoom en iOS y asegura inputs usables */
input, textarea, select { font-size: 16px; }
@media (min-width: 600px) {
  input, textarea, select { font-size: inherit; }
}
@media (max-width: 480px) {
  textarea, input[type="search"], input[type="text"], input[type="number"] {
    font-size: 16px !important;
  }
}
html { scrollbar-gutter: stable; }
body { overflow-x: hidden; }
.dashboard-shell { overflow-x: hidden; }

/* Accesibilidad */

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