/* Inventio Hub UI custom - animazioni, scrollbar, componenti riusabili.
 * Riferimento mockup: AutomationLanding/Assets/Codice/estrazione.html
 */

/* ─── Scrollbar ─── */
* { scrollbar-width: thin; scrollbar-color: #d4d4d8 transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }
*::-webkit-scrollbar-corner { background: transparent; }
*:hover::-webkit-scrollbar { width: 8px; }
*:hover::-webkit-scrollbar-thumb { background: #a1a1aa; }

/* ─── Animations ─── */
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 8px rgba(4, 148, 245, 0.15); }
  50%      { box-shadow: 0 0 24px rgba(4, 148, 245, 0.3); }
}
.pulse-glow { animation: pulse-border 1.5s ease-in-out infinite; }

.inventio-logo-dark {
  filter: brightness(0);
}

.status-pill-gray {
  border-color: #e5e7eb;
  background: #f9fafb;
  color: #374151;
}

.status-pill-blue {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.status-pill-cyan {
  border-color: #a5f3fc;
  background: #ecfeff;
  color: #0e7490;
}

.status-pill-indigo {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
}

.status-pill-teal {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: #0f766e;
}

.status-pill-emerald {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.status-pill-violet {
  border-color: #ddd6fe;
  background: #f5f3ff;
  color: #6d28d9;
}

.status-pill-amber {
  border-color: #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.status-pill-yellow {
  border-color: #fef08a;
  background: #fefce8;
  color: #a16207;
}

.status-pill-orange {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.status-pill-red {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-row { animation: fade-in 0.3s ease-out forwards; opacity: 0; }

/* ─── Components ─── */
.source-card { transition: all 0.2s ease; }
.source-card:hover {
  border-color: #0494f5;
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(4, 148, 245, 0.08);
}

.drop-zone { transition: all 0.2s ease; }
.drop-zone.is-dragover {
  border-color: #0494f5 !important;
  background: #f4f4f5;
}

.connector-row { transition: background 0.15s ease; }
.connector-row:hover { background: #f4f4f5; }

.edit-input { transition: border-color 0.2s ease; }
.edit-input:focus {
  border-color: #0494f5 !important;
  box-shadow: 0 0 0 1px rgba(4, 148, 245, 0.15);
}

/* Batch list filters */
.batch-filter {
  padding: 1rem;
}

.batch-filter-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.batch-filter-search {
  align-items: center;
  background: #f4f4f5;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  display: flex;
  flex: 1 1 auto;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.5rem 0.75rem;
}

.batch-filter-search-input {
  background: transparent;
  border: 0;
  color: #0a0a0a;
  flex: 1 1 auto;
  font-size: 0.875rem;
  line-height: 1.25rem;
  min-width: 0;
  outline: none;
}

.batch-filter-search-input::placeholder {
  color: #8f8f8f;
}

.batch-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.batch-filter-toggle,
.batch-filter-reset {
  align-items: center;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  color: #525252;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 500;
  gap: 0.375rem;
  justify-content: center;
  line-height: 1rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.batch-filter-toggle {
  background: #ffffff;
}

.batch-filter-toggle-icon {
  transition: transform 0.15s ease;
}

.batch-filter-toggle[aria-expanded="true"] {
  border-color: #0494f5;
  color: #0494f5;
}

.batch-filter-toggle[aria-expanded="true"] .batch-filter-toggle-icon {
  transform: rotate(180deg);
}

.batch-filter-reset:hover {
  border-color: #0494f5;
  color: #0494f5;
}

.batch-filter-summary {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
}

.batch-filter-panel {
  border-top: 1px solid #e5e7eb;
  margin-top: 1rem;
  padding-top: 1rem;
}

.batch-filter-period-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.batch-filter-group {
  margin-top: 1rem;
}

.batch-filter-legend {
  color: #8f8f8f;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  line-height: 1rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.filter-chip-input {
  height: 1px;
  margin: -1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.status-filter-tag {
  cursor: pointer;
  opacity: 0.56;
  transition: box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.status-filter-tag:hover {
  opacity: 0.85;
}

.filter-chip-input:checked + .status-filter-tag {
  box-shadow: 0 0 0 2px rgba(4, 148, 245, 0.16);
  opacity: 1;
}

.filter-chip-input:focus + .status-filter-tag,
.filter-chip-input:focus + .filter-date-tag {
  box-shadow: 0 0 0 2px rgba(4, 148, 245, 0.2);
}

.filter-date-tag {
  align-items: center;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  color: #374151;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
  padding: 0.125rem 0.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.filter-date-tag:hover {
  border-color: #0494f5;
}

.filter-chip-input:checked + .filter-date-tag {
  border-color: #0494f5;
  box-shadow: 0 0 0 2px rgba(4, 148, 245, 0.16);
  color: #0a0a0a;
}

.batch-filter-dates {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.batch-filter-panel-actions {
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
}

@media (min-width: 1024px) {
  .batch-filter-toolbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .batch-filter-actions {
    flex: none;
  }

  .batch-filter-period-row {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }
}

/* ─── Sparkline tooltip ─── */
.chart-bar-group { position: relative; }
.chart-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  z-index: 20;
  white-space: nowrap;
  pointer-events: none;
}
.chart-bar-group:hover .chart-tooltip { display: block; }

/* Hide elements until Alpine processes them (avoid flash). */
[x-cloak] { display: none !important; }

/* Responsive data tables.
 * Desktop keeps the standard table layout. On narrow screens each row
 * becomes a compact record card with labels from td[data-label].
 */
.responsive-table td,
.responsive-table th {
  vertical-align: middle;
}

.responsive-table td:first-child {
  min-width: 12rem;
}

.responsive-table td,
.responsive-table th {
  overflow-wrap: anywhere;
}

@media (max-width: 639px) {
  .responsive-table {
    display: block;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: block;
    padding: 0.5rem;
  }

  .responsive-table tbody tr {
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #ffffff;
    overflow: hidden;
  }

  .responsive-table tbody tr + tr {
    margin-top: 0.5rem;
  }

  .responsive-table tbody td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.625rem 0.75rem !important;
    border: 0;
    text-align: left !important;
  }

  .responsive-table tbody td + td {
    border-top: 1px solid #e5e7eb;
  }

  .responsive-table tbody td::before {
    content: attr(data-label);
    color: #8f8f8f;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-transform: uppercase;
  }

  .responsive-table tbody td[data-label=""] {
    align-items: center;
    display: flex;
    justify-content: flex-end;
  }

  .responsive-table tbody td[data-label=""]::before {
    display: none;
  }

  .responsive-table .responsive-table-empty {
    display: block;
    text-align: center !important;
  }

  .responsive-table .responsive-table-empty::before {
    display: none;
  }
}

/* HTMX request-in-flight visual feedback for the batch list table */
#batch-list-table.htmx-request {
  opacity: 0.6;
  transition: opacity 150ms ease-out;
}
