/* settings.css — Vista Configuración: pestañas, tarjetas de sección, filas,
   controles, planes/facturación e integraciones. Un solo column centrado,
   sin la columna descriptiva de la izquierda (diseño limpio y profesional). */

/* La vista de Configuración ocupa todo el ancho: el panel de info se oculta. */
.app[data-info="hidden"] .info { display: none; }

/* En tablet vertical / móvil (≤900px) el menú lateral pasa a cajón y el
   contenido debe ocupar UNA sola columna. La regla base data-info="hidden"
   (var(--drawer-w) + 1fr) tiene más especificidad que la responsive .app{1fr},
   así que aquí la reponemos explícitamente para que no quede angosto. */
@media (max-width: 900px) {
  .app[data-info="hidden"],
  .app[data-drawer="collapsed"][data-info="hidden"] { grid-template-columns: 1fr; }
}

/* ─── Contenedor ───
   Paleta de Configuración: gris oscuro (como los botones del resto de la app)
   en lugar de azul. Se redefinen los tokens de acento solo dentro de esta
   vista, así pestaña activa, botones, interruptores, iconos y focos cambian
   juntos sin tocar el resto de la aplicación. */
.set-wrap {
  --accent: var(--fg);
  --accent-ink: color-mix(in srgb, var(--fg) 82%, var(--surface));
  --accent-soft: var(--surface-sunken);
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 22px 60px;
}
@media (max-width: 640px) { .set-wrap { padding: 14px 14px 48px; } }

.set-head { margin: 0 0 18px; }
.set-head h1 {
  font-family: 'Instrument Serif', serif;
  font-weight: 400; font-size: 34px; letter-spacing: -0.02em;
  margin: 0 0 4px; color: var(--fg);
}
.set-head p { margin: 0; color: var(--fg-muted); font-size: 14px; line-height: 1.5; }
@media (max-width: 640px) { .set-head h1 { font-size: 27px; } }

/* ─── Pestañas (sticky) ─── */
.set-tabs {
  position: sticky; top: 0; z-index: 15;
  display: flex; gap: 2px;
  padding: 10px 0 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(var(--surface), var(--surface) 70%, transparent);
}
.set-tabs::-webkit-scrollbar { display: none; }
.set-tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px 13px;
  background: transparent; border: 0;
  color: var(--fg-muted);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: color .12s;
}
.set-tab svg { width: 15px; height: 15px; opacity: .7; }
.set-tab:hover { color: var(--fg); }
.set-tab.active { color: var(--accent); font-weight: 600; }
.set-tab.active svg { opacity: 1; }
.set-tab.active::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
}

/* ─── Tarjeta de sección ─── */
.set-body { display: flex; flex-direction: column; gap: 16px; }
.set-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.set-card-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.set-card-ico {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.set-card-ico svg { width: 17px; height: 17px; }
.set-card-ht { min-width: 0; flex: 1; }
.set-card-ht h2 {
  margin: 0; font-size: 15px; font-weight: 650; color: var(--fg);
  letter-spacing: -0.01em;
}
.set-card-ht p { margin: 3px 0 0; font-size: 12.5px; color: var(--fg-muted); line-height: 1.45; }
.set-card-head-act { margin-left: auto; flex-shrink: 0; }
.set-card-body { padding: 6px 18px 14px; }
.set-card-body.pad { padding: 16px 18px; }

/* ─── Fila de ajuste (icono + texto | control) ─── */
.set-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.set-row:last-child { border-bottom: 0; }
.set-row-ico {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  color: var(--fg-muted);
}
.set-row-ico svg { width: 17px; height: 17px; }
.set-row-main { min-width: 0; flex: 1; }
.set-row-main .tt { font-size: 13.5px; font-weight: 550; color: var(--fg); }
.set-row-main .ds { font-size: 12px; color: var(--fg-muted); margin-top: 2px; line-height: 1.4; }
.set-row-ctl { flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.set-row-ctl .muted { font-size: 12.5px; color: var(--fg-muted); }
/* Desplegables dentro de una fila: mismo estilo que los campos (coherencia). */
.set-row-ctl select {
  height: 38px; max-width: 240px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 11px center;
  color: var(--fg); font: inherit; font-size: 13px; font-weight: 500;
  appearance: none; cursor: pointer;
}
.set-row-ctl select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Tarjeta tipo "caja" para filas con borde individual (como el mockup) */
.set-boxrows { display: flex; flex-direction: column; gap: 10px; }
.set-box {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.set-box .set-row-ico { color: var(--fg-muted); }

/* ─── Sesiones activas (lista real de dispositivos) ─── */
.set-sessions-wrap { display: flex; flex-direction: column; gap: 8px; }
/* Encabezado ligero (sin caja): icono + título + enlace "Actualizar" */
.set-subhead { display: flex; align-items: center; gap: 12px; padding: 2px 2px 2px 0; }
.set-subhead .set-row-ico { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; color: var(--fg-muted); }
.set-subhead .set-row-ico svg { width: 17px; height: 17px; }
.set-link-btn {
  flex-shrink: 0; border: 0; background: none; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 4px; border-radius: 6px;
}
.set-link-btn:hover { text-decoration: underline; }
.set-sessions { display: flex; flex-direction: column; gap: 8px; }
.sess-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
}
.sess-item.is-current { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: color-mix(in srgb, var(--success) 5%, var(--surface)); }
.sess-ico {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 9px; background: var(--surface-sunken); color: var(--fg-muted);
}
.sess-ico svg { width: 17px; height: 17px; }
.sess-main { min-width: 0; flex: 1; }
.sess-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sess-name { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.sess-detail { font-size: 12px; color: var(--fg-muted); margin-top: 3px; line-height: 1.5; }
/* La IP va en su propia línea y nunca se parte a la mitad (sobre todo IPv6). */
.sess-ip { display: inline-block; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sess-when { font-size: 11.5px; color: var(--fg-subtle, var(--fg-muted)); margin-top: 3px; }
.sess-empty { padding: 14px; font-size: 12.5px; color: var(--fg-muted); text-align: center; }
.sess-skel { opacity: .7; }
.sess-skel .sess-ico { background: var(--surface-sunken); }
.sess-skel .sk-line { display: block; height: 10px; border-radius: 5px; background: var(--surface-sunken); margin: 4px 0; }
.sess-skel .sk-line.w40 { width: 40%; } .sess-skel .sk-line.w70 { width: 70%; }

/* ─── Campos de formulario ─── */
.set-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.set-fields.one { grid-template-columns: 1fr; }
/* Mismo aire entre bloques de campos que dentro de cada bloque: si no, la
   pista de un campo queda pegada a la etiqueta del siguiente. */
.set-fields + .set-fields { margin-top: 14px; }
@media (max-width: 620px) { .set-fields { grid-template-columns: 1fr; } }
.set-field { min-width: 0; }
.set-field > label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--fg); margin-bottom: 6px;
}
.set-field > label .opt { color: var(--fg-faint); font-weight: 400; }
.set-ctl-wrap { position: relative; }
.set-ctl-wrap > .ic {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--fg-faint); pointer-events: none;
}
.set-ctl-wrap > .ic + input,
.set-ctl-wrap > .ic + select { padding-left: 34px; }
.set-field input,
.set-field select,
.set-field textarea {
  width: 100%; min-height: 42px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg); font: inherit; font-size: 13.5px;
}
.set-field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.set-field select {
  appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}
.set-field input:focus,
.set-field select:focus,
.set-field textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.set-field input:disabled { color: var(--fg-muted); cursor: not-allowed; opacity: .8; }
.set-field .hint { font-size: 11.5px; color: var(--fg-faint); margin-top: 5px; line-height: 1.4; }

/* ─── Avatar de perfil ─── */
.set-profile { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.set-ava {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--fg);
  color: var(--surface); display: grid; place-items: center;
  font-weight: 600; font-size: 20px; flex-shrink: 0; overflow: hidden;
}
.set-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.set-profile-meta { min-width: 0; flex: 1; }
.set-profile-meta .nm { font-size: 15px; font-weight: 650; color: var(--fg); }
.set-profile-meta .em { font-size: 12.5px; color: var(--fg-muted); margin-top: 1px; }
.set-profile-meta .since { font-size: 11.5px; color: var(--fg-faint); margin-top: 2px; }

/* ─── Botones auxiliares ─── */
.set-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.btn-accent { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

/* ─── Insignias de estado ─── */
.set-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.set-badge.ok { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.set-badge.off { background: var(--surface-sunken); color: var(--fg-muted); }
.set-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ─── Facturación: plan ─── */
.set-plan {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.set-plan-ico {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.set-plan-ico svg { width: 24px; height: 24px; }
.set-plan-main { min-width: 0; flex: 1; }
.set-plan-main h3 { margin: 0; font-size: 16px; font-weight: 650; color: var(--fg); }
.set-plan-main p { margin: 3px 0 10px; font-size: 13px; color: var(--fg-muted); }
.set-plan-feats { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.set-plan-feats .ft { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg); }
.set-plan-feats .ft svg { width: 15px; height: 15px; color: var(--accent); }
.set-plan-side { text-align: right; flex-shrink: 0; }
.set-plan-price { font-size: 20px; font-weight: 700; color: var(--fg); letter-spacing: -0.01em; }
.set-plan-price .per { font-size: 12px; font-weight: 500; color: var(--fg-muted); }
.set-plan-next { font-size: 11.5px; color: var(--fg-faint); margin-top: 2px; }
.set-plan-btns { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
@media (max-width: 640px) {
  .set-plan { flex-direction: column; }
  .set-plan-side { text-align: left; }
  .set-plan-btns { justify-content: flex-start; flex-wrap: wrap; }
}

/* Método de pago */
.set-pay {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.set-pay-brand {
  width: 44px; height: 30px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center;
  background: #1434cb; color: #fff; font-weight: 800; font-size: 11px;
  font-style: italic; letter-spacing: .03em;
}
.set-pay-num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; color: var(--fg); }
.set-pay-exp { font-size: 12px; color: var(--fg-muted); margin-left: auto; }

/* Historial / tabla de facturas */
.set-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.set-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--fg-faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.set-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); color: var(--fg); }
.set-table tr:last-child td { border-bottom: 0; }
.set-table .amt { font-variant-numeric: tabular-nums; }
.set-table-wrap { overflow-x: auto; }

/* ─── Integraciones ─── */
.set-intg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px;
}
.set-intg {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.set-intg-ico {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-size: 17px;
  /* Fondo blanco también en modo oscuro: los logotipos usan sus colores de marca. */
  background: #fff; border: 1px solid var(--border);
}
.set-intg-ico svg { width: 19px; height: 19px; display: block; }
.set-intg .btn[disabled] { opacity: .65; cursor: not-allowed; pointer-events: none; gap: 6px; }
.set-intg h4 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--fg); }
.set-intg p { margin: 0; font-size: 12px; color: var(--fg-muted); line-height: 1.4; flex: 1; }
.set-intg .btn { width: 100%; margin-top: 2px; }

/* Fila de integración conectada */
.set-conn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.set-conn-ico {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 18px;
  background: var(--surface); border: 1px solid var(--border);
}
.set-conn-main { min-width: 0; flex: 1; }
.set-conn-main .tt { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.set-conn-main .ds { font-size: 12px; color: var(--fg-muted); margin-top: 1px; }

/* ─── Miembros del equipo ─── */
.set-invite { display: grid; grid-template-columns: 1fr 150px auto; gap: 8px; margin-bottom: 14px; }
@media (max-width: 560px) { .set-invite { grid-template-columns: 1fr; } }
.set-invite input, .set-invite select {
  height: 40px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--fg); font: inherit; font-size: 13.5px;
}
.set-invite select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.set-member { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.set-member:last-child { border-bottom: 0; }
.set-member .avatar-sm { width: 36px; height: 36px; }
.set-member-main { min-width: 0; flex: 1; }
.set-member-main .nm { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.set-member-main .em { font-size: 12px; color: var(--fg-muted); }

/* Selector de tema con pastillas */
.set-seg { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-sunken); border-radius: 10px; }
.set-seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 8px;
  font: inherit; font-size: 12.5px; font-weight: 500; color: var(--fg-muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.set-seg button svg { width: 14px; height: 14px; }
.set-seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }

/* ─── Teléfonos estrechos ─── */
/* Los controles anchos (desplegables y el selector de tema) bajan a una línea
   propia, a todo el ancho, para que el título no quede apretado. Los
   interruptores (pequeños) se mantienen en línea. */
@media (max-width: 560px) {
  .set-row:has(select),
  .set-row:has(.set-seg) { flex-wrap: wrap; row-gap: 10px; }
  .set-row:has(select) .set-row-ctl,
  .set-row:has(.set-seg) .set-row-ctl {
    flex-basis: calc(100% - 44px);  /* resta el sangrado para no desbordar */
    margin-left: 44px;              /* alinea con el texto (icono 30 + gap 14) */
  }
  .set-row-ctl select { max-width: none; width: 100%; }
  .set-row:has(.set-seg) .set-seg { width: 100%; }
  .set-row:has(.set-seg) .set-seg button { flex: 1; justify-content: center; }
}
/* Respaldo para navegadores sin :has() — desplegables algo más angostos. */
@supports not selector(:has(*)) {
  @media (max-width: 560px) { .set-row-ctl select { max-width: 150px; } }
}

/* ─── Estado vacío (sin plan de pago, sin facturas, sin método de pago) ─── */
.set-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: 26px 16px;
  border: 1px dashed var(--border-strong); border-radius: 12px;
  background: var(--surface-2);
}
.set-empty-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 6px;
}
.set-empty-ico svg { width: 22px; height: 22px; }
.set-empty h3 { margin: 0; font-size: 15px; font-weight: 650; color: var(--fg); }
.set-empty p { margin: 0; max-width: 420px; font-size: 13px; line-height: 1.5; color: var(--fg-muted); }
.set-empty .set-foot { justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.set-empty.compact { padding: 18px 14px; }
.set-empty.compact h3 { font-size: 13.5px; }

/* ─── Foto de perfil: acciones y estado de subida ─── */
.set-profile-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.set-ava.busy { opacity: .55; }
@media (max-width: 560px) {
  .set-profile { flex-wrap: wrap; }
  .set-profile-acts { width: 100%; justify-content: flex-start; }
}

/* ─── Carga inicial de Configuración ─── */
.set-loading { padding: 40px 16px; text-align: center; color: var(--fg-muted); font-size: 13.5px; }

/* ─── Teléfonos Android / pantallas pequeñas ───
   Solo afecta a ≤560px: el escritorio no cambia. En las cajas y filas con
   botón (Contraseña, 2FA, Sesiones, Descargar datos, Eliminar cuenta,
   Aplicaciones conectadas, Claves de API…) el control baja a su propia línea
   para que el texto use todo el ancho y no quede en una columna estrecha. */
@media (max-width: 560px) {
  .set-card-body { padding: 4px 14px 12px; }
  .set-card-body.pad { padding: 14px; }

  .set-box { flex-wrap: wrap; row-gap: 10px; padding: 12px 14px; }
  .set-box .set-row-main { flex: 1 1 calc(100% - 44px); }
  .set-box .set-row-ctl {
    flex-basis: calc(100% - 44px);
    margin-left: 44px;               /* alinea con el texto (icono 30 + gap 14) */
    flex-wrap: wrap;
  }
  .set-box .set-row-ctl .btn { flex: 1 1 auto; justify-content: center; }

  .set-row:has(.set-row-ctl .btn) { flex-wrap: wrap; row-gap: 10px; }
  .set-row:has(.set-row-ctl .btn) .set-row-ctl { flex-basis: calc(100% - 44px); margin-left: 44px; }
  .set-row:has(.set-row-ctl .btn) .set-row-ctl .btn { flex: 1 1 auto; justify-content: center; }

  /* Integraciones: dos columnas compactas */
  .set-intg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .set-intg { padding: 12px; }
  .set-intg .btn { padding-left: 8px; padding-right: 8px; font-size: 12.5px; }
}
@media (max-width: 340px) {
  .set-intg-grid { grid-template-columns: 1fr; }
}

/* Interruptores en gris oscuro: la bolita usa el color de superficie para que
   contraste también en modo oscuro (donde el gris del acento es claro). */
.set-wrap .switch.on::after { background: var(--surface); }

