/* ─────────────────────────────────────────────────────────────────────────────
   teams.css — BEM tm-* namespace
   Team Management page: team cards, member roster, invite form, modals
───────────────────────────────────────────────────────────────────────────── */

/* ── Page ─────────────────────────────────────────────────────────────────── */
.tm-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── Page header row ──────────────────────────────────────────────────────── */
.tm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
}

.tm-header__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
}

.tm-header__subtitle {
    font-size: .8125rem;
    color: #94a3b8;
    margin: .125rem 0 0;
}

/* ── Primary action button ────────────────────────────────────────────────── */
.tm-btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem 1rem;
    border-radius: .375rem;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background .15s, opacity .15s;
}

.tm-btn--primary {
    background: #6366f1;
    color: #fff;
}

.tm-btn--primary:hover:not(:disabled) {
    background: #4f46e5;
}

.tm-btn--secondary {
    background: rgba(99,102,241,.12);
    color: #a5b4fc;
    border: 1px solid rgba(99,102,241,.25);
}

.tm-btn--secondary:hover:not(:disabled) {
    background: rgba(99,102,241,.2);
}

.tm-btn--danger {
    background: rgba(239,68,68,.12);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,.25);
}

.tm-btn--danger:hover:not(:disabled) {
    background: rgba(239,68,68,.2);
}

.tm-btn--ghost {
    background: transparent;
    color: #94a3b8;
    border: 1px solid rgba(148,163,184,.2);
}

.tm-btn--ghost:hover:not(:disabled) {
    color: #f1f5f9;
    border-color: rgba(148,163,184,.4);
}

.tm-btn--sm {
    padding: .3rem .625rem;
    font-size: .8125rem;
}

.tm-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.tm-btn .material-symbols-outlined {
    font-size: 1.1em;
}

/* ── Invitations banner ───────────────────────────────────────────────────── */
.tm-invites-banner {
    background: rgba(99,102,241,.1);
    border: 1px solid rgba(99,102,241,.3);
    border-radius: .5rem;
    padding: 1rem 1.25rem;
}

.tm-invites-banner__heading {
    font-size: .9375rem;
    font-weight: 600;
    color: #c7d2fe;
    margin: 0 0 .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.tm-invites-banner__heading .material-symbols-outlined {
    font-size: 1.25rem;
    color: #818cf8;
}

.tm-invite-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .5rem 0;
    border-top: 1px solid rgba(99,102,241,.15);
}

.tm-invite-row:first-of-type {
    border-top: none;
}

.tm-invite-row__info {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.tm-invite-row__team {
    font-size: .9375rem;
    font-weight: 600;
    color: #f1f5f9;
}

.tm-invite-row__meta {
    font-size: .8125rem;
    color: #94a3b8;
}

.tm-invite-row__actions {
    display: flex;
    gap: .5rem;
}

/* ── Team card ─────────────────────────────────────────────────────────────── */
.tm-card {
    background: #1e2330;
    border: 1px solid rgba(148,163,184,.1);
    border-radius: .625rem;
    overflow: hidden;
}

.tm-card--personal {
    border-color: rgba(99,102,241,.2);
}

.tm-card__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}

.tm-card__header:hover {
    background: rgba(255,255,255,.025);
}

/* Team icon circle */
.tm-card__icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    flex-shrink: 0;
}

.tm-card__icon--personal {
    background: rgba(99,102,241,.18);
    color: #a5b4fc;
}

.tm-card__icon--org {
    background: rgba(16,185,129,.15);
    color: #6ee7b7;
}

.tm-card__info {
    flex: 1;
    min-width: 0;
}

.tm-card__name {
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-card__meta {
    font-size: .8125rem;
    color: #64748b;
    margin-top: .1rem;
}

.tm-card__badges {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}

.tm-card__chevron {
    color: #64748b;
    font-size: 1.25rem;
    transition: transform .2s;
    flex-shrink: 0;
    font-variation-settings: 'wght' 400;
    font-family: 'Material Symbols Outlined';
}

.tm-card__chevron--open {
    transform: rotate(180deg);
}

/* ── Badge ──────────────────────────────────────────────────────────────────── */
.tm-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1;
}

.tm-badge--owner { background: rgba(245,158,11,.15); color: #fcd34d; }
.tm-badge--admin { background: rgba(99,102,241,.15); color: #a5b4fc; }
.tm-badge--member { background: rgba(15,118,110,.15); color: #5eead4; }
.tm-badge--viewer { background: rgba(148,163,184,.1); color: #94a3b8; }
.tm-badge--personal { background: rgba(99,102,241,.1); color: #818cf8; }
.tm-badge--org { background: rgba(16,185,129,.1); color: #34d399; }
.tm-badge--active { background: rgba(16,185,129,.12); color: #6ee7b7; }
.tm-badge--invited { background: rgba(245,158,11,.12); color: #fde68a; }
.tm-badge--default { background: rgba(139,92,246,.12); color: #c4b5fd; }

/* ── Card body (expanded) ───────────────────────────────────────────────────── */
.tm-card__body {
    border-top: 1px solid rgba(148,163,184,.08);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* actions row inside card body */
.tm-card__actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

/* ── Member table ───────────────────────────────────────────────────────────── */
.tm-members-heading {
    font-size: .8125rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .75rem;
}

.tm-members {
    width: 100%;
    border-collapse: collapse;
}

.tm-members th {
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .35rem .6rem;
    border-bottom: 1px solid rgba(148,163,184,.08);
}

.tm-members td {
    padding: .6rem .6rem;
    font-size: .875rem;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(148,163,184,.05);
    vertical-align: middle;
}

.tm-members tr:last-child td {
    border-bottom: none;
}

.tm-member-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(99,102,241,.18);
    color: #a5b4fc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    margin-right: .5rem;
}

.tm-member-name {
    font-weight: 500;
    color: #f1f5f9;
}

.tm-member-email {
    font-size: .8125rem;
    color: #64748b;
}

.tm-members-loading {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #64748b;
    font-size: .875rem;
    padding: .5rem 0;
}

/* ── Invite form ────────────────────────────────────────────────────────────── */
.tm-invite-form {
    background: rgba(15,23,42,.4);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: .5rem;
    padding: 1rem 1.25rem;
}

.tm-invite-form__title {
    font-size: .875rem;
    font-weight: 600;
    color: #c7d2fe;
    margin: 0 0 .75rem;
}

.tm-invite-form__row {
    display: flex;
    gap: .625rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.tm-invite-form__row .tm-field {
    flex: 1;
    min-width: 160px;
}

.tm-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.tm-field label {
    font-size: .8125rem;
    color: #94a3b8;
    font-weight: 500;
}

.tm-input, .tm-select {
    background: #0f1629;
    border: 1px solid rgba(148,163,184,.15);
    border-radius: .375rem;
    color: #f1f5f9;
    padding: .5rem .75rem;
    font-size: .875rem;
    width: 100%;
    outline: none;
    transition: border .15s;
}

.tm-input:focus, .tm-select:focus {
    border-color: rgba(99,102,241,.5);
}

.tm-input::placeholder {
    color: #475569;
}

.tm-select option {
    background: #1e2330;
}

.tm-field-error {
    font-size: .8125rem;
    color: #f87171;
    margin-top: .25rem;
}

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.tm-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,.15);
    border-top-color: #a5b4fc;
    border-radius: 50%;
    animation: tm-spin .6s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes tm-spin {
    to { transform: rotate(360deg); }
}

/* ── Loading skeleton ───────────────────────────────────────────────────────── */
.tm-skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,.04) 25%,
        rgba(255,255,255,.08) 50%,
        rgba(255,255,255,.04) 75%);
    background-size: 200% 100%;
    animation: tm-shimmer 1.4s infinite;
    border-radius: .375rem;
}

@keyframes tm-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.tm-skeleton-card {
    height: 4rem;
    border-radius: .625rem;
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.tm-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #64748b;
}

.tm-empty .material-symbols-outlined {
    font-size: 3rem;
    color: #334155;
    display: block;
    margin: 0 auto .75rem;
}

.tm-empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .25rem;
}

.tm-empty-desc {
    font-size: .875rem;
    color: #64748b;
    margin-bottom: 1.25rem;
}

/* ── Error banner ────────────────────────────────────────────────────────────── */
.tm-error-banner {
    background: rgba(239,68,68,.1);
    border: 1px solid rgba(239,68,68,.25);
    border-radius: .5rem;
    padding: 1rem 1.25rem;
    color: #fca5a5;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.tm-error-banner .material-symbols-outlined {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ── Modal overlay ──────────────────────────────────────────────────────────── */
.tm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.78);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.tm-modal {
    background: #1e2330;
    border: 1px solid rgba(148,163,184,.12);
    border-radius: .75rem;
    width: 100%;
    max-width: 460px;
    position: relative;
    z-index: 10000;
    box-shadow: 0 24px 64px rgba(0,0,0,.6);
}

.tm-modal__header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid rgba(148,163,184,.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tm-modal__title {
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
}

.tm-modal__close {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: .25rem;
    display: flex;
    align-items: center;
    transition: color .15s;
}

.tm-modal__close:hover {
    color: #f1f5f9;
}

.tm-modal__body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tm-modal__footer {
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: .625rem;
    border-top: 1px solid rgba(148,163,184,.08);
}

/* ── Confirm dialog ─────────────────────────────────────────────────────────── */
.tm-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.78);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.tm-confirm {
    background: #1e2330;
    border: 1px solid rgba(239,68,68,.25);
    border-radius: .75rem;
    max-width: 400px;
    width: 100%;
    padding: 1.5rem;
    position: relative;
    z-index: 10000;
    box-shadow: 0 24px 64px rgba(0,0,0,.6);
}

.tm-confirm__icon {
    font-size: 2rem;
    color: #f87171;
    margin-bottom: .5rem;
    font-variation-settings: 'wght' 400;
    font-family: 'Material Symbols Outlined';
}

.tm-confirm__title {
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0 0 .5rem;
}

.tm-confirm__msg {
    font-size: .875rem;
    color: #94a3b8;
    margin: 0 0 1.25rem;
}

.tm-confirm__actions {
    display: flex;
    justify-content: flex-end;
    gap: .625rem;
}

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.tm-toast {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    background: #1e2330;
    border: 1px solid rgba(148,163,184,.15);
    border-radius: .5rem;
    padding: .875rem 1.25rem;
    font-size: .875rem;
    color: #f1f5f9;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: .625rem;
    max-width: 360px;
    animation: tm-toast-in .2s ease;
}

.tm-toast--ok { border-color: rgba(16,185,129,.35); }
.tm-toast--ok .material-symbols-outlined { color: #34d399; }
.tm-toast--err { border-color: rgba(239,68,68,.35); }
.tm-toast--err .material-symbols-outlined { color: #f87171; }

@keyframes tm-toast-in {
    from { opacity: 0; transform: translateY(.5rem); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Role select colour hints ──────────────────────────────────────────────── */
.tm-role-hint {
    font-size: .75rem;
    color: #64748b;
    margin-top: .2rem;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .tm-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tm-members th:last-child,
    .tm-members td:last-child {
        display: none;
    }

    .tm-invite-form__row {
        flex-direction: column;
    }
}
