/**
 * Lenguaje visual Mirgor.
 *
 * Paleta, tipografia y layout del login tomados del sistema de diseño corporativo, que
 * ya tiene la estetica corporativa resuelta. Los tokens de abajo son los mismos
 * de su globals.css, transcritos a CSS plano porque este PoC no usa Tailwind.
 */

/* Archivo — variable (eje wght 400-800), auto-hospedada para que la pagina no
   dependa de fonts.gstatic.com ni haya que abrirle la CSP a un tercero. */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 100%;
  font-display: swap;
  src: url("/fonts/archivo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 100%;
  font-display: swap;
  src: url("/fonts/archivo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Superficies */
  --canvas: #f4f6fb;
  --surface-soft: #f7f9fe;
  --surface-hover: #f0f3fc;
  --row-hover: #f8fafe;

  /* Marca */
  --navy: #0b1b5c;
  --navy-hover: #152878;
  --brand: #2440ff;
  --brand-strong: #1a2fb8;
  --brand-soft: #e8edff;
  --brand-soft-hover: #d7dfff;

  /* Texto */
  --ink: #0b1b5c;
  --ink-soft: #3d4666;
  --muted: #66708c;
  --faint: #8b93ad;

  /* Texto sobre navy */
  --on-navy: #dde3fa;
  --on-navy-muted: #b6c0f5;
  --on-navy-faint: #8b93d9;

  /* Bordes */
  --line: #e3e8f4;
  --line-strong: #d5dcee;
  --line-soft: #eef1fa;

  /* Estado */
  --danger-bg: #feecec;
  --danger-fg: #c0392b;
  --online: #34d399;

  /* Elevacion */
  --shadow-card: 0 12px 40px rgba(11, 27, 92, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.loading {
  padding: 3rem;
  color: var(--muted);
}

/* --- Topbar --------------------------------------------------------------- */

header.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 60px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: var(--navy);
  color: #fff;
}

header.topbar .logo {
  display: block;
  height: 22px;
  width: auto;
}

header.topbar .divider {
  width: 1px;
  height: 22px;
  flex: none;
  background: rgba(255, 255, 255, 0.2);
}

header.topbar .title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* El logo del encabezado vuelve al home: es el gesto que todos esperan. */
header.topbar .brand {
  display: inline-flex;
  align-items: center;
  flex: none;
}

/* "Administración" al lado del título: dónde estoy parado, sin ambigüedad. */
header.topbar .crumb {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

header.topbar .crumb::before {
  content: '/';
  margin-right: 0.5rem;
  color: rgba(255, 255, 255, 0.35);
}

header.topbar .spacer {
  flex: 1;
}

header.topbar .who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 13px;
  color: var(--on-navy-muted);
  white-space: nowrap;
}

header.topbar .dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--online);
}

/* --- Layout --------------------------------------------------------------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.6rem, 4vw, 2.6rem) clamp(16px, 4vw, 40px) 4rem;
  animation: fade-up 0.4s ease;
}

h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
}

h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2.6rem 0 0.9rem;
}

.subtitle {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0 0 1.9rem;
}

/* --- Login ---------------------------------------------------------------- */

.login {
  display: flex;
  min-height: 100vh;
  flex-wrap: wrap;
  align-items: stretch;
}

.login-brand {
  display: flex;
  flex: 1 1 380px;
  min-height: 320px;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  color: #fff;
  background-image: linear-gradient(160deg, #0b1b5c 0%, #101f6e 55%, #1a2fb8 100%);
}

.login-brand .logo {
  display: block;
  width: 150px;
  height: auto;
}

.login-brand h1 {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
}

.login-brand p.lead {
  max-width: 360px;
  margin: 0.9rem 0 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--on-navy-muted);
}

.login-brand p.legal {
  margin: 0;
  font-size: 12px;
  color: var(--on-navy-faint);
}

.login-panel {
  display: flex;
  flex: 1 1 380px;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  animation: fade-up 0.4s ease;
}

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.login-card p.hint {
  margin: 0.4rem 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.login-card p.foot {
  margin: 1.4rem 0 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--faint);
}

.user-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 1.7rem;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  min-height: 56px;
  padding: 0.6rem 0.9rem;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.user-btn:hover {
  background: var(--surface-hover);
  border-color: var(--brand);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 700;
}

.user-btn strong {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
}

.user-btn small {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

/* --- Tiles ---------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.tile {
  display: block;
  padding: 1.3rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}

.tile .mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 0.9rem;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 15px;
  font-weight: 800;
}

.tile strong {
  display: block;
  font-size: 15.5px;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.tile span {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* --- Bloques -------------------------------------------------------------- */

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 1.4rem;
}

.empty {
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 2.6rem 2rem;
  text-align: center;
}

.empty strong {
  display: block;
  font-size: 16px;
  margin-bottom: 0.4rem;
}

.note {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  margin-top: 0.6rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: var(--row-hover);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--chip-fg, var(--brand-strong));
  white-space: nowrap;
}

.chip.nested {
  background: var(--surface-hover);
  color: var(--muted);
}

/**
 * Un grupo sin object id NO le da acceso a nadie: la membresía se resuelve
 * contra el directorio por GUID, y sin GUID no hay contra qué resolver. Se
 * marca donde se lo ve, porque el fallo es silencioso en todos los demás lados.
 */
.chip.pendiente {
  background: transparent;
  color: var(--danger, #b3261e);
  border: 1px dashed currentColor;
}

/* --- Controles ------------------------------------------------------------ */

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--brand);
}

.btn.primary {
  min-height: 44px;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-size: 14.5px;
}

.btn.primary:hover {
  background: var(--navy-hover);
  border-color: var(--navy-hover);
}

.btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.45);
}

.btn.danger {
  color: var(--danger-fg);
  border-color: var(--line-strong);
}

.btn.danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger-fg);
}

form.stack {
  display: grid;
  gap: 0.85rem;
  max-width: 520px;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="url"],
select {
  padding: 0.55rem 0.65rem;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

input:focus,
select:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}

select[multiple] {
  min-height: 130px;
}

.error {
  color: var(--danger-fg);
  font-size: 13.5px;
}

/* --- Utilidades ----------------------------------------------------------- */

/* La CSP es `style-src 'self'`: el atributo style inline esta bloqueado a
   proposito, asi que el espaciado puntual va por clase. */

.mt-0 {
  margin-top: 0;
}

.mt-lg {
  margin-top: 1.6rem;
}

.pad-lg {
  padding: 2rem;
}

/* Boton de ingreso al proveedor corporativo. Es un <a>, no un <button>: la
   accion es navegar a otro origen, y un enlace se comporta como enlace (abrir
   en pestaña nueva, ver el destino en la barra de estado). */
.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1rem;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 10px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.primary-btn:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}
