/* ==========================================================================
   Teams Page - Team management, tile list, detail view
   ========================================================================== */

/* --------------------------------------------------------------------------
   Toolbar (Add button + Search)
   -------------------------------------------------------------------------- */

.teams-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.teams-search {
    position: relative;
    flex: 0 0 260px;
}

.teams-search .bi-search {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8125rem;
    pointer-events: none;
}

.teams-search input {
    padding-left: 32px;
}

/* --------------------------------------------------------------------------
   Mobile Dropdown (visible < 768px)
   -------------------------------------------------------------------------- */

.teams-mobile-select {
    display: none;
    margin-bottom: var(--space-md);
}

/* --------------------------------------------------------------------------
   Two-Column Layout
   -------------------------------------------------------------------------- */

.teams-layout {
    display: flex;
    gap: var(--space-lg);
    min-height: 500px;
}

.teams-sidebar {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
}

.teams-detail {
    flex: 1;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Tile List (Left Side)
   -------------------------------------------------------------------------- */

.teams-tile-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 600px;
    overflow-y: auto;
    padding-right: var(--space-xs);
}

.team-tile {
    padding: var(--space-md);
    background-color: var(--bg-tile);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.team-tile:hover {
    background-color: var(--bg-tile-hover);
    border-color: var(--accent-primary);
}

.team-tile.active {
    background-color: rgba(var(--accent-primary-rgb), 0.1);
    border-color: var(--accent-primary);
    box-shadow: inset 3px 0 0 var(--accent-primary);
}

.team-tile-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.team-tile.active .team-tile-name {
    color: var(--accent-primary);
}

.team-tile-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.teams-empty-search {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   Team Detail (Right Side)
   -------------------------------------------------------------------------- */

.team-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color-light);
}

.team-detail-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-xs) 0;
}

.team-detail-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.team-detail-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Edit Mode Fields
   -------------------------------------------------------------------------- */

.team-edit-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.team-edit-fields input,
.team-edit-fields textarea {
    font-size: 0.875rem;
}

/* --------------------------------------------------------------------------
   Members Toolbar (count + add/remove buttons)
   -------------------------------------------------------------------------- */

.team-members-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.team-members-count {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Members Table — Horizontally scrollable with sticky Name column
   -------------------------------------------------------------------------- */

.team-table-scroll-wrapper {
    overflow-x: auto;
    position: relative;
}

.team-members-table {
    font-size: 0.8125rem;
    white-space: nowrap;
}

/* Sticky Name column (read mode — Name is first column) */
.team-members-table .sticky-name {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--bg-tile, #fff);
    min-width: 150px;
}

.team-members-table thead .sticky-name {
    z-index: 3;
    background-color: var(--bg-secondary, #f8f9fa);
}

/* When checkbox column exists (edit mode), pin it first, shift Name */
.team-members-table .sticky-cb {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--bg-tile, #fff);
    min-width: 36px;
    width: 36px;
}

.team-members-table thead .sticky-cb {
    z-index: 3;
    background-color: var(--bg-secondary, #f8f9fa);
}

.has-checkbox .team-members-table .sticky-name {
    left: 36px;
}

/* Right shadow on sticky column to indicate scrollable content */
.team-members-table .sticky-name::after {
    content: '';
    position: absolute;
    top: 0;
    right: -6px;
    bottom: 0;
    width: 6px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
}

/* Row hover: override sticky cell backgrounds */
.team-members-table tbody tr:hover .sticky-name,
.team-members-table tbody tr:hover .sticky-cb {
    background-color: var(--bg-tile-hover, #f0f0f0);
}

/* --------------------------------------------------------------------------
   Add Members Modal
   -------------------------------------------------------------------------- */

.add-members-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
}

.add-members-table-wrapper .already-member {
    opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Outline Danger Button (delete, remove)
   -------------------------------------------------------------------------- */

.btn-outline-danger {
    border: 1px solid var(--alert-error-text, #dc3545);
    color: var(--alert-error-text, #dc3545);
    background: transparent;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-outline-danger:hover {
    background-color: var(--alert-error-bg, #f8d7da);
    color: var(--alert-error-text, #dc3545);
}

.btn-outline-danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Responsive: < 768px
   -------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    .teams-sidebar {
        display: none;
    }

    .teams-mobile-select {
        display: block;
    }

    .teams-layout {
        flex-direction: column;
    }

    .teams-toolbar {
        flex-wrap: wrap;
    }

    .teams-search {
        flex: 1 1 200px;
    }

    .team-detail-header {
        flex-direction: column;
    }

    .team-detail-actions {
        align-self: flex-end;
    }
}
