/* ========================================
   TEAM MODULE STYLES
   Follows customer.css patterns and design tokens
   ======================================== */

/* ── Toolbar ── */
.team-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.team-search {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.team-search__icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    stroke: var(--color-text-muted);
    pointer-events: none;
}

.team-search__input {
    width: 100%;
    padding: 12px 12px 12px 44px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.team-search__input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.team-search__input::placeholder {
    color: var(--color-text-muted);
}

.team-search__clear {
    position: absolute;
    right: 10px;
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-error);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.team-search__clear:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ── Filter Pills ── */
.team-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.team-filter-pill {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.team-filter-pill:hover {
    border-color: rgba(13, 148, 136, 0.4);
    color: var(--color-primary);
}

.team-filter-pill--active {
    background: rgba(13, 148, 136, 0.15);
    border-color: rgba(13, 148, 136, 0.4);
    color: var(--color-primary);
    font-weight: 600;
}

.team-filter-pill--active:hover {
    background: rgba(13, 148, 136, 0.15);
    border-color: rgba(13, 148, 136, 0.4);
    color: var(--color-primary);
}

.team-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* ── Cards Grid ── */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    animation: team-fade-in 0.3s ease;
}

@keyframes team-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.team-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.team-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), #6366f1);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.team-card:hover {
    border-color: rgba(13, 148, 136, 0.4);
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(13, 148, 136, 0.1);
    transform: translateY(-2px);
}

.team-card:hover::before {
    opacity: 1;
}

.team-card__header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.team-card__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.team-card__info {
    min-width: 0;
    flex: 1;
}

.team-card__name {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-card__you {
    font-size: 11px;
    font-weight: 400;
    color: var(--color-text-muted);
}

.team-card__email {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-card__badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.team-card__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--color-text-muted);
}

.team-card__meta svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* ── Role & Status Badges ── */
.team-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.team-badge--owner {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.team-badge--manager {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.team-badge--staff {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.team-badge--cleaner {
    background: rgba(20, 184, 166, 0.15);
    color: #14b8a6;
}

.team-badge--active {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.team-badge--pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

/* ── Empty State ── */
.team-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.team-empty__icon {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
    opacity: 0.3;
}

.team-empty__icon svg {
    width: 100%;
    height: 100%;
    stroke: var(--color-text-muted);
}

.team-empty__title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.team-empty__subtitle {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.team-empty__btn {
    padding: 12px 32px;
}

/* ── FAB ── */
.team-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #6366f1);
    border: none;
    box-shadow:
        0 6px 20px rgba(13, 148, 136, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.team-fab svg {
    width: 24px;
    height: 24px;
    stroke: white;
    transition: transform 0.3s ease;
}

.team-fab:hover {
    transform: scale(1.08);
    box-shadow:
        0 8px 28px rgba(13, 148, 136, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

.team-fab:active {
    transform: scale(0.96);
}

/* ── Detail View ── */
.team-detail__header {
    margin-bottom: 28px;
}

.team-detail__back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.15s ease;
}

.team-detail__back svg {
    width: 18px;
    height: 18px;
}

.team-detail__back:hover {
    opacity: 0.8;
    transform: translateX(-2px);
}

.team-detail__profile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.team-detail__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.team-detail__profile-info {
    min-width: 0;
}

.team-detail__name {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.team-detail__email {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.team-detail__badges {
    display: flex;
    gap: 6px;
}

/* ── Sections ── */
.team-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    overflow: hidden;
    animation: team-fade-in 0.3s ease;
}

.team-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(51, 65, 85, 0.15);
    border-bottom: 1px solid var(--color-border);
}

.team-section__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.team-section__body {
    padding: 20px;
}

/* ── Detail Fields ── */
.team-detail__field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.team-detail__field:last-child {
    border-bottom: none;
}

.team-detail__label {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.team-detail__value {
    font-size: 14px;
    color: var(--color-text);
    font-weight: 500;
}

/* ── Role Select (detail view) ── */
.team-role-grid--detail {
    display: flex;
    gap: 6px;
}

.team-role-grid--detail .team-role-option {
    padding: 6px 14px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Action Buttons ── */
.team-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: 2px dashed rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-md);
    background: none;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.team-action-btn:last-child {
    margin-bottom: 0;
}

.team-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.team-action-btn--resend:hover {
    background: rgba(13, 148, 136, 0.04);
    border-color: rgba(13, 148, 136, 0.3);
    color: var(--color-primary);
}

.team-action-btn--danger:hover {
    background: rgba(239, 68, 68, 0.04);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ── Invite Panel (Slide-in) ── */
.team-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.team-panel-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

.team-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    max-width: 100vw;
    background: var(--color-bg);
    border-left: 1px solid var(--color-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.team-panel--open {
    transform: translateX(0);
}

.team-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-card);
    flex-shrink: 0;
}

.team-panel__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.team-panel__title svg {
    width: 22px;
    height: 22px;
    stroke: var(--color-primary);
}

.team-panel__close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.team-panel__close:hover {
    background: var(--color-bg-input);
    color: var(--color-text);
}

.team-panel__close svg {
    width: 18px;
    height: 18px;
}

.team-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.team-panel__actions {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
    margin-top: 20px;
}

.team-panel__actions .btn {
    flex: 1;
}

/* ── Role Grid (Invite Form) ── */
.team-role-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.team-role-option {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.team-role-option:hover {
    border-color: rgba(13, 148, 136, 0.3);
    color: var(--color-text);
}

.team-role-option--active {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.1);
    color: var(--color-primary);
}

.team-role-option--active.team-role-option--owner {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.team-role-option--active.team-role-option--manager {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.team-role-option--active.team-role-option--staff {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.team-role-option--active.team-role-option--cleaner {
    border-color: #14b8a6;
    background: rgba(20, 184, 166, 0.1);
    color: #14b8a6;
}

/* ── Toast ── */
.team-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: white;
    z-index: 20000;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.team-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.team-toast--success {
    background: linear-gradient(135deg, #059669, #10b981);
}

.team-toast--error {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.team-toast--info {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

/* ── Loading ── */
.team-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* ── Shake Animations (reuse from customer) ── */
.team-panel .shake-mild {
    animation: shake-mild 0.4s ease;
}

.team-panel .shake-medium {
    animation: shake-medium 0.5s ease;
}

.team-panel .shake-hard {
    animation: shake-hard 0.6s ease;
}

.team-panel .input-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .team-grid {
        grid-template-columns: 1fr;
    }

    .team-panel {
        width: 100vw;
    }

    .team-fab {
        bottom: 20px;
        right: 20px;
    }

    .team-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .team-detail__profile {
        flex-direction: column;
        text-align: center;
    }

    .team-detail__name {
        font-size: 22px;
    }
}
