/* =====================================================================
   CarStories – friends management
   Uses Bootstrap 5 CSS variables so it follows the Color Admin theme
   (light / dark) without own colour definitions.
   ===================================================================== */

:root {
    --friends-radius: .5rem;
    --friends-muted: var(--bs-secondary-color, #6c757d);
    --friends-border: var(--bs-border-color, #dee2e6);
    --friends-surface: var(--bs-body-bg, #fff);
    --friends-surface-alt: var(--bs-tertiary-bg, #f5f6f7);
    --friends-accent: var(--bs-primary, #348fe2);
    --friends-accent-rgb: var(--bs-primary-rgb, 52, 143, 226);
}

/* ---------------------------------------------------------------------
   Toolbar / view mode navigation
   --------------------------------------------------------------------- */
.friends-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
}

.friends-tabs {
    flex-wrap: nowrap;
    gap: .25rem;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
}

.friends-tabs::-webkit-scrollbar { display: none; }

.friends-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    white-space: nowrap;
    color: var(--bs-body-color);
    background: var(--friends-surface);
    border: 1px solid var(--friends-border);
}

    .friends-tabs .nav-link.active {
        color: #fff;
        background: var(--car-stories-lightgreen);
        border-color: var(--car-stories-darkgreen);
    }

.friends-tabs .badge { font-size: .7rem; }

.friends-toolbar__invite { margin-left: auto; white-space: nowrap; }

@media (max-width: 575.98px) {
    .friends-toolbar__invite { width: 100%; margin-left: 0; }
}

/* ---------------------------------------------------------------------
   Search
   --------------------------------------------------------------------- */
.friends-search { position: relative; }

.friends-search > .fa {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--friends-muted);
    pointer-events: none;
}

.friends-search .form-control { padding-left: 2.3rem; }

/* ---------------------------------------------------------------------
   List: DataTables only acts as pager, remove all table chrome
   --------------------------------------------------------------------- */
.friends-list { border-collapse: separate; border-spacing: 0; }

.friends-list > tbody > tr > td,
.friends-list > tbody > tr > td.friends-list__cell {
    padding: 0 0 .5rem 0;
    border: 0;
    background: transparent !important;
    box-shadow: none !important;
}

.friends-list > tbody > tr:last-child > td { padding-bottom: 0; }

.friends-list__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding-top: .75rem;
    font-size: .8rem;
    color: var(--friends-muted);
}

.friends-list__footer .pagination { margin: 0; }
.friends-list__footer .dataTables_info,
.friends-list__footer .dt-info { padding: 0 !important; }

#friends-list-wrapper { position: relative; min-height: 4rem; }

/* ---------------------------------------------------------------------
   Person card
   --------------------------------------------------------------------- */
.friend-card {
    container-type: inline-size;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    border: 1px solid var(--friends-border);
    border-radius: var(--friends-radius);
    background: var(--friends-surface);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.friend-card:hover { border-color: rgba(var(--car-stories-ochre), .6); }

.friend-card.is-active {
    border-color: var(--car-stories-ochre);
    background: rgba(var(--car-stories-ochre), .06);
    box-shadow: inset 3px 0 0 var(--car-stories-ochre);
}

.friend-card__avatar {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--friends-surface-alt);
}

.friend-card__body { flex: 1 1 auto; min-width: 0; }

.friend-card__title {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}

.friend-card__name {
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-card__name:focus-visible {
    outline: 2px solid var(--friends-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.friend-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem .75rem;
    margin-top: .15rem;
    font-size: .75rem;
    color: var(--friends-muted);
}

.friend-card__meta > span {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    min-width: 0;
    max-width: 100%;
}

.friend-status {
    flex-shrink: 0;
    font-size: .65rem;
    font-weight: 600;
}

/* ---------------------------------------------------------------------
   Actions (list + detail)
   --------------------------------------------------------------------- */
.friend-actions {
    display: flex;
    flex-shrink: 0;
    gap: .375rem;
}

/* Guard against legacy PersonLine styles (CssHelper.PersonLine) hiding the buttons */
.friend-card > .friend-actions {
    display: flex !important;
    visibility: visible !important;
    margin-left: auto;
}

.friend-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    white-space: nowrap;
}

/* Narrow cards: icon only (title / aria-label stay available) */
@container (max-width: 440px) {
    .friend-card .friend-action__label { display: none; }
}

/* ---------------------------------------------------------------------
   Detail panel / offcanvas
   --------------------------------------------------------------------- */
.friends-detail-panel {
    position: sticky;
    top: calc(var(--app-header-height, 50px) + 1rem);
}

.friends-detail-panel > .panel-body {
    max-height: calc(100vh - var(--app-header-height, 50px) - 6rem);
    overflow-y: auto;
}

.friends-offcanvas { --bs-offcanvas-width: min(100vw, 520px); }

.friends-placeholder,
.friends-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--friends-muted);
}

.friends-placeholder > .fa,
.friends-empty .fa {
    display: block;
    margin-bottom: .75rem;
    font-size: 2.25rem;
    opacity: .4;
}

.friends-empty p { max-width: 32ch; margin: 0 auto 1rem; }

/* ---------------------------------------------------------------------
   Profile (detail content)
   --------------------------------------------------------------------- */
.friend-profile__cover {
    height: 140px;
    background-color: var(--friends-surface-alt);
    background-position: center;
    background-size: cover;
}

.friend-profile__head {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1rem;
    margin-top: -48px;
    padding: 0 1.25rem;
}

.friend-profile__avatar {
    width: 96px;
    height: 96px;
    border: 4px solid var(--friends-surface);
    border-radius: 50%;
    object-fit: cover;
    background: var(--friends-surface-alt);
}

.friend-profile__identity {
    flex: 1 1 180px;
    min-width: 0;
    padding-bottom: .25rem;
}

.friend-profile__name {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.friend-profile__sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-top: .2rem;
    font-size: .8rem;
    color: var(--friends-muted);
}

.friend-profile__head .friend-actions { padding-bottom: .35rem; }

.friend-profile__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    margin: 0;
    padding: 1rem 1.25rem;
}

.friend-profile__stats > div { min-width: 0; }
.friend-profile__stat-wide { flex: 1 1 160px; }

.friend-profile__stats dt {
    font-size: .75rem;
    font-weight: 400;
    color: var(--friends-muted);
}

.friend-profile__stats dd {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.friend-profile__tabs { padding: 0 1.25rem; }
.friend-profile__pane { padding: 1.25rem; }

/* Vehicles */
.friend-vehicles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
}

.friend-vehicle {
    display: block;
    overflow: hidden;
    border: 1px solid var(--friends-border);
    border-radius: var(--friends-radius);
    background: var(--friends-surface);
    color: inherit;
    text-decoration: none;
    transition: border-color .15s ease;
}

.friend-vehicle:hover,
.friend-vehicle:focus-visible {
    border-color: var(--friends-accent);
    color: inherit;
}

.friend-vehicle__img {
    aspect-ratio: 4 / 3;
    background-color: var(--friends-surface-alt);
    background-position: center;
    background-size: cover;
}

.friend-vehicle__body { padding: .5rem .75rem .65rem; }

.friend-vehicle__name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-vehicle__sub {
    font-size: .75rem;
    color: var(--friends-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Garage */
.friend-garage__facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .5rem 1.25rem;
    margin-bottom: 1.25rem;
}

.friend-garage__facts dt { font-weight: 400; color: var(--friends-muted); }
.friend-garage__facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.friend-garage__group + .friend-garage__group { margin-top: 1rem; }

.friend-garage__label {
    margin-bottom: .35rem;
    font-size: .75rem;
    color: var(--friends-muted);
}

.friend-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.friend-garage__description { max-width: 75ch; }

@media (max-width: 400px) {
    .friend-garage__facts { grid-template-columns: 1fr; gap: .1rem; }
    .friend-garage__facts dd { margin-bottom: .5rem; }
}

/* Likes dialog on story pages */
.friends-like-list {
    display: grid;
    gap: .5rem;
}

@media (prefers-reduced-motion: reduce) {
    .friend-card,
    .friend-vehicle { transition: none; }
}
