/* ============================================================
   mlh-id.css — Estilos compartidos Microlab ID
   Sistema de diseño: Material Design 3
   Actualizado: 2026-02-25
   ============================================================ */

/* ─── Tokens M3 ──────────────────────────────────────────── */
:root {
  /* Color — Primary */
  --md-sys-color-primary: #1a6fdb;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d6e4ff;
  --md-sys-color-on-primary-container: #002c6c;

  /* Color — Secondary */
  --md-sys-color-secondary: #5a6475;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #dee3f0;
  --md-sys-color-on-secondary-container: #17202f;

  /* Color — Surface */
  --md-sys-color-surface: #f8f9fc;
  --md-sys-color-surface-container: #ffffff;
  --md-sys-color-surface-container-high: #f1f3f8;
  --md-sys-color-on-surface: #191c20;
  --md-sys-color-on-surface-variant: #43474e;
  --md-sys-color-outline: #73777f;
  --md-sys-color-outline-variant: #c3c7cf;

  /* Color — Error */
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;

  /* Color — Success */
  --md-sys-color-success: #1a6f48;
  --md-sys-color-success-container: #b7f2d8;
  --md-sys-color-on-success-container: #002114;

  /* Tipografía */
  --md-sys-typescale-body-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --md-sys-typescale-display-size: 2rem;
  --md-sys-typescale-headline-size: 1.375rem;
  --md-sys-typescale-title-size: 1rem;
  --md-sys-typescale-body-size: 0.9375rem;
  --md-sys-typescale-label-size: 0.8125rem;

  /* Elevación */
  --md-sys-elevation-1: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
  --md-sys-elevation-2: 0 2px 6px rgba(0, 0, 0, .10), 0 1px 4px rgba(0, 0, 0, .07);
  --md-sys-elevation-3: 0 4px 12px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .08);

  /* Border radius */
  --md-sys-shape-small: 8px;
  --md-sys-shape-medium: 12px;
  --md-sys-shape-large: 16px;
  --md-sys-shape-full: 9999px;
}

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

/* ─── Base ───────────────────────────────────────────────── */
body {
  font-family: var(--md-sys-typescale-body-font);
  font-size: var(--md-sys-typescale-body-size);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Tarjeta principal ──────────────────────────────────── */
.mlh-card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-large);
  box-shadow: var(--md-sys-elevation-3);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

/* ─── Logo cabecera (rectangular) ────────────────────────── */
.mlh-logo-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  gap: 0.25rem;
}

.mlh-logo-header img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.mlh-logo-header-title {
  font-size: var(--md-sys-typescale-label-size);
  color: var(--md-sys-color-on-surface-variant);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ─── Bloque cliente OAuth ───────────────────────────────── */
.mlh-client-block {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-medium);
  padding: 0.875rem 1rem;
  margin-bottom: 1.5rem;
}

.mlh-client-block-logo {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-small);
  object-fit: contain;
  background: var(--md-sys-color-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--md-sys-color-on-primary-container);
  overflow: hidden;
}

.mlh-client-block-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mlh-client-block-info {
  flex: 1;
  min-width: 0;
}

.mlh-client-block-name {
  font-size: var(--md-sys-typescale-title-size);
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mlh-client-block-desc {
  font-size: var(--md-sys-typescale-label-size);
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 0.125rem;
}

/* ─── Título de pantalla ─────────────────────────────────── */
.mlh-screen-title {
  font-size: var(--md-sys-typescale-headline-size);
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 0.5rem;
  text-align: center;
}

.mlh-screen-subtitle {
  font-size: var(--md-sys-typescale-body-size);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 1.5rem;
  text-align: center;
}

/* ─── Formulario ─────────────────────────────────────────── */
.mlh-form-group {
  margin-bottom: 1.375rem;
}

.mlh-form-group label {
  display: block;
  font-size: var(--md-sys-typescale-label-size);
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}

.mlh-input {
  display: block;
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-medium);
  font-size: var(--md-sys-typescale-body-size);
  font-family: var(--md-sys-typescale-body-font);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}

.mlh-input::placeholder {
  color: var(--md-sys-color-outline);
}

.mlh-input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 4px rgba(26, 111, 219, .12);
  background: var(--md-sys-color-surface-container-high);
}

.mlh-input:readonly {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
}

/* ─── Botones ────────────────────────────────────────────── */
.mlh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.9375rem 1.5rem;
  border-radius: var(--md-sys-shape-full);
  font-size: var(--md-sys-typescale-body-size);
  font-weight: 600;
  font-family: var(--md-sys-typescale-body-font);
  cursor: pointer;
  border: none;
  transition: background 0.2s, box-shadow 0.2s, filter 0.2s;
  text-decoration: none;
}

.mlh-btn-primary {
  background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, #1559c7 100%);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-2);
}

.mlh-btn-primary:hover {
  filter: brightness(1.12);
  box-shadow: var(--md-sys-elevation-3);
}

.mlh-btn-outlined {
  background: transparent;
  color: var(--md-sys-color-primary);
  border: 1.5px solid var(--md-sys-color-outline);
}

.mlh-btn-outlined:hover {
  background: var(--md-sys-color-primary-container);
  border-color: var(--md-sys-color-primary);
}

.mlh-btn-tonal {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.mlh-btn-tonal:hover {
  filter: brightness(0.95);
}

.mlh-btn-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.mlh-btn-row .mlh-btn {
  flex: 1;
}

/* ─── Alerta error ───────────────────────────────────────── */
.mlh-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  background: var(--md-sys-color-error-container);
  border: 1px solid var(--md-sys-color-error);
  color: var(--md-sys-color-on-error-container);
  border-radius: var(--md-sys-shape-small);
  padding: 0.75rem 1rem;
  font-size: var(--md-sys-typescale-label-size);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.mlh-alert-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--md-sys-color-error);
}

/* ─── Alerta éxito ───────────────────────────────────────── */
.mlh-alert-success {
  background: var(--md-sys-color-success-container);
  border: 1px solid var(--md-sys-color-success);
  color: var(--md-sys-color-on-success-container);
}

.mlh-alert-success .mlh-alert-icon {
  color: var(--md-sys-color-success);
}

/* ─── Ícono central (estado) ────────────────────────────── */
.mlh-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 1.5rem;
}

.mlh-state-icon-success {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-success);
}

.mlh-state-icon-error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}

.mlh-state-icon svg {
  width: 36px;
  height: 36px;
}

/* ─── Lista de scopes ────────────────────────────────────── */
.mlh-scopes-section {
  margin-bottom: 1.5rem;
}

.mlh-scopes-label {
  font-size: var(--md-sys-typescale-label-size);
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

/* ─── Icons (Material Symbols) ──────────────────────── */
.mlh-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-family: 'Material Symbols Rounded';
  font-size: 1.5rem;
  line-height: 1;
  color: currentColor;
}

.mlh-icon-sm {
  font-size: 1.25rem;
  color: var(--md-sys-color-primary);
}

.mlh-icon-tab {
  font-size: 1.25rem;
  margin-right: 0.5rem;
}

/* ─── Editor de perfil (botones colapsables) ──────── */
.mlh-profile-editor {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.mlh-profile-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: var(--md-sys-color-surface-container);
  border: 2px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-medium);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}

.mlh-profile-item-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.25rem;
  cursor: pointer;
}

.mlh-profile-item:hover {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-high);
}

.mlh-profile-item-active {
  border: 2px dashed var(--md-sys-color-error);
  background: linear-gradient(135deg, rgba(186, 26, 26, .04) 0%, rgba(186, 26, 26, .02) 100%);
}

.mlh-profile-item-icon {
  flex-shrink: 0;
  font-size: 1.5rem;
  color: var(--md-sys-color-primary);
}

.mlh-profile-item-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.mlh-profile-item-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.mlh-profile-item-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  word-break: break-word;
}

.mlh-profile-item-chevron {
  flex-shrink: 0;
  font-size: 1.5rem;
  color: var(--md-sys-color-on-surface-variant);
  transition: transform 0.3s;
}

.mlh-profile-item-active .mlh-profile-item-chevron {
  transform: rotate(180deg);
  color: var(--md-sys-color-error);
}

/* ─── Formulario de perfil ────────────────────────── */
.mlh-profile-item-form {
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 1.5rem;
  background: var(--md-sys-color-surface-container-high);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  cursor: default;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mlh-scopes-list {
  list-style: none;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-medium);
  overflow: hidden;
}

.mlh-scopes-list li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  font-size: var(--md-sys-typescale-body-size);
  color: var(--md-sys-color-on-surface);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.mlh-scopes-list li:last-child {
  border-bottom: none;
}

.mlh-scopes-list li svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--md-sys-color-primary);
}

/* ─── Separador ─────────────────────────────────────────── */
.mlh-divider {
  border: none;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin: 1.5rem 0;
}

/* ─── Footer ────────────────────────────────────────────── */
.mlh-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  text-align: center;
  margin-top: 1.5rem;
  font-size: var(--md-sys-typescale-label-size);
  color: var(--md-sys-color-outline);
  line-height: 1.4;
}

.mlh-footer-separator {
  opacity: 0.55;
}

.mlh-footer a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  font-weight: 500;
}

.mlh-footer a:hover {
  text-decoration: underline;
}

/* ─── Insignia de versión ───────────────────────────────── */
.mlh-version-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  color: var(--md-sys-color-outline);
  letter-spacing: 0.04em;
  opacity: 0.7;
}