/* Joseteasiste — prototipo de plataforma (MOCK estático, sin auth real).
   Reusa variables/base de ../styles.css. Solo estilos propios del prototipo:
   acceso (login/alta/recuperar), tabs, Mis Robots y Movimientos. */

.app-main { min-height: calc(100vh - 66px); padding: 28px 20px 60px; background: var(--bg-alt); }

/* Aviso permanente: prototipo, no autentica de verdad. */
.mock-note {
  max-width: 760px; margin: 0 auto 22px;
  background: #fff6e5; border: 1px solid #f0d9a8; color: #6a4b12;
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: .85rem; text-align: center;
}

.brand-center { justify-content: center; display: flex; margin-bottom: 18px; }
.nav-logout {
  background: transparent; border: 1px solid var(--border); color: var(--brand-dark);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font: inherit; font-size: .9rem;
}
.nav-logout:hover { border-color: var(--brand); }

/* ===================== VISTA ACCESO ===================== */
.auth-wrap { width: 100%; max-width: 460px; margin: 0 auto; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 28px;
}
.auth-tabs { display: flex; gap: 4px; margin-bottom: 22px; background: var(--bg-alt);
  border-radius: 999px; padding: 4px; }
.auth-tab {
  flex: 1; border: none; background: transparent; color: var(--muted);
  padding: 8px 6px; border-radius: 999px; cursor: pointer; font: inherit;
  font-size: .82rem; font-weight: 600; line-height: 1.2;
}
.auth-tab.is-active { background: var(--surface); color: var(--brand-dark); box-shadow: var(--shadow-sm); }

.auth-panel { display: none; }
.auth-panel.is-active { display: block; }
.auth-h1 { font-size: 1.5rem; text-align: center; margin-bottom: .3em; }
.auth-sub { color: var(--muted); text-align: center; font-size: .92rem; margin-bottom: 22px; }
.auth-mail { font-weight: 700; color: var(--text); }

.auth-icon {
  width: 56px; height: 56px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; margin: 0 auto 14px;
  font-size: 1.6rem; background: var(--brand-soft); color: var(--brand-dark);
}

.auth-help { font-size: .85rem; color: var(--muted); text-align: center; margin-top: 16px; }
.auth-help a { font-weight: 600; }

/* Campos de formulario (login/alta/recuperar) */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 1rem; font-family: var(--font);
  color: var(--text); background: #fff;
}
.field input:focus { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field-hint { font-size: .78rem; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); }
.btn-block { width: 100%; }

/* Switcher de prototipo */
.demo-switch {
  margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--border);
  text-align: center; font-size: .8rem; color: var(--muted);
}
.demo-switch span { display: block; margin-bottom: 8px; font-weight: 600; }
.demo-switch button {
  background: transparent; border: 1px solid var(--border); color: var(--brand-dark);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; font: inherit; font-size: .82rem;
}
.demo-switch button:hover { border-color: var(--brand); }

/* ===================== VISTA PLATAFORMA ===================== */
.app-wrap { max-width: 1100px; margin: 0 auto; }
.app-head { margin-bottom: 18px; }
.app-title { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-bottom: .15em; }

.app-tabs { display: inline-flex; gap: 4px; margin-bottom: 22px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.app-tab {
  border: none; background: transparent; color: var(--muted);
  padding: 9px 20px; border-radius: 999px; cursor: pointer; font: inherit;
  font-size: .9rem; font-weight: 600;
}
.app-tab.is-active { background: var(--brand); color: #fff; }

.app-panel { display: none; }
.app-panel.is-active { display: block; }
.panel-h { margin-bottom: .3em; }

/* ---- Mis Robots ---- */
.robot-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.robot-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px;
  display: flex; flex-wrap: wrap; gap: 14px 24px; justify-content: space-between; align-items: flex-start;
}
.robot-item.is-paused { opacity: .72; }
.robot-info { flex: 1 1 260px; min-width: 220px; }
.robot-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.robot-name { font-size: 1.08rem; margin: 0; }
.robot-state {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark);
}
.robot-item.is-paused .robot-state { background: #f0eef0; color: var(--muted); }
.robot-desc { color: var(--muted); font-size: .9rem; margin: 0; }
.robot-channels { display: grid; gap: 8px; flex: 0 0 auto; }
.chk { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.chk input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.robot-note { margin: .6rem 0 0; font-size: .84rem; color: var(--brand-dark); }

.legal-stack { display: grid; gap: 14px; margin-top: 18px; }
.legal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.legal-card h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.legal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
  margin-top: 14px;
}
.legal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 14px;
}
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.status-pill.is-ok { background: #e6f6ef; color: #136b45; }
.status-pill.is-warn { background: #fff4df; color: #996515; }
.status-pill.is-idle { background: #eef2f5; color: #5b6770; }
/* denied = precondición faltante (p.ej. sin container vinculado), distinto de is-warn
   (algo pendiente de confirmar) y de is-error (falla real del backend). */
.status-pill.is-denied { background: #f4eef7; color: #6a4c8a; border: 1px dashed #c9b3dd; }
.cred-summary {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #dbe4ea;
}
.cred-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  font-size: .88rem;
}
.cred-row strong { color: var(--brand-dark); }
.fav-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.fav-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.fav-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.fav-name { margin: 0; font-size: .98rem; }
.fav-kind {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.fav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}
.fav-remove {
  border: 1px solid #d6dde3;
  background: transparent;
  color: #55626c;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
}
.fav-remove:hover { border-color: #b8c6d0; }
.fav-empty {
  text-align: center;
  padding: 14px;
  border: 1px dashed #cfd8df;
  border-radius: 12px;
  color: var(--muted);
  font-size: .88rem;
  background: #fbfcfd;
}

/* ---- PJN: banner demo + estado de container ---- */
.legal-demo-banner {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border: 1px solid #ffe1b0;
  border-left: 4px solid #e0952a;
  background: #fff8ec;
  border-radius: 10px;
  color: #6b4c1a;
  font-size: .86rem;
  line-height: 1.5;
}
.legal-demo-banner code { background: #fdeccf; padding: 1px 5px; border-radius: 5px; font-size: .82em; }
.fav-item.is-nocontainer { border-color: #f0d49a; background: #fffdf8; }
.fav-container-row { margin-top: 10px; }
.fav-cta { padding: 7px 14px; font-size: .84rem; }
.fav-container-ok { font-size: .83rem; color: #136b45; font-weight: 600; }
.fav-manual { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.fav-manual > summary {
  cursor: pointer;
  font-size: .86rem;
  color: var(--brand-dark);
  font-weight: 600;
  list-style: revert;
}
.fav-manual[open] > summary { margin-bottom: 10px; }

/* ---- PJN: tabla de favoritos (contrato causa-madre / incidentes 2026-07-04) ---- */
.fav-table-wrap { margin-top: 12px; }
.fav-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .9rem; min-width: 1080px; }
.fav-table th, .fav-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: break-word; }
.fav-table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg-alt); font-weight: 700; }
.fav-table th.th-center, .fav-table td.col-activo { text-align: center; }
.fav-table tbody tr:last-child td { border-bottom: none; }
.fav-table tr.is-nocontainer { background: #fffdf8; }
.fav-empty-cell { text-align: center; padding: 18px; color: var(--muted); font-size: .88rem; }
.col-caratula { max-width: 260px; }
.fav-alias { display: block; font-weight: 700; color: var(--brand-dark); }
.fav-caratula { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.col-container .cid { display: block; margin-top: 4px; font-size: .72rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.col-sync { font-size: .82rem; color: var(--muted); }
/* agrupación por familia (causa madre + incidentes). flex + wrap: con "Crear container" +
   "Descargar familia ahora" + "Descargar container ahora" puede haber hasta 3 botones; en vez de
   float (que se pisaba con fam-meta en pantallas angostas), envuelven a una segunda línea. */
.fav-table tr.fam-group td.fam-head { background: #eef4f8; border-bottom: 2px solid #cdd9e1; padding: 9px 12px; font-size: .84rem; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.fam-badge { display: inline-block; font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: #fff; background: var(--brand, #0e7c86); border-radius: 999px; padding: 2px 8px; margin-right: 6px; }
.fam-meta { color: var(--muted); font-size: .78rem; }
.fam-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.fav-table tr.fav-row.is-madre td.col-exp { border-left: 3px solid var(--brand, #0e7c86); }
.fav-table tr.fav-row.is-revision { background: #fffaf0; }
.col-exp { max-width: 220px; }
.col-exp strong { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }
.exp-tag { display: inline-block; margin-top: 3px; font-size: .68rem; font-weight: 700; border-radius: 6px; padding: 1px 7px; }
.exp-tag.exp-madre { background: #e6f6ef; color: #136b45; }
.exp-tag.exp-inc { background: #eef2f5; color: #47566a; }
.exp-ref { display: block; margin-top: 3px; font-size: .7rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.col-dep, .col-situacion { font-size: .82rem; }
.col-actu { font-size: .8rem; color: var(--muted); }
.col-familia code { font-size: .74rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.chk-center { justify-content: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-xs { padding: 5px 10px; font-size: .78rem; border-width: 1px; }
.fav-remove.btn-xs { padding: 5px 10px; font-size: .78rem; }
/* Acción deshabilitada (denied): visualmente apagada + cursor honesto; el motivo va en el
   atributo title del botón (tooltip nativo), nunca se oculta ni se muestra como si funcionara. */
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn[disabled]:hover, .btn:disabled:hover { transform: none; }

/* ---- PJN: estados cargando / error reales (borde async del cliente) ---- */
.pjn-alert {
  margin: 12px 0 4px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid #f2c2c2; border-left: 4px solid #d64545;
  background: #fdecec; color: #8a2b2b; font-size: .86rem; line-height: 1.45;
}
.pjn-loading { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: .84rem; color: var(--muted); }
.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #cfd8df; border-top-color: var(--brand);
  display: inline-block; animation: pjn-spin .7s linear infinite;
}
@keyframes pjn-spin { to { transform: rotate(360deg); } }
#pjn-panel.is-loading { position: relative; }
#pjn-panel.is-loading .fav-table { opacity: .55; transition: opacity .15s ease; }
.status-pill.is-error { background: #fdecec; color: #8a2b2b; }

.pjn-run-panel {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: #f7fafc; border: 1px solid #dbe4ea;
}
.pjn-run-panel .run-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.pjn-run-panel p { margin: 4px 0 0; }

/* ---- Movimientos ---- */
.table-scroll { overflow-x: auto; margin-top: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.mov-table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 560px; }
.mov-table th, .mov-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.mov-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg-alt); }
.mov-table tbody tr:last-child td { border-bottom: none; }
.mov-table tbody tr:hover { background: var(--bg-alt); }
.nowrap { white-space: nowrap; }

.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.tag-carga { background: #e3f4f5; color: var(--brand-dark); }
.tag-consulta { background: #eef0ff; color: #4a4fb0; }

@media (max-width: 560px) {
  .robot-channels { width: 100%; }
  .auth-tab { font-size: .76rem; }
  .cred-row,
  .fav-top { display: block; }
}
