/* Messagerie : « Mes messages » et boîte de réception de l'équipe. Aplats, filets de 1 px, aucun dégradé. */

.tk, .ad { --c-attente: var(--warn); --c-repondu: var(--ok); --c-ferme: var(--text-2); }
.tk { padding-block: var(--s-6) var(--s-9); }
.tk *, .ad .tk-app * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.tk-eyebrow { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--accent); }
.tk h1 { font-size: 1.5rem; letter-spacing: -0.01em; white-space: nowrap; }
.tk-gate h1 { white-space: normal; }

/* --- Écran de connexion ------------------------------------------------------------------ */
.tk-gate { max-width: 640px; padding-block: var(--s-6); }
.tk-gate h1 { margin-top: var(--s-3); font-size: clamp(2rem, 4.5vw, 3rem); letter-spacing: -0.02em; }
.tk-lead { margin-top: var(--s-4); font-size: 1.0625rem; line-height: 1.7; }
.tk-gate .btn { margin-top: var(--s-6); }
.tk-points { list-style: none; margin: var(--s-7) 0 0; padding: 0; border: 1px solid var(--border); }
.tk-points li { padding: var(--s-4) var(--s-5); }
.tk-points li + li { border-top: 1px solid var(--border); }
.tk-points b { display: block; color: var(--text); }
.tk-points span { display: block; margin-top: 2px; font-size: 0.9375rem; color: var(--text-2); }
.tk-points a, .tk-alt a, .tk-closed a { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
.tk-alt { margin-top: var(--s-5); font-size: 0.9375rem; }

/* --- Cadre : liste à gauche, conversation à droite ------------------------------------------ */
.tk-app { display: grid; grid-template-columns: 370px minmax(0, 1fr); height: clamp(580px, calc(100vh - 150px), 840px); border: 1px solid var(--border); background: var(--surface); animation: tk-in 0.3s ease both; }
.tk-app[hidden], .tk-gate[hidden], .tk [hidden] { display: none !important; }
@keyframes tk-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes tk-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.tk-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
.tk-side-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3); padding: var(--s-5); border-bottom: 1px solid var(--border); }
.tk-side-head .btn { padding: 9px 16px; font-size: 0.9375rem; white-space: nowrap; }
.tk-search { margin: var(--s-3) var(--s-4); padding: 11px var(--s-3); font: inherit; font-size: 0.9375rem; color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 0; }
.tk-search:focus { outline: none; border-color: var(--accent); }
.tk-search::placeholder { color: var(--text-2); }
.tk-search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.tk-filters { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-4) var(--s-4) 0; }
.tk-chip { display: inline-flex; gap: var(--s-2); align-items: center; padding: 6px 12px; font: inherit; font-size: 0.875rem; color: var(--text-2); background: none; border: 1px solid var(--border-strong); border-radius: 999px !important; cursor: pointer; transition: color 0.15s, background-color 0.15s, border-color 0.15s; }
.tk-chip em { font-style: normal; font-family: var(--font-mono); font-size: 0.75rem; opacity: 0.8; }
.tk-chip:hover { color: var(--text); border-color: var(--text-2); }
.tk-chip.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.tk-chip.att:not(.on) em { color: var(--warn); opacity: 1; font-weight: 600; }

/* Liste */
.tk-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; border-top: 1px solid var(--border); }
.tk-item { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s-3); width: 100%; padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5); font: inherit; text-align: left; color: var(--text-2); background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background-color 0.15s; }
.tk-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); transform: scaleY(0); transition: transform 0.2s; }
.tk-item:hover { background: var(--surface-2); }
.tk-item.on { background: var(--surface-2); }
.tk-item.on::before, .tk-item.unread::before { transform: scaleY(1); }
.tk-item.att:not(.on)::before { background: var(--warn); transform: scaleY(1); }
.tk-item-av { width: 40px; height: 40px; border-radius: 50% !important; background: var(--surface-2); object-fit: cover; }
.tk-item-av.logo { padding: 7px; background: var(--bg); border: 1px solid var(--border); }
.tk-item-body { min-width: 0; }
.tk-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); }
.tk-item-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; font-size: 1rem; }
.tk-item.unread .tk-item-top b { font-weight: 700; }
.tk-item-top time { flex: none; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-2); }
.tk-item-sub { display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9375rem; color: var(--text); }
.tk-item-ex { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; }
.tk-item-meta { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-2); }
.tk-item-meta i { margin-left: auto; font-style: normal; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-2); }
.tk-empty { padding: var(--s-7) var(--s-5); font-size: 0.9375rem; text-align: center; line-height: 1.6; }
.tk-empty .btn { margin-top: var(--s-4); }
.tk-dot { width: 9px; height: 9px; margin-left: auto; border-radius: 50% !important; background: var(--accent); }

.tk-cat, .tk-st, .tk-tag { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 8px; border: 1px solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.tk-st::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: currentColor; border-radius: 50% !important; vertical-align: 1px; }
.tk-st.attente { color: var(--c-attente); border-color: var(--c-attente); }
.tk-st.repondu { color: var(--c-repondu); border-color: var(--c-repondu); }
.tk-st.ferme { color: var(--c-ferme); }
.tk-tag { color: var(--accent-hover); border-color: var(--accent); }

.tk-account { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--text-2); }
.tk-account b { color: var(--text); font-weight: 500; }
.tk-link { padding: 0; font: inherit; color: var(--accent-hover); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.tk-link:hover { color: var(--text); }

/* --- Volet principal --------------------------------------------------------------------------- */
.tk-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.tk-placeholder { margin: auto; padding: var(--s-7); max-width: 420px; text-align: center; animation: tk-rise 0.4s ease both; }
.tk-placeholder b { display: block; color: var(--text); font-size: 1.1875rem; }
.tk-placeholder span { display: block; margin: var(--s-2) 0 var(--s-5); font-size: 0.9375rem; line-height: 1.6; }
.tk-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: tk-in 0.25s ease both; }
#tk-head { flex: none; }
.tk-pane-head { display: flex; align-items: flex-start; gap: var(--s-4); flex-wrap: wrap; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); background: var(--surface); }
.tk-pane-head h2 { font-size: 1.25rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tk-title { flex: 1; min-width: 220px; }
.tk-title p { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-2); }
.tk-hint { font-size: 0.8125rem; color: var(--text-2); }
.tk-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.tk-back { display: none; padding: 0; font: inherit; font-size: 0.9375rem; color: var(--accent-hover); background: none; border: 0; cursor: pointer; }
.tk-btn { padding: 8px 14px; font: inherit; font-size: 0.875rem; color: var(--text-2); background: none; border: 1px solid var(--border-strong); border-radius: 6px !important; cursor: pointer; transition: color 0.15s, border-color 0.15s, background-color 0.15s; }
.tk-btn:hover:not(:disabled) { color: var(--text); border-color: var(--text-2); background: var(--surface-2); }
.tk-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tk-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.tk-btn.ok { color: var(--ok); border-color: var(--ok); }
.tk-btn:focus-visible, .tk-chip:focus-visible, .tk-item:focus-visible, .tk-link:focus-visible, .tk-back:focus-visible, .tk-prev-x:focus-visible, .tk-cat-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tk-who { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); background: var(--bg); }
.tk-who img { border-radius: 50% !important; background: var(--surface-2); }
.tk-who > div { flex: 1; min-width: 0; }
.tk-who b { display: block; color: var(--text); font-size: 1rem; }
.tk-who span { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-2); }

/* --- Fil de discussion ----------------------------------------------------------------------------- */
.tk-msgs { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: var(--s-5); }
.tk-day { align-self: center; margin: var(--s-4) 0 var(--s-3); padding: 3px 12px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px !important; }
.tk-day:first-child { margin-top: 0; }
.tk-msg { display: flex; align-items: flex-end; gap: var(--s-2); max-width: 80%; align-self: flex-start; }
.tk-msg.fresh { animation: tk-rise 0.3s ease both; }
.tk-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.tk-msg.gap { margin-top: var(--s-3); }
.tk-av { flex: none; width: 30px; height: 30px; border-radius: 50% !important; background: var(--surface-2); object-fit: cover; }
.tk-av.logo { padding: 5px; background: var(--surface); border: 1px solid var(--border); }
.tk-msg.cont .tk-av { visibility: hidden; }
.tk-bub { min-width: 0; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); }
.tk-msg.mine .tk-bub { background: var(--accent); border-color: var(--accent); }
.tk-msg header { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s-2); margin-bottom: 4px; }
.tk-msg.cont header { display: none; }
.tk-msg header b { color: var(--text); font-size: 0.875rem; font-weight: 600; }
.tk-msg header .tk-tag { padding: 0 6px; }
.tk-msg.mine header b, .tk-msg.mine p { color: #fff; }
.tk-msg.mine .tk-tag { color: #fff; border-color: rgba(255, 255, 255, 0.6); }
.tk-msg p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.6; color: var(--text); }
.tk-msg time { display: block; margin-top: 4px; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-2); }
.tk-msg.mine time { color: rgba(255, 255, 255, 0.75); text-align: right; }
.tk-imgs { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.tk-img { display: block; border: 1px solid var(--border-strong); background: var(--bg); transition: opacity 0.15s; }
.tk-img:hover { opacity: 0.85; }
.tk-img img { display: block; max-width: 240px; max-height: 180px; object-fit: cover; }
.tk-closed { margin: 0; padding: var(--s-3) var(--s-5); font-size: 0.875rem; color: var(--text); background: var(--surface); border-top: 1px solid var(--border); border-left: 3px solid var(--warn); }
#tk-bas { flex: none; background: var(--surface); }

/* --- Saisie ------------------------------------------------------------------------------------------ */
.tk-compose { padding: var(--s-3) var(--s-4) var(--s-4); border-top: 1px solid var(--border); }
.tk-form .tk-compose { padding: 0; border: 0; }
.tk-compose.drop .tk-box { outline: 2px dashed var(--accent); outline-offset: 3px; }
.tk-previews { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.tk-previews:not(:empty) { margin-bottom: var(--s-3); }
.tk-box { background: var(--bg); border: 1px solid var(--border-strong); transition: border-color 0.15s; }
.tk-box:focus-within { border-color: var(--accent); }
.tk-box textarea { display: block; width: 100%; min-height: 48px; max-height: 220px; padding: 12px var(--s-4); resize: none; font: inherit; font-size: 1rem; line-height: 1.55; color: var(--text); background: transparent; border: 0; border-radius: 0; }
.tk-box textarea:focus { outline: none; }
.tk-box textarea::placeholder { color: var(--text-2); }
.tk-compose-bar { position: relative; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-2); border-top: 1px solid var(--border); }
.tk-compose-bar .sp { flex: 1; }
.tk-compose-bar .tk-btn, .tk-compose-bar .btn { white-space: nowrap; }
.tk-compose-bar .tk-count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-2); }
.tk-compose-bar .tk-count.pres { color: var(--warn); }
.tk-compose-bar .btn { padding: 8px 20px; }
.tk-compose-bar .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tk-compose > .tk-hint { display: block; margin-top: var(--s-2); line-height: 1.5; }
.tk-prev { position: relative; width: 84px; height: 84px; border: 1px solid var(--border-strong); background: var(--bg); }
.tk-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tk-prev.load img { opacity: 0.35; }
.tk-prev.load::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50% !important; animation: tk-spin 0.8s linear infinite; }
.tk-prev-x { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0; line-height: 20px; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 50% !important; cursor: pointer; }
.tk-prev-x:hover { color: var(--danger); border-color: var(--danger); }
@keyframes tk-spin { to { transform: rotate(360deg); } }

/* Modèles de réponse (équipe) */
.tk-menu { position: absolute; left: var(--s-2); bottom: calc(100% + 6px); z-index: 30; width: min(420px, calc(100vw - 48px)); max-height: 320px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border-strong); animation: tk-rise 0.15s ease both; }
.tk-menu button { display: block; width: 100%; padding: 10px var(--s-4); font: inherit; font-size: 0.9375rem; line-height: 1.45; text-align: left; color: var(--text); background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.tk-menu button:hover { background: var(--accent); color: #fff; }
.tk-menu button b { display: block; font-size: 0.8125rem; color: var(--accent-hover); }
.tk-menu button:hover b { color: #fff; }
.tk-menu .foot { color: var(--text-2); font-size: 0.8125rem; }
.tk-menu .sup { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); border-bottom: 1px solid var(--border); }
.tk-menu .sup button { border: 0; flex: 1; }
.tk-menu .sup i { padding: 0 var(--s-4); font-style: normal; color: var(--text-2); cursor: pointer; }
.tk-menu .sup i:hover { color: var(--danger); }

/* --- Nouveau message --------------------------------------------------------------------------------- */
.tk-form { display: grid; gap: var(--s-5); align-content: start; padding: var(--s-5); overflow-y: auto; }
.tk-form .step { display: grid; gap: var(--s-2); }
.tk-form .step > p, .tk-lab { margin: 0; font-size: 0.875rem; font-weight: 600; color: var(--text); }
.tk-form .step > p em { font-style: normal; font-family: var(--font-mono); color: var(--accent-hover); margin-right: var(--s-2); }
.tk-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); }
.tk-cat-opt { padding: var(--s-3); font: inherit; text-align: left; color: var(--text-2); background: var(--bg); border: 1px solid var(--border-strong); cursor: pointer; transition: border-color 0.15s, background-color 0.15s, color 0.15s; }
.tk-cat-opt b { display: block; color: var(--text); font-size: 0.9375rem; }
.tk-cat-opt span { display: block; margin-top: 2px; font-size: 0.8125rem; line-height: 1.4; }
.tk-cat-opt:hover { border-color: var(--text-2); }
.tk-cat-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-2); box-shadow: none; outline: 1px solid var(--accent); }
.tk-tip { padding: var(--s-3) var(--s-4); font-size: 0.875rem; line-height: 1.6; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--accent); }
.tk-tip ul { margin: var(--s-1) 0 0; padding-left: 1.2em; color: var(--text-2); }
.tk-form input[type="text"] { width: 100%; padding: 11px var(--s-3); font: inherit; font-size: 1rem; color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 0; }
.tk-form input:focus { outline: none; border-color: var(--accent); }
.tk-sujet-n { justify-self: end; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-2); }

.tk-toast { position: fixed; left: 50%; bottom: var(--s-6); z-index: 300; max-width: min(520px, calc(100vw - 32px)); padding: var(--s-3) var(--s-5); font-size: 0.9375rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--ok); opacity: 0; visibility: hidden; transform: translate(-50%, 12px); transition: opacity 0.15s, transform 0.15s, visibility 0s 0.15s; }
.tk-toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.tk-toast.ko { border-left-color: var(--danger); }

.tk-zoom { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: var(--s-5); background: rgba(0, 0, 0, 0.88); cursor: zoom-out; }
.tk-zoom img { max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid var(--border-strong); }
.tk-zoom button { position: absolute; top: var(--s-4); right: var(--s-4); width: 36px; height: 36px; font-size: 22px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 50% !important; cursor: pointer; }

/* Dans la console admin : même composant, hauteur adaptée */
.ad .tk-app { grid-template-columns: 290px minmax(0, 1fr); height: clamp(560px, calc(100vh - 290px), 800px); }
.ad .tk-compose-bar .tk-btn { padding: 8px 10px; }
.ad .tk-compose-bar .btn { padding: 8px 16px; }

/* Mobile : la liste OU le fil, jamais les deux */
@media (max-width: 860px) {
  .tk-app { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .tk-side { border-right: 0; max-height: none; }
  .tk-list { max-height: 70vh; }
  .tk-pane { max-height: none; }
  .tk-back { display: inline-block; flex: 1 0 100%; text-align: left; }
  .tk-app[data-vue="liste"] .tk-main { display: none; }
  .tk-app[data-vue="detail"] .tk-side { display: none; }
  .tk-msg { max-width: 94%; }
  .tk-msgs { max-height: 58vh; min-height: 260px; }
  .ad .tk-app { height: auto; }
}
@media (prefers-reduced-motion: reduce) { .tk *, .tk *::before, .tk *::after { animation: none !important; transition: none !important; } .tk-toast { transition: none; } }
