/* Popup « Créer un ticket support » partagée (ticket-modal.js) : calls.html (appel) et index.html (FAQ).
   Empilement : au-dessus du bouton chatbot de la FAQ (9999) ; toasts des pages au-dessus de la popup (10030).
   Jetons de couleur des pages (--primary, --gray-*, --danger…) avec valeurs de repli. */
.tm-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 10010; display: none; }
.tm-overlay.active { display: block; }
.tm-dialog {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95);
    width: min(640px, 96vw); max-height: 88vh; background: #fff; border-radius: var(--radius, 12px);
    z-index: 10011; display: none; flex-direction: column; opacity: 0;
    box-shadow: var(--shadow-lg, 0 20px 40px -12px rgba(0, 0, 0, 0.35));
    transition: opacity 0.2s, transform 0.2s; color: var(--gray-900, #111827); text-align: left;
}
.tm-dialog.active { display: flex; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tm-dialog *, .tm-dialog *::before, .tm-dialog *::after { box-sizing: border-box; }
.tm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-200, #e5e7eb); }
.tm-heading { font-size: 1.05rem; }
.tm-subtitle { font-size: 0.8rem; color: var(--gray-500, #6b7280); margin-top: 0.2rem; overflow-wrap: anywhere; }
.tm-close { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--gray-100, #f3f4f6); color: var(--gray-700, #374151); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.tm-close:hover { background: var(--gray-200, #e5e7eb); }
.tm-body { padding: 1.25rem 1.5rem; overflow-y: auto; }
.tm-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.tm-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.tm-row > .ct-field { flex: 1; min-width: 160px; }
.tm-inline { display: flex; gap: 0.4rem; align-items: stretch; }
.tm-inline > input { flex: 1; min-width: 0; }
.tm-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200, #e5e7eb); }
.tm-req { color: var(--danger, #ef4444); }
.tm-opt { font-weight: 400; color: var(--gray-500, #6b7280); font-size: 0.78rem; }
.tm-ai-status { font-weight: 400; color: var(--primary, #3b82f6); }
.tm-note, .tm-iu-ai { font-size: 0.78rem; color: var(--gray-500, #6b7280); }
.tm-iu-ai { margin-top: 0.35rem; }
.tm-iu-guard { margin-top: 0.25rem; font-size: 0.78rem; font-weight: 600; color: var(--gray-700, #374151); }
.tm-sla-hint { font-size: 0.8rem; color: var(--gray-600, #4b5563); margin-top: 0.3rem; }
.ct-iu-edited { color: var(--gray-700, #374151); font-weight: 600; }
.tm-dialog [hidden] { display: none !important; }

.tm-btn { padding: 0.65rem 1.1rem; border: 0; border-radius: var(--radius-sm, 8px); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: background 0.15s, box-shadow 0.15s; }
.tm-btn:focus-visible, .tm-ai-btn:focus-visible, .tm-close:focus-visible, .tm-resto-item:focus-visible { outline: 2px solid var(--primary, #3b82f6); outline-offset: 2px; }
.tm-btn-primary { background: #6366f1; color: #fff; }
.tm-btn-primary:hover { background: #4f46e5; }
.tm-btn-primary:disabled { background: #a5b4fc; cursor: progress; }
.tm-btn-ghost { background: var(--gray-200, #e5e7eb); color: var(--gray-700, #374151); }
.tm-btn-ghost:hover { background: var(--gray-300, #d1d5db); }
.tm-btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.tm-ai-btn { white-space: nowrap; padding: 0 0.7rem; border: 1px solid var(--gray-300, #d1d5db); border-radius: var(--radius-sm, 8px); background: #eef2ff; color: var(--primary, #3b82f6); cursor: pointer; font-weight: 600; font: inherit; font-weight: 600; }
.tm-ai-btn:disabled { opacity: 0.6; cursor: progress; }

/* Champs (repris de calls.html) */
.ct-field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--gray-700, #374151); font-weight: 600; }
.ct-field input[type=text], .ct-field input[type=search], .ct-field input[type=tel], .ct-field textarea, .ct-field select, .ct-field input[type=file] {
    font-weight: 400; font-size: 0.88rem; padding: 0.5rem 0.6rem; border: 1px solid var(--gray-300, #d1d5db);
    border-radius: var(--radius-sm, 8px); width: 100%; font-family: inherit; background: #fff; color: inherit;
}
.ct-field textarea { resize: vertical; line-height: 1.45; }
.ct-field input:focus, .ct-field textarea:focus, .ct-field select:focus { outline: 2px solid var(--primary, #3b82f6); outline-offset: 0; border-color: transparent; }
.ct-priority { --ct-prio-color: #6b7280; --ct-prio-text: #4b5563; padding: 1rem; border: 1px solid color-mix(in srgb, var(--ct-prio-color) 30%, white); border-radius: var(--radius-sm, 8px); background-color: color-mix(in srgb, var(--ct-prio-color) 7%, white); transition: background-color 150ms ease, border-color 150ms ease; }
.ct-priority[data-prio="3"] { --ct-prio-color: var(--danger, #ef4444); --ct-prio-text: #b91c1c; }
.ct-priority[data-prio="2"] { --ct-prio-color: #ea580c; --ct-prio-text: #9a3412; }
.ct-priority[data-prio="1"] { --ct-prio-color: var(--warning, #f59e0b); --ct-prio-text: #92400e; }
.ct-priority[data-prio="0"] { --ct-prio-color: #64748b; --ct-prio-text: #475569; }
.ct-priority-fields { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.ct-priority-fields > .ct-field { flex: 1; min-width: 190px; }
.ct-priority-result { margin-top: 0.5rem; font-size: 0.9rem; font-weight: 700; color: var(--ct-prio-text); line-height: 1.5; }
.ct-priority-value { font-size: 1rem; font-weight: 800; }
.ct-priority-level { font-size: 0.78rem; font-weight: 400; color: var(--ct-prio-text); }
.ct-checkbox { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--gray-700, #374151); cursor: pointer; }
/* Catégories de panne : multi-choix en pastilles (cases à cocher natives → clavier Tab/Espace). */
.ct-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; font-weight: 400; }
.ct-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.28rem 0.65rem; border: 1px solid var(--gray-300, #d1d5db); border-radius: 999px; font-size: 0.8rem; color: var(--gray-700, #374151); background: #fff; cursor: pointer; user-select: none; transition: background 0.15s, border-color 0.15s; }
.ct-chip:hover { border-color: var(--primary, #3b82f6); }
.ct-chip input { margin: 0; accent-color: var(--primary, #3b82f6); cursor: pointer; }
.ct-chip:focus-within { outline: 2px solid var(--primary, #3b82f6); outline-offset: 1px; }
.ct-chip.on { border-color: var(--primary, #3b82f6); background: #eef2ff; color: var(--primary, #3b82f6); font-weight: 600; }
.ct-chip.primary::after { content: 'principale'; font-size: 0.66rem; font-weight: 700; padding: 0.05rem 0.4rem; border-radius: 999px; background: var(--primary, #3b82f6); color: #fff; }
.ct-ai-hint { font-size: 0.78rem; color: var(--gray-500, #6b7280); font-weight: 400; }

/* Saisie libre : choix du restaurant */
.tm-resto-picker { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 400; }
.tm-resto-results { max-height: min(40vh, 280px); overflow-y: auto; }
.tm-resto-results:empty { display: none; }
.tm-resto-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tm-resto-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 0.6rem; padding: 0.5rem 0.7rem; border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius-sm, 8px); background: #fff; text-align: left; font: inherit; cursor: pointer; color: inherit; }
.tm-resto-item:hover { background: var(--gray-50, #f9fafb); border-color: var(--gray-300, #d1d5db); }
.tm-resto-item .tm-resto-meta { grid-column: 1; }
.tm-resto-item .tm-resto-badge { grid-column: 2; grid-row: 1 / span 2; }
.tm-resto-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-resto-meta { font-size: 0.78rem; color: var(--gray-500, #6b7280); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-resto-badge { font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eff6ff; color: #1e40af; }
.tm-resto-state { margin: 0.2rem 0; font-size: 0.82rem; color: var(--gray-500, #6b7280); font-weight: 400; }
.tm-resto-chosen { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0.75rem; border: 1px solid var(--primary, #3b82f6); border-radius: var(--radius-sm, 8px); background: #eef2ff; font-weight: 400; }
.tm-resto-text { display: grid; min-width: 0; }

/* Multi-tickets : bandeau de proposition, onglets (un par sujet), résultats */
.tm-multi-banner { padding: 0.85rem 1rem; border: 1px solid #c7d2fe; border-left: 4px solid #6366f1; border-radius: var(--radius-sm, 8px); background: #eef2ff; color: #312e81; }
.tm-multi-title { margin: 0 0 0.45rem; font-weight: 700; font-size: 0.92rem; }
.tm-multi-list { margin: 0 0 0.7rem; padding: 0; list-style: none; display: grid; gap: 0.3rem; font-size: 0.85rem; }
.tm-multi-list li { display: flex; align-items: baseline; gap: 0.45rem; }
.tm-multi-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tm-badge { flex: none; display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--gray-200, #e5e7eb); color: var(--gray-700, #374151); white-space: nowrap; }
.tm-badge-resolu { background: #dcfce7; color: #166534; }
.tm-badge-escalade_n2 { background: #ffedd5; color: #9a3412; }
.tm-badge-transfert { background: #e0f2fe; color: #075985; }
.tm-tabs-wrap { display: grid; gap: 0.35rem; }
.tm-tabs { display: flex; gap: 0.35rem; overflow-x: auto; padding-bottom: 2px; }
.tm-tab { flex: 0 1 auto; min-width: 0; max-width: 260px; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.6rem; border: 1px solid var(--gray-300, #d1d5db); border-radius: var(--radius-sm, 8px); background: #fff; font: inherit; font-size: 0.8rem; color: var(--gray-700, #374151); cursor: pointer; }
.tm-tab:hover { border-color: #6366f1; }
.tm-tab.active { border-color: #6366f1; background: #eef2ff; color: #312e81; box-shadow: inset 0 -2px 0 #6366f1; }
.tm-tab:focus-visible { outline: 2px solid var(--primary, #3b82f6); outline-offset: 2px; }
.tm-tab-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.tm-tab-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-tab-state { font-weight: 800; }
.tm-tab-state.tm-ok { color: #15803d; }
.tm-tab-state.tm-ko { color: var(--danger, #ef4444); }
.tm-tab-remove { margin-left: 0.15rem; padding: 0 0.3rem; border-radius: 4px; color: var(--gray-500, #6b7280); font-size: 1rem; line-height: 1; }
.tm-tab-remove:hover { background: #fee2e2; color: #991b1b; }
.tm-tabs-note { margin: 0; font-size: 0.75rem; color: var(--gray-500, #6b7280); }
.tm-results { padding: 0.75rem 1rem; border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius-sm, 8px); background: var(--gray-50, #f9fafb); font-size: 0.85rem; }
.tm-results-title { margin: 0 0 0.35rem; font-weight: 700; }
.tm-results ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.35rem; }
.tm-results li { line-height: 1.5; overflow-wrap: anywhere; }
.tm-results li .tm-btn { margin-left: 0.35rem; vertical-align: middle; }
.tm-link { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; text-align: left; }
.tm-link:focus-visible { outline: 2px solid var(--primary, #3b82f6); outline-offset: 2px; }
.tm-res-ok { color: #166534; }
.tm-res-ok a { color: inherit; font-weight: 700; }
.tm-res-ko { color: #991b1b; }
.tm-res-wait { color: var(--gray-500, #6b7280); }

/* Toast (pages sans toast propre, ex. FAQ) */
.tm-toast { position: fixed; bottom: 1.5rem; right: 1.5rem; max-width: min(420px, calc(100vw - 2rem)); padding: 0.75rem 1.1rem; border-radius: var(--radius-sm, 8px); color: #fff; font-size: 0.88rem; font-weight: 500; z-index: 10030; background: #374151; box-shadow: 0 10px 25px -8px rgba(0, 0, 0, 0.35); transform: translateY(20px); opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
.tm-toast.show { opacity: 1; transform: none; pointer-events: auto; }
.tm-toast-success { background: var(--success, #10b981); }
.tm-toast-error { background: var(--danger, #ef4444); }
.tm-toast a { color: #fff; font-weight: 700; text-decoration: underline; margin-left: 0.35rem; }

body.tm-open { overflow: hidden; }

@media (max-width: 639px) {
    .ct-priority-fields > .ct-field { flex-basis: 100%; min-width: 0; }
    .tm-row > .ct-field { flex-basis: 100%; min-width: 0; }
    .tm-dialog { top: 0; left: 0; transform: none; width: 100vw; max-height: none; height: 100%; border-radius: 0; }
    .tm-dialog.active { transform: none; }
    .tm-head, .tm-body, .tm-foot { padding-left: 1rem; padding-right: 1rem; }
    .tm-foot .tm-btn { flex: 1; }
    .tm-toast { left: 1rem; right: 1rem; bottom: auto; top: 1rem; max-width: none; transform: translateY(-20px); }
}
@media (prefers-reduced-motion: reduce) {
    .ct-priority, .tm-dialog, .tm-toast { transition: none; }
}
