/* Equipos (assets-manage): barra de filtros, KPI, tabla enriquecida y resumen lateral.
   Las clases llevan el prefijo am- para no chocar con el resto de módulos.
   Nota: todo-list.css fuerza .hidden{display:none!important}, por eso aquí se usa el atributo [hidden]
   y las consultas de medios en lugar de variantes responsive de Tailwind para mostrar/ocultar. */

#assets-manage-view [hidden] { display: none !important; }

/* ---------- Cabecera ---------- */
.am-search { position: relative; min-width: 0; }
.am-search svg { position: absolute; top: 50%; left: 0.75rem; width: 1rem; height: 1rem; color: #94a3b8; transform: translateY(-50%); pointer-events: none; }
.am-search .gmao-input { box-sizing: border-box; width: 100%; height: 2.5rem; padding: 0.5rem 0.75rem 0.5rem 2.25rem; border: 1px solid #e2e8f0; border-radius: 0.75rem; color: #334155; background: #f8fafc; font-size: 0.8125rem; }
.am-search .gmao-input:focus { background: #fff; border-color: #93c5fd; outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }
.am-search-btn { position: relative; height: 2.5rem; padding: 0 1rem; align-items: center; font-size: 0.8125rem; white-space: nowrap; }
.am-dirty-dot { position: absolute; top: -0.25rem; right: -0.25rem; width: 0.625rem; height: 0.625rem; border: 2px solid #fff; border-radius: 50%; background: #f59e0b; }
.am-count { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.75rem; border: 1px solid #f1f5f9; border-radius: 999px; background: #f8fafc; color: #475569; font-size: 0.625rem; font-weight: 800; letter-spacing: 0.08em; }
.am-view-toggle { display: flex; align-items: center; padding: 0.25rem; border-radius: 0.75rem; background: #f1f5f9; }
.am-action { height: 2.5rem; padding: 0 0.875rem; align-items: center; white-space: nowrap; }

.am-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.am-chip-wrap { position: relative; }
.am-chip { display: inline-flex; align-items: center; gap: 0.375rem; height: 2.25rem; padding: 0 0.75rem; border: 1px solid #e2e8f0; border-radius: 0.75rem; background: #fff; color: #475569; font-size: 0.75rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
.am-chip:hover { border-color: #93c5fd; }
.am-chip svg { flex: none; width: 0.875rem; height: 0.875rem; }
.am-chip .am-chev { width: 0.75rem; height: 0.75rem; color: #94a3b8; }
.am-chip[data-active="true"] { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.am-chip-value { font-weight: 800; }
.am-chip:focus-visible, .am-reset:focus-visible, .am-kpi:focus-visible, .am-row:focus-visible, .am-token button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.am-chip-link { display: none; text-decoration: none; }
.am-reset { height: 2.25rem; padding: 0 0.5rem; border: 0; background: transparent; color: #64748b; font-size: 0.75rem; font-weight: 700; cursor: pointer; }
.am-reset:hover { color: #1e293b; }

.am-menu { position: absolute; top: calc(100% + 0.375rem); left: 0; z-index: 60; min-width: 15rem; padding: 0.5rem; border: 1px solid #e2e8f0; border-radius: 0.875rem; background: #fff; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14); }
.am-menu-title { display: none; margin: 0 0 0.5rem; padding: 0 0.25rem; color: #0f172a; font-size: 0.9375rem; font-weight: 800; }
.am-option { display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem 0.625rem; border-radius: 0.625rem; color: #334155; font-size: 0.8125rem; cursor: pointer; }
.am-option:hover { background: #f1f5f9; }
.am-option input { flex: none; width: 0.9375rem; height: 0.9375rem; margin: 0; accent-color: #2563eb; }
.am-menu-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.375rem; padding: 0.5rem 0.25rem 0; border-top: 1px solid #f1f5f9; }
.am-menu-foot [data-menu-clear] { border: 0; background: transparent; color: #64748b; font-size: 0.75rem; font-weight: 700; cursor: pointer; }
.am-menu-foot [data-menu-clear]:hover { color: #1e293b; }
.am-menu-foot .gmao-btn { align-items: center; height: 2rem; padding: 0 0.875rem; font-size: 0.75rem; border-radius: 0.625rem; }

.am-tokens { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.am-token { display: inline-flex; align-items: center; gap: 0.25rem; max-width: 100%; padding: 0.125rem 0.25rem 0.125rem 0.625rem; border: 1px solid #e2e8f0; border-radius: 0.5rem; background: #f8fafc; color: #334155; font-size: 0.6875rem; font-weight: 600; }
.am-token-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-token button { padding: 0 0.375rem; border: 0; border-radius: 0.375rem; background: transparent; color: #94a3b8; font-size: 0.875rem; line-height: 1.25rem; cursor: pointer; }
.am-token button:hover { background: #e2e8f0; color: #334155; }

.am-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, 0.45); }

/* ---------- KPI ---------- */
.am-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.625rem; }
.am-kpi { display: flex; flex-direction: column; gap: 0.125rem; padding: 0.625rem 0.75rem; border: 1px solid #e2e8f0; border-radius: 0.875rem; background: #fff; text-align: left; cursor: pointer; transition: border-color 150ms ease, box-shadow 150ms ease; }
.am-kpi:hover { border-color: #93c5fd; }
.am-kpi small { color: #64748b; font-size: 0.6875rem; font-weight: 600; }
.am-kpi b { color: #0f172a; font-size: 1.375rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.am-kpi[aria-pressed="true"] { border-color: #2563eb; box-shadow: inset 0 0 0 1px #2563eb; }
.am-kpi[data-tone="good"] b { color: #059669; }
.am-kpi[data-tone="warn"] b { color: #b45309; }
.am-kpi[data-tone="bad"] b { color: #e11d48; }
.am-kpi[data-static="true"] { cursor: default; }
.am-kpi[data-static="true"]:hover { border-color: #e2e8f0; }
.am-kpi[data-loading="true"] b { color: #cbd5e1; }

/* ---------- Tabla ---------- */
.am-layout { display: flex; align-items: flex-start; gap: 1rem; }
.am-table td { vertical-align: middle; }
.am-table th, .am-table td { padding-right: 0.75rem; padding-left: 0.75rem; }
.am-table td:nth-child(2) { min-width: 10rem; }
.machine-table-criticality { white-space: nowrap; }
/* Con el resumen lateral abierto se ocultan las columnas que el panel ya muestra, para que la tabla quepa sin scroll. */
.am-layout[data-pane="open"] .am-col-secondary { display: none; }
.am-layout[data-pane="open"] .am-table { min-width: 640px; }
.am-layout[data-pane="open"] .am-table th, .am-layout[data-pane="open"] .am-table td { padding-right: 0.5rem; padding-left: 0.5rem; }
.am-layout[data-pane="open"] .gmao-table.am-table td.machine-table-location { width: 11rem; max-width: 11rem; }
.gmao-table.am-table td.machine-table-location { width: 12rem; max-width: 12rem; }
@media (max-width: 1535px) { .am-col-wide { display: none; } }
.am-row[aria-selected="true"] { background: #eff6ff; }
.am-crumbs { display: block; color: #64748b; font-size: 0.75rem; line-height: 1.3; overflow-wrap: break-word; }
.am-crumbs > * { white-space: nowrap; }
.am-crumbs b { color: #1e293b; font-weight: 700; }
.am-crumbs > * + *::before { content: "›"; margin: 0 0.3rem; color: #94a3b8; font-weight: 400; }

.am-crit { display: inline-flex; align-items: flex-end; gap: 2px; height: 0.875rem; }
.am-crit i { width: 4px; border-radius: 1px; background: #e2e8f0; }
.am-crit i:nth-child(1) { height: 0.25rem; } .am-crit i:nth-child(2) { height: 0.4375rem; } .am-crit i:nth-child(3) { height: 0.625rem; }
.am-crit i:nth-child(4) { height: 0.75rem; } .am-crit i:nth-child(5) { height: 0.875rem; }
.am-crit[data-tone="low"] i.on { background: #10b981; }
.am-crit[data-tone="mid"] i.on { background: #f59e0b; }
.am-crit[data-tone="high"] i.on { background: #f43f5e; }

.am-pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.125rem 0.5rem; border: 1px solid transparent; border-radius: 999px; font-size: 0.6875rem; font-weight: 700; white-space: nowrap; }
.am-pill[data-tone="good"] { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.am-pill[data-tone="warn"] { border-color: #fde68a; background: #fffbeb; color: #b45309; }
.am-pill[data-tone="bad"] { border-color: #fecdd3; background: #fff1f2; color: #be123c; }
.am-pill[data-tone="none"] { border-color: #e2e8f0; background: #f8fafc; color: #64748b; }
.am-pill[data-tone="acc"] { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.am-dot { width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: currentColor; }

.am-completeness { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.6875rem; font-weight: 600; color: #475569; }
.am-bar { display: inline-block; width: 3.75rem; height: 0.375rem; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.am-bar i { display: block; height: 100%; background: #10b981; }
.am-bar[data-tone="mid"] i { background: #f59e0b; }
.am-bar[data-tone="low"] i { background: #f43f5e; }
.machine-table-inspection[data-tone="warn"] { color: #b45309; }
.machine-table-inspection[data-tone="bad"] { color: #be123c; }
.machine-table-inspection[data-tone="good"], .machine-table-inspection[data-tone="none"] { color: #64748b; }

/* ---------- Resumen lateral ---------- */
.am-pane { position: sticky; top: 0; display: flex; flex: 0 0 18.5rem; width: 18.5rem; flex-direction: column; gap: 0.75rem; padding: 1rem; border: 1px solid #e2e8f0; border-radius: 1rem; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05); }
.am-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 0.5rem; margin: 0; padding-top: 0.75rem; border-top: 1px solid #f1f5f9; }
.am-kv dt { color: #94a3b8; font-size: 0.625rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.am-kv dd { margin: 0.125rem 0 0; color: #334155; font-size: 0.8125rem; font-weight: 600; overflow-wrap: anywhere; }
.am-kv .am-kv-wide { grid-column: 1 / -1; }
#machine-preview-open, #machine-preview-orders, #machine-preview-preventives { min-height: 2.25rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1279px) {
  .am-count { display: none; }
}
@media (max-width: 1023px) {
  .am-pane { display: none !important; }
  .am-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  #open-preventives-btn, #export-machines-btn { display: none; }
  .am-chip-link:not([hidden]) { display: inline-flex; }
  .am-view-toggle { display: none; }
  .am-action-label { display: none; }
  .am-action { width: 2.5rem; padding: 0; }
  #create-machine-btn .am-action-label { display: none; }
  .am-filter-bar > * { flex: none; }
  .am-filter-bar { flex-wrap: nowrap; margin: 0 -1rem; padding: 0 1rem 0.25rem; overflow-x: auto; scrollbar-width: none; }
  .am-filter-bar::-webkit-scrollbar { display: none; }
  .am-menu { position: fixed; top: auto; right: 0; bottom: 0; left: 0; z-index: 60; min-width: 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px)); border-radius: 1.25rem 1.25rem 0 0; box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.3); }
  .am-menu-title { display: block; }
  .am-option { padding: 0.75rem 0.5rem; font-size: 0.9375rem; }
  .am-option input { width: 1.125rem; height: 1.125rem; }
  .am-menu-foot .gmao-btn { height: 2.5rem; padding: 0 1.25rem; font-size: 0.8125rem; }
}
@media (max-width: 479px) {
  .am-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .am-scrim { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .am-chip, .am-kpi { transition: none; }
}

/* ---------- Ficha del equipo (modal) ---------- */
.am-quick-actions { display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.am-quick-actions .gmao-btn { justify-content: center; min-height: 2.5rem; padding: 0.5rem; font-size: 0.75rem; }
@media (max-width: 767px) {
  .am-quick-actions:not([hidden]) { display: grid; }
}
#machine-form-modal [hidden] { display: none !important; }
#machine-completeness-badge { font-variant-numeric: tabular-nums; }

/* Ficha técnica: tarjetas con filas etiqueta | valor; lo que falta se ve en ámbar como «Sin informar». */
.am-meta-count { color: #64748b; font-size: 0.75rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.am-meta-card { display: flex; flex: 0 0 18.5rem; flex-direction: column; scroll-snap-align: start; padding: 1rem; border: 1px solid #e2e8f0; border-radius: 0.75rem; background: #fff; transition: border-color 150ms ease; }
.am-meta-card:hover, .am-meta-card:focus-within { border-color: #93c5fd; }
.am-meta-title { margin: 0 0 0.375rem; color: #1e293b; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.04em; line-height: 1.3; text-transform: uppercase; }
.am-prop { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-top: 1px solid #f1f5f9; }
.am-prop:first-child { border-top: 0; }
.am-prop-label { color: #64748b; font-size: 0.75rem; font-weight: 500; line-height: 1.25; }
.metadata-required::after { content: " *"; color: #f43f5e; }
input.am-prop-input, select.am-prop-input { box-sizing: border-box; width: 100%; min-width: 0; height: 1.75rem; margin: 0; padding: 0 0.375rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; color: #0f172a; font-size: 0.8125rem; font-weight: 700; line-height: 1.25rem; box-shadow: none; }
.am-prop-input:hover:not(:disabled) { border-color: #e2e8f0; }
.am-prop-input:focus { border-color: #93c5fd; background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }
.am-prop-input::placeholder { color: #b45309; font-style: normal; font-weight: 600; opacity: 1; }
.am-prop-input.metadata-field-pending { border: 1px solid transparent !important; background: transparent !important; min-height: 0; padding: 0 0.375rem !important; color: #b45309; font-weight: 600; }
.am-prop-input.metadata-field-pending:hover:not(:disabled) { border-color: #e2e8f0 !important; }
.am-prop-input.metadata-field-pending:focus { border-color: #93c5fd !important; background: #fff !important; }
.am-prop-input:disabled { color: #334155; opacity: 1; cursor: default; -webkit-text-fill-color: currentColor; }
.am-prop-input.metadata-field-pending:disabled { color: #b45309; -webkit-text-fill-color: currentColor; }
select.am-prop-input { appearance: auto; cursor: pointer; }
select.am-prop-input option { color: #0f172a; font-weight: 500; }
