/* TraceabilityRegistry — stili condivisi della galleria (card + filtri).
   Prefisso "te-" per non entrare in conflitto con lo stile della pagina
   che lo include (user.html ha già le sue classi .card/.row/ecc.). */

.te-collection-header { position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 20px; background: #eee; display: none; }
.te-banner { width: 100%; max-height: 220px; object-fit: cover; display: block; }
.te-collection-body { padding: 16px 20px; background: #fff; display: flex; gap: 14px; align-items: center; }
.te-collection-icon { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: #eee; }
.te-collection-header h2 { margin: 0 0 4px; }
.te-collection-header p { margin: 0; color: #555; font-size: 0.9rem; }

.te-filters { margin-bottom: 16px; display: none; }
.te-lot-search { margin-bottom: 10px; }
.te-lot-search-input { width: 100%; max-width: 320px; padding: 7px 12px; border: 1px solid #ccc; border-radius: 999px; font-size: 0.85rem; box-sizing: border-box; }
.te-filters-row { display: flex; flex-wrap: wrap; gap: 8px; }
.te-filter-chip { position: relative; display: inline-block; }
.te-chip-toggle { padding: 6px 14px; border: 1px solid #ccc; border-radius: 999px; background: #fff; font-size: 0.82rem; cursor: pointer; white-space: nowrap; color: #333; }
.te-filter-chip.has-active .te-chip-toggle { background: #222; color: #fff; border-color: #222; }
.te-filter-chip.open .te-chip-toggle { border-color: #5b3fd6; }
.te-filter-dropdown { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: #fff; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,0.14); padding: 10px; z-index: 30; min-width: 200px; max-height: 260px; overflow-y: auto; }
.te-filter-chip.open .te-filter-dropdown { display: block; }
.te-filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.te-pill { padding: 4px 12px; border: 1px solid #ccc; border-radius: 999px; font-size: 0.8rem; background: #f5f5f5; cursor: pointer; white-space: nowrap; }
.te-pill.active { background: #222; color: #fff; border-color: #222; }
.te-filters-clear { font-size: 0.78rem; color: #5b3fd6; cursor: pointer; text-decoration: underline; margin-top: 8px; display: inline-block; }

.te-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.te-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); cursor: pointer; transition: box-shadow 0.15s; }
.te-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.12); }
.te-card.te-invalidated { opacity: 0.55; }
.te-card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: #eee; display: block; }
.te-noimage { aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; color: #bbb; background: #f0f0f0; }
.te-card-body { padding: 12px; }
.te-badge { display: inline-block; font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; margin-bottom: 6px; }
.te-badge-lot { background: #e0f2e9; color: #0a6; }
.te-badge-batch { background: #e8e6fb; color: #5b3fd6; }
.te-badge-invalid { background: #fde0e0; color: #c33; margin-left: 6px; }
.te-card h3 { margin: 4px 0 6px; font-size: 1rem; }
.te-desc { font-size: 0.85rem; color: #555; margin: 0 0 8px; }
.te-invalid-reason { font-size: 0.8rem; color: #c33; background: #fde0e0; border-radius: 6px; padding: 6px 8px; margin: 0 0 8px; }
.te-attrs { display: none; margin-top: 8px; border-top: 1px solid #eee; padding-top: 8px; }
.te-card.te-expanded .te-attrs { display: block; }
.te-attr-row { display: flex; justify-content: space-between; font-size: 0.8rem; padding: 3px 0; border-bottom: 1px dashed #eee; }
.te-attr-row span:first-child { color: #888; }
.te-used-lots { margin-top: 8px; }
.te-used-lots a { font-size: 0.78rem; color: #5b3fd6; text-decoration: none; display: block; margin-bottom: 3px; }
.te-used-lots a:hover { text-decoration: underline; }
.te-invalidate-btn { margin-top: 10px; background: #fff; color: #c33; border: 1px solid #c33; padding: 5px 12px; border-radius: 6px; font-size: 0.78rem; cursor: pointer; }
.te-invalidate-btn:hover { background: #fde0e0; }
.te-invalidate-btn:disabled { opacity: 0.6; cursor: default; }
.te-dochash-row { margin-top: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.te-dochash-select { font-size: 0.72rem; max-width: 160px; }
.te-dochash-btn { background: #fff; color: #3454d1; border: 1px solid #3454d1; padding: 5px 12px; border-radius: 6px; font-size: 0.78rem; cursor: pointer; }
.te-dochash-btn:hover { background: #e8ecfc; }
.te-dochash-btn:disabled { opacity: 0.6; cursor: default; }
.te-dochash-gate { font-size: 0.72rem; color: #a67c00; }
.te-err { color: #c33; }
.te-empty { text-align: center; padding: 40px; color: #999; }

.te-dochash-info { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #eee; }
.te-dochash-badge { display: inline-block; font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; background: #fff4d6; color: #a67c00; }
.te-dochash-value { font-size: 0.72rem; color: #777; }
.te-verify-row { margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.te-verify-input { font-size: 0.72rem; max-width: 140px; }
.te-verify-btn { background: #fff; color: #0a6; border: 1px solid #0a6; padding: 5px 12px; border-radius: 6px; font-size: 0.78rem; cursor: pointer; }
.te-verify-btn:hover { background: #e0f2e9; }
.te-verify-result { font-size: 0.78rem; font-weight: 600; }
.te-verify-result.te-verify-ok { color: #0a6; }
.te-verify-result.te-verify-fail { color: #c33; }
.te-verify-result.te-verify-warn { color: #a66a1e; }
.te-dochash-history { margin-top: 6px; font-size: 0.72rem; color: #7a4a17; }
.te-dochash-correction { margin-top: 2px; }
.te-dochash-correct-row { border-top: 1px dashed #eee; padding-top: 8px; }
.te-dochash-reason { font-size: 0.72rem; flex: 1 1 160px; min-width: 0; padding: 4px 6px; }
.te-lot-after { font-size: 0.72rem; color: #8a5a00; background: #fff3d9; border-radius: 6px; padding: 2px 7px; margin: -1px 0 5px 12px; display: inline-block; }

/* Filtro per tipo (Tutti / Materie prime / Batch) */
.te-type-filter { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #eef3fc; border-radius: 999px; padding: 4px; margin-bottom: 10px; }
.te-type-pill { border: none; background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 0.82rem; font-weight: 600; color: #5d6b82; cursor: pointer; }
.te-type-pill.active { background: #fff; color: #1e6bff; box-shadow: 0 1px 4px rgba(16, 32, 64, 0.12); }
.te-type-count { font-weight: 500; opacity: 0.75; }
.te-used-in { margin-top: 10px; }

/* Scheda rapida */
.te-quick-back { position: fixed; inset: 0; background: rgba(11, 29, 58, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 900; }
.te-quick { position: relative; background: #fff; border-radius: 18px; max-width: 420px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 18px 50px rgba(11, 29, 58, 0.35); }
.te-quick img { width: 100%; max-height: 240px; object-fit: cover; display: block; }
.te-quick .te-attr-row { display: flex; }
.te-quick-close { position: absolute; top: 8px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.9); font-size: 1.3rem; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.te-quick-show { margin-top: 12px; background: #fff; color: #1e6bff; border: 1px solid #1e6bff; border-radius: 9px; padding: 7px 14px; font-weight: 600; cursor: pointer; }
