/* =========================================================
   TEAM
   Role legend with live counts, then the people table.
========================================================= */

/* ---------- role legend ---------- */

.tm-roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--border); overflow: hidden; box-shadow: var(--shadow-sm); }
.tm-role-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); }
.tm-role-card.is-admin { background: var(--primary-soft-2); }
.tm-role-card dt { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tm-role-card dt b { font-size: 22px; line-height: 1; font-weight: 800; letter-spacing: -.03em; color: var(--text); font-variant-numeric: tabular-nums; }
.tm-role-card dd { margin: 0; font-size: 12px; line-height: 1.45; color: var(--text-2); }

.tm-role { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; background: var(--surface-soft); border: 1px solid var(--border); color: var(--text-2); }
.tm-role.is-admin { background: var(--primary); border-color: var(--primary); color: #fff; }
.tm-role.is-member { background: var(--primary-soft-2); border-color: var(--primary-soft); color: var(--primary-dark); }

.tm-note { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-md); background: var(--warning-soft); color: var(--warning); font-size: 12.5px; font-weight: 600; }
.tm-note[hidden] { display: none; }
.tm-note svg { flex: none; width: 18px; height: 18px; }

/* ---------- table ---------- */

.tm-card { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.tm-table { min-width: 680px; }
.tm-table th { font-size: 10.5px; padding: 11px 14px; }
.tm-table td { padding: 12px 14px; font-size: 12.5px; color: var(--text-2); }
.tm-table tbody tr { cursor: default; }
.tm-table tbody tr.is-you { background: var(--surface-soft); }
.tm-table tr.tm-state:hover { background: transparent; }
.tm-c-added { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-3); }
.tm-c-email { overflow-wrap: anywhere; }
.tm-c-action { text-align: right; }

.tm-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tm-person b { color: var(--text); font-weight: 700; overflow-wrap: anywhere; }
.tm-avatar { flex: 0 0 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft-2); color: var(--primary-dark); font-size: 11.5px; font-weight: 800; }
.is-you .tm-avatar { background: var(--primary-gradient); color: #fff; }
.tm-you { padding: 1px 7px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-strong); font-size: 10.5px; font-weight: 800; color: var(--text-2); }
.tm-muted { font-size: 11.5px; color: var(--text-3); }

.tm-role-select.lab-select { width: auto; min-width: 120px; min-height: 44px; padding-top: 0; padding-bottom: 0; font-size: 12.5px; font-weight: 600; }
.tm-role-select:disabled { opacity: .6; }
.tm-remove { min-height: 44px; padding: 0 14px; font-size: 12px; color: var(--text-2); }
.tm-remove:hover, .tm-remove:focus-visible { background: var(--danger-soft); color: var(--danger); }

.tm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- states ---------- */

.tm-empty { padding: 32px 16px; text-align: center; }
.tm-empty h3 { margin: 0; font-size: 14px; color: var(--text); }
.tm-empty p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-3); }

.tm-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; font-weight: 700; }
.tm-error .btn { min-height: 36px; }

.tm-skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-soft) 0%, var(--surface-hover) 50%, var(--surface-soft) 100%); background-size: 200% 100%; animation: tm-shimmer 1.4s ease-in-out infinite; }
@keyframes tm-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .tm-skeleton { animation: none; } }

/* ---------- dialog ---------- */

.modal-overlay .tm-modal { width: min(480px, 100%); }
.tm-modal .modal-header { align-items: center; }
.tm-modal-sub { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.tm-close { width: 44px; height: 44px; }
.tm-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.tm-field > span { font-size: 12px; font-weight: 700; color: var(--text); }
.tm-field small { font-size: 11px; color: var(--text-3); }
.tm-field .lab-input, .tm-field .lab-select { min-height: 40px; font-size: 13px; }
.tm-form-error { margin: 4px 0 0; padding: 9px 11px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 12px; font-weight: 700; }
.tm-modal .modal-footer .btn { min-height: 44px; padding: 0 16px; font-size: 12.5px; }

/* ---------- small screens: rows become cards ---------- */

@media (max-width: 640px) {
    #page-team .page-actions .btn { min-height: 44px; }
    .tm-roles { grid-template-columns: 1fr; }
    .tm-role-card { flex-direction: row; align-items: center; gap: 12px; }
    .tm-role-card dt { flex-direction: column-reverse; align-items: flex-start; gap: 6px; min-width: 76px; }

    .tm-table { min-width: 0; }
    .tm-table thead { display: none; }
    .tm-table tbody tr:not(.tm-state) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "name name" "email email" "role action" "added added";
        gap: 6px 10px;
        padding: 14px;
        border-bottom: 1px solid var(--border);
    }
    .tm-table tbody tr:last-child { border-bottom: 0; }
    .tm-table tbody tr:not(.tm-state) td { padding: 0; border: 0; }
    .tm-c-name { grid-area: name; }
    .tm-c-email { grid-area: email; font-size: 12px; }
    .tm-c-role { grid-area: role; }
    .tm-c-action { grid-area: action; align-self: center; }
    .tm-c-added { grid-area: added; font-size: 11.5px; }
    .tm-table tbody tr:not(.tm-state) :is(.tm-c-email, .tm-c-role, .tm-c-added) { padding-left: 42px; }
    .tm-c-added::before { content: "Added "; }
    .tm-role-select.lab-select, .tm-remove { min-height: 44px; }
    .tm-table tr.tm-state td { display: block; }
    .tm-table tr.tm-state[aria-hidden] td:nth-child(n+3) { display: none; }
}
