/* ============ Allegati in cartella 📎: referti, radiografie, PDF e foto ============ */

/* ---------- pannello ---------- */
.att-panel { position: relative; display: flex; flex-direction: column; gap: 14px; }
.att-drop {
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: var(--radius); border: 2.5px dashed var(--line-2);
  background: var(--card-2); transition: border-color .15s, background .15s;
}
.att-drop:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line-2)); }
.att-drop-art {
  font-size: 32px; width: 56px; height: 56px; min-width: 56px; border-radius: 18px; display: grid; place-items: center;
  background: var(--sun-soft); animation: float 4s ease-in-out infinite; --r: -5deg;
}
.att-drop-txt { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.att-drop-txt b { font: 600 16px/1.25 var(--font-display); color: var(--ink); }
.att-drop-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.att-sw { color: var(--ink-2); }
.att-sw .small { font-weight: 700; }
.att-cam { display: none !important; }
@media (pointer: coarse) { .att-cam { display: inline-flex !important; } }
.att-scoped .att-drop { padding: 12px 14px; }
.att-scoped .att-drop-art { width: 44px; height: 44px; min-width: 44px; font-size: 24px; border-radius: 14px; }

/* file trascinati sopra il pannello */
.att-dragover {
  display: none; position: absolute; inset: -6px; z-index: 5; place-items: center; pointer-events: none;
  border-radius: calc(var(--radius) + 6px); border: 3px dashed var(--brand);
  background: color-mix(in srgb, var(--brand-soft) 90%, transparent); backdrop-filter: blur(2px);
  font: 600 20px var(--font-display); color: var(--brand-dark); text-align: center; padding: 20px;
}
.att-panel.drag .att-dragover { display: grid; animation: fadein .15s ease both; }
.att-dragover .emoji { display: inline-block; animation: wiggle .7s ease infinite; }
[data-theme="dark"] .att-dragover { color: var(--brand); }

/* ---------- avanzamento dei caricamenti ---------- */
.att-queue { display: flex; flex-direction: column; gap: 8px; }
.att-queue:empty { display: none; }
.att-up {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: var(--card); border: 2px solid var(--line); animation: rise .3s ease both; transition: opacity .3s, transform .3s;
}
.att-up-ic { font-size: 22px; }
.att-up-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.att-up-top b { font-size: 14px; min-width: 0; }
.att-up-top small { flex: none; }
.att-up .progress { height: 8px; margin: 6px 0 4px; }
.att-up-msg { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.att-up.ok { border-color: var(--mint); background: var(--mint-soft); }
.att-up.ok .progress > span { background: var(--mint); }
.att-up.err { border-color: var(--red); background: var(--red-soft); }
.att-up.err .progress { display: none; }
.att-up.err .att-up-msg { color: var(--red-dark); }
[data-theme="dark"] .att-up.err .att-up-msg { color: var(--red); }
.att-up.out { opacity: 0; transform: translateY(-6px); }
.att-up-x {
  border: 0; width: 30px; height: 30px; min-width: 30px; border-radius: 10px; padding: 0;
  display: grid; place-items: center; background: var(--bg-2); color: var(--ink-2); font-size: 18px; line-height: 1;
}
.att-up-x:hover { background: var(--line); }

/* ---------- barra e griglia ---------- */
.att-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.att-filter button { display: inline-flex; align-items: center; gap: 6px; }
.att-n { font: 800 11px/1.5 var(--font); background: var(--line); color: var(--ink-2); border-radius: 99px; padding: 0 7px; }
.att-filter button.on .att-n { background: var(--brand-soft); color: var(--brand-dark); }
[data-theme="dark"] .att-filter button.on .att-n { color: var(--brand); }
.att-usage { white-space: nowrap; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

.att-tile {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--card); border-radius: 20px; border: 2px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s; animation: rise .35s ease both;
}
.att-ghost { height: 250px; border: 0; box-shadow: none; }
.att-thumb {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--bg-2); color: inherit; text-decoration: none !important;
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.att-thumb.broken img { display: none; }
.att-thumb.broken::before { content: '🖼️'; font-size: 40px; opacity: .5; }
.att-tile.pdf .att-thumb { background: linear-gradient(160deg, color-mix(in srgb, var(--red-soft) 75%, var(--card)), var(--bg-2)); }
.att-doc { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.att-doc .emoji { font-size: 48px; filter: drop-shadow(0 6px 8px color-mix(in srgb, var(--red) 25%, transparent)); }
.att-doc b { font: 800 11px var(--font); letter-spacing: .14em; padding: 3px 10px; border-radius: 99px; background: var(--red-soft); color: var(--red-dark); }
[data-theme="dark"] .att-doc b { color: var(--red); }
.att-badge {
  position: absolute; top: 8px; left: 8px; font-size: 13px; line-height: 1; padding: 5px 7px;
  border-radius: 99px; background: var(--card); box-shadow: var(--shadow-sm);
}
.att-badge.off, .att-badge.warn { background: var(--sun-soft); }
.att-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 10px 12px 2px; }
.att-name {
  font: 800 14px/1.3 var(--font); color: var(--ink); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.att-rec {
  display: flex; align-items: center; gap: 5px; align-self: flex-start; max-width: 100%; min-width: 0; margin-top: 3px;
  padding: 3px 8px; border-radius: 10px; background: var(--sky-soft); color: var(--sky-dark); font-weight: 700;
}
[data-theme="dark"] .att-rec { color: var(--sky); }
.att-acts { display: flex; gap: 6px; margin-top: auto; padding: 8px 10px 10px; }
.att-act {
  width: 34px; height: 34px; min-width: 34px; border: 0; border-radius: 11px; padding: 0;
  display: inline-grid; place-items: center; background: var(--bg-2); color: var(--ink-2); font-size: 15px;
  text-decoration: none !important; transition: background .15s, transform .15s, color .15s;
}
.att-act svg { width: 17px; height: 17px; }
.att-act:disabled { opacity: .55; cursor: not-allowed; }
.att-act.vis.on { background: var(--mint-soft); }
.att-act.vis.off, .att-act.vis.warn { background: var(--sun-soft); }
.att-act.danger { margin-left: auto; }
@media (hover: hover) {
  .att-drop:hover .att-drop-art { animation-duration: 1.6s; }
  .att-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
  .att-tile:hover .att-thumb img { transform: scale(1.04); }
  .att-tile:hover .att-doc .emoji { animation: wiggle .5s ease; }
  .att-act:not(:disabled):hover { background: var(--line); transform: translateY(-1px); }
  .att-act.danger:hover { background: var(--red-soft); color: var(--red-dark); }
}

/* stato vuoto */
.att-empty { text-align: center; padding: 24px 16px 10px; color: var(--muted); }
.att-empty h3 { color: var(--ink); margin-bottom: 6px; }
.att-empty p { max-width: 520px; margin: 0 auto; }
.att-empty .big-emoji { font-size: 46px; display: block; margin-bottom: 6px; animation: float 3s ease-in-out infinite; }
.att-empty-art { position: relative; width: 120px; height: 96px; margin: 0 auto 8px; }
.att-empty-art .emoji { position: absolute; left: 8px; top: 6px; font-size: 64px; animation: float 3.4s ease-in-out infinite; }
.att-empty-art .att-empty-pet { left: 66px; top: 40px; font-size: 40px; animation: wag 1.8s ease-in-out infinite; transform-origin: 50% 90%; }

/* ---------- cronologia della cartella: "📎 N" sulle voci ---------- */
.att-rec-chip { border: 0; cursor: pointer; transition: transform .15s, filter .15s; }
.att-rec-chip:hover { transform: translateY(-1px); filter: saturate(1.25); }

/* ---------- finestra della voce di cartella: "Allega file" ---------- */
.att-field { display: flex; flex-direction: column; gap: 8px; }
.att-field-drop {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; cursor: pointer;
  border: 2px dashed var(--line-2); background: var(--card-2); font-weight: 700; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.att-field-drop:hover, .att-field-drop.drag { border-color: var(--brand); background: color-mix(in srgb, var(--brand-soft) 60%, var(--card)); }
.att-field-drop:focus-within { box-shadow: var(--ring); }
.att-field-drop > .emoji { font-size: 22px; }
.att-minis { display: flex; flex-wrap: wrap; gap: 6px; }
.att-mini {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 10px; border-radius: 99px;
  background: var(--sky-soft); color: var(--ink); font: 700 12.5px var(--font); text-decoration: none !important;
}
.att-mini .ellipsis { max-width: 210px; }
.att-mini.pending { background: var(--card); box-shadow: inset 0 0 0 2px var(--line-2); }
.att-mini-x {
  border: 0; width: 20px; height: 20px; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: var(--bg-2); color: var(--ink-2); font-size: 14px; line-height: 1;
}
.att-mini-x:hover { background: var(--red-soft); color: var(--red-dark); }

/* rinomina */
.att-ren-row { display: flex; align-items: center; gap: 8px; }
.att-ext { flex: none; font: 800 13px var(--font); color: var(--muted); padding: 11px 12px; border-radius: 12px; background: var(--bg-2); }

/* ---------- visore delle immagini ---------- */
.att-lb-modal { --lb-stage: var(--ink); --lb-ink: var(--card); }
[data-theme="dark"] .att-lb-modal { --lb-stage: var(--bg); --lb-ink: var(--ink); }
.att-lb { position: relative; }
.att-lb-stage {
  position: relative; display: grid; place-items: center; min-height: min(56vh, 520px); max-height: 70vh;
  border-radius: 20px; background: var(--lb-stage); overflow: hidden; touch-action: pan-y pinch-zoom;
}
.att-lb-stage img { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; cursor: zoom-in; user-select: none; transition: opacity .2s; }
.att-lb-stage.zoomed { overflow: auto; place-items: start; }
.att-lb-stage.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.att-lb-stage.loading img { opacity: .25; }
.att-lb-wait, .att-lb-broken { position: absolute; inset: 0; display: none; color: var(--lb-ink); }
.att-lb-stage.loading .att-lb-wait { display: grid; place-items: center; }
.att-lb-stage.broken img { display: none; }
.att-lb-stage.broken .att-lb-broken { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-weight: 700; padding: 20px; text-align: center; }
.att-lb-broken .emoji { font-size: 44px; }
.att-lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: color-mix(in srgb, var(--card) 90%, transparent); color: var(--ink);
  box-shadow: var(--shadow); transition: transform .15s;
}
.att-lb-nav:hover { transform: translateY(-50%) scale(1.08); }
.att-lb-nav svg { width: 22px; height: 22px; }
.att-lb-nav.prev { left: 10px; }
.att-lb-nav.next { right: 10px; }
.att-lb-cap { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- documenti visti dal proprietario (profilo e Petxy Share) ---------- */
.att-olist { display: flex; flex-direction: column; }
.att-orow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 2px dashed var(--line); }
.att-orow:first-child { border-top: 0; }
.att-othumb {
  width: 56px; height: 56px; min-width: 56px; border-radius: 16px; overflow: hidden; display: grid; place-items: center;
  background: var(--bg-2); text-decoration: none !important; transition: transform .15s;
}
.att-othumb:hover { transform: scale(1.05) rotate(-2deg); }
.att-othumb img { width: 100%; height: 100%; object-fit: cover; }
.att-othumb.pdf { background: var(--red-soft); }
.att-othumb .emoji { font-size: 28px; }
.att-oname { font-weight: 800; color: var(--ink); overflow-wrap: anywhere; }
.att-orec { display: flex; align-items: center; gap: 5px; min-width: 0; }
.att-odl { flex: none; }

/* ---------- telefono ---------- */
@media (max-width: 620px) {
  .att-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
  .att-drop { padding: 14px; }
  .att-drop-art { display: none; }
  .att-drop-btns { width: 100%; }
  .att-drop-btns .btn { flex: 1; }
  .att-meta { padding: 8px 10px 2px; }
  .att-acts { gap: 4px; padding: 6px 8px 8px; }
  .att-act { width: 32px; height: 32px; min-width: 32px; }
  .att-lb-stage { min-height: 40vh; max-height: 62vh; }
  .att-lb-stage img { max-height: 62vh; }
  .att-lb-nav { width: 40px; height: 40px; }
}
