/* -------------------------------------------------------------------------
   GestFel CSS · 20-forms-auth.css
   Formularios compactos, login, logos, recargas y ajustes previos de listados.
   Orden de carga: respetar la numeración de los ficheros para conservar
   la cascada original y evitar regresiones visuales.
   ------------------------------------------------------------------------- */

@layer forms {

/* Ajustes responsive del panel */
.app-top,
.app-shell,
.app-main,
.card,
.table-wrap,
.chart-canvas {
  min-width: 0;
}
.table-wrap {
  width: 100%;
  overflow-x: auto;
}
.kpi {
  display: grid;
  gap: 0.25rem;
  align-content: start;
}
.kpi > span {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.2;
}
@media (max-width: 720px) {
  .app-top {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    display: grid;
    gap: 0.5rem;
    padding: 0 12px;
  }
  .app-top .brand {
    justify-self: center;
    min-width: 0;
    gap: 0.45rem;
  }
  .app-top .brand strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .user-chip {
    justify-self: end;
    gap: 0.35rem;
    align-items: center;
  }
  .user-chip .avatar,
  .user-chip .account-link[aria-label] {
    display: none;
  }
  .user-chip .account-link,
  .user-chip .logout {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 0.35rem 0.45rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
  }
  .user-chip .account-link {
    color: var(--teal);
    background: var(--mint);
  }
  .user-chip .logout {
    color: #9d241b;
    background: #fff1f2;
  }
  .app-main {
    padding: 18px 14px;
  }
  .page-head {
    gap: 0.85rem;
    margin-bottom: 1rem;
  }
  .page-head h1 {
    font-size: clamp(1.9rem, 9vw, 2.35rem);
    line-height: 1.05;
  }
  .page-head p {
    margin: 0.35rem 0 0;
  }
  .page-head .btn,
  .page-head .button {
    width: auto;
    max-width: 100%;
  }
  .kpis,
  .metric-grid,
  .compact-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
  .kpi,
  .metric {
    padding: 0.9rem;
    min-height: 112px;
  }
  .kpi-icon {
    width: 38px;
    height: 38px;
    padding: 9px;
    margin-bottom: 0.45rem;
  }
  .metric strong,
  .kpi strong {
    font-size: clamp(1.35rem, 7vw, 1.8rem);
    line-height: 1.05;
    overflow-wrap: anywhere;
  }
  .card {
    padding: 1rem;
    border-radius: 16px;
  }
  .card h2 {
    font-size: clamp(1.35rem, 7vw, 1.85rem);
    line-height: 1.1;
    margin-top: 0;
  }
  .table {
    min-width: 640px;
    font-size: 0.86rem;
  }
  .table th,
  .table td {
    padding: 0.7rem 0.65rem;
  }
  .chart-legend {
    gap: 0.45rem 0.75rem;
    font-size: 0.86rem;
  }
  .chart-canvas {
    height: 240px;
  }
  .actions .btn,
  .actions .button {
    min-height: 46px;
  }
}
@media (max-width: 380px) {
  .kpis,
  .metric-grid,
  .compact-kpis {
    grid-template-columns: 1fr;
  }
  .page-head .btn,
  .page-head .button {
    width: 100%;
  }
}

/* Formularios compactos y códigos autogenerados */
.entity-form {
  max-width: 920px;
  margin-inline: auto;
  gap: 0.85rem;
}
.entity-form .field-group,
.entity-form .readonly-code {
  position: relative;
  border-color: color-mix(in srgb, var(--teal) 18%, var(--line));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(248, 253, 251, .98)),
    var(--soft);
  box-shadow: 0 10px 26px rgba(15, 36, 55, .06);
}
.entity-form .field-group {
  padding: 1.15rem;
  margin-top: .25rem;
}
.entity-form .field-group + .field-group,
.entity-form .readonly-code + .field-group {
  margin-top: .45rem;
}
.entity-form .field-group legend {
  padding: 0 .55rem;
  letter-spacing: .01em;
}
.entity-form .field-group label {
  display: grid;
  gap: .35rem;
}
.entity-form .field-group label:has(input[type="checkbox"]),
.entity-form .field-group .check-row,
.entity-form .field-group .recipient-option {
  display: flex;
  align-items: center;
  gap: .55rem;
  max-width: 100%;
  min-width: 0;
}

.entity-form .field-group label:has(input[type="checkbox"]) {
  justify-content: flex-start;
  overflow-wrap: anywhere;
}

.entity-form .field-group label:has(input[type="checkbox"]) input[type="checkbox"] {
  flex: 0 0 auto;
}
.entity-form .field-group .recipient-option {
  align-items: flex-start;
}
.form-grid-balanced.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form input:not([type="checkbox"]):not([type="file"]),
.form select {
  min-height: 42px;
  height: 42px;
  padding: 0.55rem 0.7rem;
}
.form textarea {
  min-height: 84px;
  padding: 0.65rem 0.75rem;
  resize: vertical;
}

.readonly-code {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem 0.85rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--soft);
}
.readonly-code strong {
  color: var(--muted);
  font-size: 0.9rem;
}
.readonly-code span {
  color: var(--teal);
  font-weight: 900;
}
.compact-checks label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 42px;
}
.compact-checks input[type="checkbox"] {
  width: 18px;
  height: 18px;
}
.general-notes {
  margin-bottom: 1rem;
}
.general-notes p {
  margin: 0.35rem 0 0;
  line-height: 1.5;
}
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  align-items: start;
}
.photo-card {
  display: grid;
  gap: 0.65rem;
}
.photo-card .cat-photo {
  width: 100%;
  height: 120px;
  border-radius: 12px;
}
.photo-card strong {
  display: block;
  font-size: 0.95rem;
}
.photo-card .badge {
  margin-top: 0.35rem;
}
.photo-delete {
  margin-top: 1.2rem;
}
.photo-delete form {
  margin-top: 0.8rem;
}
.photo-edit-preview {
  width: 100%;
  height: min(520px, 55vw);
  border-radius: 14px;
}
@media (max-width: 760px) {
  .entity-form {
    max-width: 100%;
  }
  .form-grid-balanced.grid.two {
    grid-template-columns: 1fr;
  }
  .form input:not([type="checkbox"]):not([type="file"]),
  .form select {
    height: 40px;
    min-height: 40px;
  }
  .form textarea {
    min-height: 76px;
  }
}

/* Login privado */
.login-page {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at top left,
      rgba(34, 182, 166, 0.12),
      transparent 34%
    ),
    linear-gradient(135deg, #e6f4f1 0%, #fff 70%);
}
.login-card {
  width: min(520px, 100%);
  min-height: auto;
  padding: 42px 42px 34px;
  display: grid;
  gap: 16px;
  align-content: start;
  justify-content: stretch;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 36, 55, 0.12);
}
.login-card h1 {
  margin: 0;
  font-size: clamp(2.25rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}
.login-card p {
  margin: 0 0 6px;
  max-width: 390px;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--dark);
}
.login-card label {
  margin-top: 4px;
  display: grid;
  gap: 0.4rem;
  font-weight: 850;
  font-size: 1rem;
}
.login-card input {
  width: 100%;
  height: 48px;
  min-height: 48px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  background: #fff;
}
.login-card input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(11, 125, 109, 0.12);
  outline: 0;
}
.login-card .button,
.login-card button,
.login-card input[type="submit"] {
  justify-self: center;
  width: min(280px, 100%);
  min-width: 0;
  min-height: 52px;
  margin-top: 8px;
  border-radius: 12px;
  font-weight: 850;
}
.login-card > a {
  justify-self: center;
  margin-top: 2px;
  color: var(--teal);
  font-weight: 850;
  text-align: center;
}
.login-card .muted {
  font-size: 0.95rem;
}
@media (max-width: 720px) {
  .login-page {
    padding: 18px;
    place-items: center;
  }
  .login-card {
    width: 100%;
    max-width: 460px;
    padding: 30px 24px;
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(15, 36, 55, 0.1);
  }
  .login-card h1 {
    font-size: 2.15rem;
  }
  .login-card p {
    font-size: 1rem;
  }
  .login-card .button,
  .login-card button,
  .login-card input[type="submit"] {
    width: 100%;
  }
}

/* Logo de la barra superior */

.public-nav .brand img,
.app-top .brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}

.public-nav .brand strong,
.app-top .brand strong {
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.02em;
}

/* Logo de instalación y login */
.login-card img {
  justify-self: center;
  display: block;
  width: 82px !important;
  height: auto !important;
  object-fit: contain;
  margin-bottom: 8px;
}

/* Ajuste responsive del logo */
@media (max-width: 720px) {
  .public-nav .brand img,
  .app-top .brand img {
    width: 42px;
    height: 42px;
  }

  .public-nav .brand strong,
  .app-top .brand strong {
    font-size: 1.12rem;
  }

  .login-card img {
    width: 72px !important;
  }
}

/* -------------------------------------------------------------------------
   Tablas y listados · base común
   La estructura responsive y las acciones se gobiernan en 60-responsive-tables-actions.css.
   Aquí solo queda la base mínima compartida.
   ------------------------------------------------------------------------- */
.table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: auto;
}
.table th,
.table td {
  display: table-cell;
  float: none;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
.table th,
.table td:not(.actions) {
  max-width: 26rem;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

/* Portada pública: hero y preview */
.public-hero {
  grid-template-columns: minmax(0, 0.85fr) minmax(580px, 1.15fr);
}

.public-hero .public-preview {
  grid-template-columns: minmax(130px, 180px) minmax(0, 1fr);
}

.public-hero .preview-content .grid.four {
  grid-template-columns: repeat(4, minmax(105px, 1fr));
}

@media (max-width: 1100px) {
  .public-hero {
    grid-template-columns: 1fr;
  }
}

/* Recargas de pienso y barra de plazo estimado */
.food-status-bar {
  width: 100%;
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f2f4f7;
  box-shadow: inset 0 1px 2px rgba(15, 36, 55, 0.06);
}
.food-status-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 0.25s ease;
}
.food-status-atencion {
  background: #f59e0b;
}
.food-status-urgente,
.food-status-agotado {
  background: #ef4444;
}
.food-status-sin_recarga,
.food-status-sin_censo {
  background: #98a2b3;
}
.feeding-indicator .food-status-bar {
  margin: 0.75rem 0 1rem;
}


/* Histórico de recargas de pienso */
.muted {
  color: var(--muted);
}
.feeding-entry-grid {
  margin-top: 1rem;
  align-items: start;
}
.feeding-history-card {
  margin-top: 1rem;
}
.feeding-table {
  min-width: 980px;
}
.feeding-table th {
  white-space: nowrap;
}
.feeding-table td {
  vertical-align: top;
}
.feeding-table td:nth-child(7),
.feeding-table td:nth-child(9) {
  min-width: 12rem;
}
.feeding-table .badge {
  white-space: nowrap;
}
@media (max-width: 720px) {
  .feeding-table {
    min-width: 0;
  }
  .feeding-table td:nth-child(7),
  .feeding-table td:nth-child(9) {
    min-width: 0;
  }
  .feeding-table td[data-label="Notas"],
  .feeding-table td[data-label="Tipo"] {
    align-items: start;
  }
}
} /* end @layer forms */
