/* Trascriviamo – Messaggi & file (area riservata e pagina ordine in amministrazione) */
.tr-msg { --tr-msg-blue: #1d5fa8; --tr-msg-ink: #1b2430; --tr-msg-muted: #6b7280; --tr-msg-line: #e5e7eb; --tr-msg-cta: #c4621a; }
.tr-msg-section { margin: 32px 0 0; }
.tr-msg-section > h2 { margin-bottom: 8px; }
.tr-msg__intro { margin: 0 0 14px; color: var(--tr-msg-muted); font-size: .95rem; line-height: 1.5; }
.tr-msg--admin .tr-msg__intro { font-size: 12px; margin: 4px 0 10px; }

/* thread */
.tr-msg__thread { max-height: 520px; overflow: auto; padding: 4px 2px; border: 1px solid var(--tr-msg-line); border-radius: 12px; background: #fafafa; }
.tr-msg__empty { margin: 0; padding: 22px 18px; color: var(--tr-msg-muted); font-size: .95rem; text-align: center; }
.tr-msg__list { list-style: none; margin: 0; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 12px; }
.tr-msg__item { width: 86%; max-width: 640px; box-sizing: border-box; padding: 12px 14px; border-radius: 14px; background: #fff; border: 1px solid var(--tr-msg-line); align-self: flex-start; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.tr-msg__item--staff { background: #eef3fa; border-color: #d6e2f3; }
.tr-msg__item.is-mine { align-self: flex-end; }
.tr-msg__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; font-size: .8rem; color: var(--tr-msg-muted); }
.tr-msg__who { font-weight: 600; color: var(--tr-msg-ink); }
.tr-msg__tag { padding: 1px 8px; border-radius: 999px; background: #e5e7eb; color: #374151; font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.tr-msg__item--staff .tr-msg__tag { background: var(--tr-msg-blue); color: #fff; }
.tr-msg__tag--legacy { background: #f3f4f6 !important; color: #6b7280 !important; }
.tr-msg__date { margin-left: auto; white-space: nowrap; }
.tr-msg__del { all: unset; cursor: pointer; font-size: .74rem; color: #9ca3af; text-decoration: underline; }
.tr-msg__del:hover { color: #b91c1c; }
.tr-msg__text { font-size: .95rem; line-height: 1.55; color: var(--tr-msg-ink); overflow-wrap: anywhere; }
.tr-msg__text a { color: var(--tr-msg-blue); }
.tr-msg__atts { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tr-msg__att { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 8px; background: #fff; border: 1px solid var(--tr-msg-line); color: var(--tr-msg-ink) !important; text-decoration: none !important; font-size: .85rem; max-width: 100%; }
.tr-msg__att:hover { border-color: var(--tr-msg-blue); }
.tr-msg__att-icon { flex: 0 0 auto; padding: 3px 5px; border-radius: 5px; background: #fee2e2; color: #b91c1c; font-size: .66rem; font-weight: 700; letter-spacing: .04em; }
.tr-msg__att-icon--img { background: #e0f2fe; color: #075985; }
.tr-msg__att-icon--file { background: #ede9fe; color: #4c1d95; }
.tr-msg__att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-msg__att-size { color: var(--tr-msg-muted); font-size: .78rem; }
.tr-msg__status { margin-top: 6px; font-size: .74rem; color: var(--tr-msg-muted); text-align: right; }

/* modulo di invio */
.tr-msg__form { margin-top: 12px; }
.tr-msg__body { width: 100%; box-sizing: border-box; min-height: 96px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; font: inherit; font-size: .95rem; line-height: 1.5; resize: vertical; }
.tr-msg__body:focus { outline: none; border-color: var(--tr-msg-blue); box-shadow: 0 0 0 3px rgba(29,95,168,.15); }
.tr-msg__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.tr-msg__attach { position: relative; display: inline-block; cursor: pointer; }
.tr-msg__attach input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.tr-msg__attach-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; color: var(--tr-msg-ink); font-size: .88rem; font-weight: 600; line-height: 1.2; }
.tr-msg__attach:hover .tr-msg__attach-btn, .tr-msg__attach input:focus-visible + .tr-msg__attach-btn { border-color: var(--tr-msg-blue); color: var(--tr-msg-blue); }
.tr-msg__filelist { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 200px; min-width: 0; }
.tr-msg__chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 999px; background: #eef3fa; color: var(--tr-msg-ink); font-size: .8rem; max-width: 100%; }
.tr-msg__chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.tr-msg__chip button { all: unset; cursor: pointer; width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 50%; color: #6b7280; font-size: 14px; }
.tr-msg__chip button:hover { background: #fff; color: #b91c1c; }
.tr-msg .tr-msg__send { margin-left: auto; }
.tr-msg--front .tr-msg__send { min-height: 43px; padding: 0 28px; }
.tr-msg__hint { margin: 6px 0 0; font-size: .78rem; color: var(--tr-msg-muted); }
.tr-msg__notice { display: none; margin-top: 8px; padding: 8px 12px; border-radius: 8px; font-size: .88rem; }
.tr-msg__notice.is-ok { display: block; background: #ecfdf5; color: #065f46; }
.tr-msg__notice.is-error { display: block; background: #fef2f2; color: #991b1b; }
.tr-msg.is-sending { opacity: .7; pointer-events: none; }

/* badge nelle tabelle ordini */
.tr-msg-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #eef3fa; color: #1d5fa8 !important; font-size: .82rem; font-weight: 600; text-decoration: none !important; }
.tr-msg-badge--new { background: #c4621a; color: #fff !important; }
.tr-msg-badge--none { background: transparent; color: #9ca3af !important; font-weight: 400; }
.column-tr_messages { width: 90px; }

/* amministrazione: dimensioni compatte */
.tr-msg--admin .tr-msg__thread { max-height: 460px; background: #fff; }
.tr-msg--admin .tr-msg__list { padding: 10px 10px 4px; }
.tr-msg--admin .tr-msg__item { width: 88%; max-width: none; }
.tr-msg--admin .tr-msg__body { min-height: 80px; font-size: 13px; }

@media (max-width: 600px) {
	.tr-msg__item { width: 100%; max-width: none; }
	.tr-msg .tr-msg__send { margin-left: 0; width: 100%; }
	.tr-msg__date { margin-left: 0; }
}

/* ---------- Elenco file dell'ordine ---------- */
.tr-files__intro { margin: 0 0 14px; color: #4a5561; }
.tr-files__empty { color: #6b7682; font-style: italic; }
.tr-files__wrap { overflow-x: auto; }
.tr-files__table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tr-files__table th { text-align: left; font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: #4a5561; padding: 8px 6px; border-bottom: 2px solid #dfe5ea; white-space: nowrap; }
.tr-files__table td { padding: 10px 6px; border-bottom: 1px solid #e8edf1; vertical-align: middle; }
.tr-files__num { text-align: right; white-space: nowrap; }
.tr-files__name a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; word-break: break-word; }
.tr-files__name a:hover span:last-child { text-decoration: underline; }
.tr-files__who { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.tr-files__who--customer { background: #eef3f8; color: #1d5fa8; }
.tr-files__who--staff { background: #e3f3f4; color: #0d7d88; }
.tr-files--admin .tr-files__table th, .tr-files--admin .tr-files__table td { padding: 8px 10px; }
@media (max-width: 640px) {
	.tr-files__table thead { display: none; }
	.tr-files__table, .tr-files__table tbody, .tr-files__table tr, .tr-files__table td { display: block; width: 100%; }
	.tr-files__table tr { border-bottom: 1px solid #dfe5ea; padding: 8px 0; }
	.tr-files__table td { border: 0; padding: 3px 0; text-align: left; }
	.tr-files__table td[data-label]:not(.tr-files__name)::before { content: attr(data-label) ": "; font-weight: 700; color: #4a5561; font-size: .82rem; }
}
.tr-files__table td.tr-files__name { min-width: 170px; }
.tr-files__name a span:last-child { overflow-wrap: anywhere; }
.tr-files__table td:nth-child(4) { white-space: nowrap; }
.tr-files__table td.tr-files__where { min-width: 140px; }
.tr-files__detail { display: block; font-size: .8rem; color: #6b7682; line-height: 1.35; margin-top: 2px; }
.tr-msg__item.is-internal { border-style: dashed !important; background: #fffbea !important; }
.tr-msg__tag--internal { background: #fef3c7 !important; color: #92400e !important; }
.tr-files__row.is-internal td { background: #fffbea; }
.tr-files__internal { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: .72rem; font-weight: 700; }
.tr-files__pending { color: #6b7682; font-size: .8rem; font-style: italic; }
.tr-files__who--archive { background: #f3f4f6; color: #4b5563; }
.tr-msg__thread:empty { display: none; }

/* arrivo da e-mail: solo l'ultimo messaggio + link "Mostra messaggi precedenti" */
.tr-msg__more { display: block; margin: 12px auto 0; padding: 4px 10px; background: none; border: 0; color: #1d5fa8; font-weight: 600; text-decoration: underline; cursor: pointer; font-size: 14px; }
.tr-msg__more:hover { color: #c4621a; }
.tr-msg__item.is-latest { box-shadow: 0 0 0 2px rgba(196, 98, 26, .35); }
.tr-msg__item[hidden] { display: none !important; }

/* messaggi predefiniti (amministrazione) */
.tr-msg__tpl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 8px; }
.tr-msg__tpl label { font-weight: 600; }
.tr-msg__tpl-select { min-width: 280px; max-width: 100%; }
.tr-msg__tpl-empty { margin: 0 0 8px; color: #646970; }
