/* ========================================
 * Coach Browser — Two-Pane Split Layout
 * Sidebar coach list + inline content panel
 * ======================================== */

/* ── Layout Shell ── */
.coach-browser {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: 1fr;
    height: calc(100vh - 60px);
    overflow: hidden;
    position: relative;
}

/* ── Sidebar ── */
.coach-browser__sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--bg-primary);
    overflow: hidden;
}

.coach-browser__sidebar-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 16px 16px 0;
    flex-shrink: 0;
}

.coach-browser__title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.coach-browser__count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Search */
.coach-browser__search {
    position: relative;
    padding: 12px 16px 8px;
    flex-shrink: 0;
}

.coach-browser__search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.8rem;
    pointer-events: none;
}

.coach-browser__search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.coach-browser__search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.coach-browser__search-input:focus {
    border-color: var(--cta-primary);
    box-shadow: 0 0 0 3px rgba(var(--cta-primary-rgb, 59, 130, 246), 0.15);
}

/* Filter pills (conference + role) */
.coach-browser__pills {
    display: flex;
    gap: 6px;
    padding: 4px 16px 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.coach-browser__pills .coaches-pill {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.coach-browser__pills .coaches-pill-count {
    min-width: 18px;
    height: 16px;
    font-size: 0.65rem;
}

/* Shared pill styles */
.coaches-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background-color: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.coaches-pill:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.coaches-pill:focus-visible {
    outline: 2px solid var(--cta-primary);
    outline-offset: 2px;
}

.coaches-pill.active {
    background-color: var(--cta-primary, #3b82f6);
    border-color: var(--cta-primary, #3b82f6);
    color: #fff;
}

.coaches-pill.active .coaches-pill-count {
    background-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.coaches-pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    background-color: var(--bg-secondary, rgba(128, 128, 128, 0.12));
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    transition: all 0.2s ease;
}

/* Role pills row */
.coach-browser__role-pills {
    display: flex;
    gap: 6px;
    padding: 0 16px 10px;
    flex-shrink: 0;
}

.coach-browser__role-pills .coaches-pill {
    padding: 3px 10px;
    font-size: 0.72rem;
}

/* Coach list */
.coach-browser__list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

.coach-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px 8px 0;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
    font-family: inherit;
    transition: background-color 0.15s ease;
    position: relative;
    min-height: 48px;
}

.coach-list-item:hover {
    background-color: var(--bg-card);
}

.coach-list-item:focus-visible {
    outline: 2px solid var(--cta-primary);
    outline-offset: -2px;
    border-radius: 4px;
}

.coach-list-item.active {
    background-color: var(--bg-card);
}

.coach-list-item.active .coach-list-item__accent {
    width: 4px;
}

.coach-list-item__accent {
    width: 3px;
    align-self: stretch;
    flex-shrink: 0;
    border-radius: 0 2px 2px 0;
    transition: width 0.15s ease;
}

.coach-list-item__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
}

.coach-list-item__initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: var(--bg-secondary, #374151);
    letter-spacing: 0.02em;
}

.coach-list-item__info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 1px;
    flex: 1;
}

.coach-list-item__name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coach-list-item__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coach-list-item__role-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

.coach-list-item__role-badge--hc {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.coach-list-item__role-badge--oc {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.coach-list-item__role-badge--dc {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Hidden items (filtered out) */
.coach-list-item.item-hidden {
    display: none;
}

/* Empty state */
.coach-browser__empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
}

.coach-browser__empty i {
    font-size: 1.5rem;
    opacity: 0.4;
    margin-bottom: 8px;
}

.coach-browser__empty p {
    font-size: 0.85rem;
    margin: 0 0 12px;
}

.coach-browser__empty-reset {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 16px;
    color: var(--cta-primary);
    font-size: 0.82rem;
    cursor: pointer;
}

.coach-browser__empty-reset:hover {
    background-color: var(--bg-card);
}

/* ── Content Panel ── */
.coach-browser__content {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: var(--bg-primary);
    position: relative;
}

/* Adapt coach profile layout inside the browser content panel */
.coach-browser__content .command-center {
    grid-template-columns: 1fr;
    max-width: 100%;
}

@media (min-width: 1200px) {
    .coach-browser__content .command-center {
        grid-template-columns: minmax(300px, 380px) 1fr;
    }
}

/* Welcome state */
.coach-browser__welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    gap: 8px;
}

.coach-browser__welcome i {
    font-size: 3rem;
    opacity: 0.2;
}

.coach-browser__welcome h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.coach-browser__welcome p {
    margin: 0;
    font-size: 0.9rem;
}

/* Content fade transition */
.coach-browser__content-inner {
    animation: cb-fadeIn 0.2s ease-out;
}

@keyframes cb-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Skeleton loader */
.coach-browser__skeleton {
    animation: cb-fadeIn 0.15s ease-out;
}

.coach-browser__skeleton-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.coach-browser__skeleton-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-card);
    animation: cb-shimmer 1.2s ease-in-out infinite;
}

.coach-browser__skeleton-text {
    flex: 1;
}

.coach-browser__skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: var(--bg-card);
    animation: cb-shimmer 1.2s ease-in-out infinite;
    margin-bottom: 8px;
}

.coach-browser__skeleton-line--title {
    width: 50%;
    height: 20px;
}

.coach-browser__skeleton-line--sub {
    width: 30%;
}

.coach-browser__skeleton-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.coach-browser__skeleton-card {
    height: 180px;
    border-radius: 16px;
    background: var(--bg-card);
    animation: cb-shimmer 1.2s ease-in-out infinite;
}

.coach-browser__skeleton-card--wide {
    grid-column: 1 / -1;
    height: 120px;
}

@keyframes cb-shimmer {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.7; }
}

/* Error state */
.coach-browser__error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── Mobile Back Button ── */
.coach-browser__back {
    display: none;
    position: fixed;
    top: 68px;
    left: 12px;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ── Responsive: Tablet ── */
@media (max-width: 1024px) {
    .coach-browser {
        grid-template-columns: 280px 1fr;
    }
}

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

    .coach-browser__sidebar {
        border-right: none;
    }

    .coach-browser__content {
        position: absolute;
        inset: 0;
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 60px 16px 24px;
    }

    .coach-browser.content-visible .coach-browser__content {
        transform: translateX(0);
    }

    .coach-browser.content-visible .coach-browser__back {
        display: flex;
    }

    .coach-browser__search-input {
        font-size: 16px; /* Prevents iOS zoom */
    }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .coach-browser__content {
        transition: none;
    }

    .coach-browser__content-inner {
        animation: none;
    }

    .coach-browser__skeleton-avatar,
    .coach-browser__skeleton-line,
    .coach-browser__skeleton-card {
        animation: none;
        opacity: 0.5;
    }

    @keyframes cb-fadeIn {
        from { opacity: 1; transform: none; }
        to   { opacity: 1; transform: none; }
    }
}
