/**
 * SelectionList Component Styles
 * 
 * LinkedIn-style FLAT LIST layout for selection modals.
 * Features:
 * - Full-width rows with subtle 1px dividers (no card borders)
 * - .sl-row: row container
 * - .sl-left: avatar area (circular, left)
 * - .sl-main: title/subtitle (center, flex-grow)
 * - .sl-right: trailing actions (right-aligned)
 * - Subtle hover/selected backgrounds
 * - Accessible keyboard navigation
 * 
 * Class naming: .sl-* to avoid conflicts with legacy styles.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   ROW STYLES - Flat list rows with subtle dividers
   ═══════════════════════════════════════════════════════════════════════════ */

.sl-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md, 12px);
    padding: 10px 12px 12px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
    
    /* FLAT LIST: No card borders, no border-radius, no margins */
    border: none;
    border-radius: 0;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    
    /* Divider on top of EVERY row (including first) */
    border-top: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
}

/* Hover state - subtle background tint */
.sl-row:hover:not(.sl-disabled) {
    background: var(--yrh-apple-row-hover-bg, rgba(0, 0, 0, 0.04));
}

/* Apple list system: modal lists use consistent insets/density */
.c-modal-scroll-body .sl-row {
    gap: var(--yrh-apple-row-gap, 12px);
    padding: var(--yrh-apple-row-padding-y, 11px) var(--yrh-apple-list-padding-x, 20px);
    border-top-color: var(--yrh-apple-separator-color, rgba(0, 0, 0, 0.14));
}

@media (hover: hover) and (pointer: fine) {
    .c-modal-scroll-body .sl-row:hover:not(.sl-disabled) {
        background: var(--yrh-apple-row-hover-bg, rgba(0, 0, 0, 0.04));
    }
}

.c-modal-scroll-body .sl-row:active:not(.sl-disabled) {
    background: var(--yrh-apple-row-active-bg, rgba(0, 0, 0, 0.10));
}

.c-modal-scroll-body .sl-left {
    width: var(--yrh-apple-avatar-size, 40px);
    height: var(--yrh-apple-avatar-size, 40px);
}

/* Selected state - soft highlight with left accent, full row coverage */
.sl-row.sl-selected {
    background: var(--color-brand-primary-10, rgba(102, 126, 234, 0.08));
    box-shadow: inset 3px 0 0 0 var(--color-primary, #667eea);
}

.sl-row.sl-selected:hover {
    background: var(--color-brand-primary-15, rgba(102, 126, 234, 0.12));
}

/* Focus state for keyboard navigation */
.sl-row:focus {
    outline: none;
}

.sl-row:focus-visible {
    outline: 2px solid var(--color-primary, #667eea);
    outline-offset: -2px;
    z-index: 1;
}

/* Disabled state */
.sl-row.sl-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Special items (All Timelines, No Timeline) */
.sl-row.sl-special {
    /* Slightly muted to distinguish from regular items */
    position: relative;
}

.sl-row.sl-special .sl-left {
    background: var(--color-text-tertiary, #999);
    font-size: 1em;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AVATAR / LEFT SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.sl-left {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1em;
    overflow: hidden;
}

.sl-left.has-image {
    background: var(--color-bg-secondary, #f5f5f5);
}

.sl-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN / INFO SECTION (Title & Subtitle)
   ═══════════════════════════════════════════════════════════════════════════ */

.sl-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sl-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-primary, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sl-subtitle {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--color-text-muted, #666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RIGHT / TRAILING SECTION (Actions/Icons)
   ═══════════════════════════════════════════════════════════════════════════ */

.sl-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Prevent trailing actions from triggering row click */
.sl-right button,
.sl-right a,
.sl-right .btn-small {
    position: relative;
    z-index: 2;
}


.sl-row .official-badge {
    display: inline-block;
    background: var(--color-primary, #667eea);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-right: 8px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .sl-row {
        padding: 8px 10px;
        gap: 10px;
    }

    .sl-left {
        width: 36px;
        height: 36px;
        font-size: 1em;
    }

    .sl-title {
        font-size: 0.875rem;
    }

    .sl-subtitle {
        font-size: 0.75rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIMELINE PICKER - Reset any inherited card styles
   ═══════════════════════════════════════════════════════════════════════════ */

/* Remove container padding/gap that creates visual spacing between rows */
.timeline-picker-list {
    padding: 0 0 12px;
    gap: 0;
}

.timeline-picker-list .sl-row {
    /* Ensure flat styling: no cards, no margins, no gaps */
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    background: transparent;
    
    /* Divider on top of every row */
    border-top: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
    padding-left: 16px;
    padding-right: 16px;
}

/* Bottom divider for last row in each list */
.timeline-picker-list .sl-row:last-child {
    border-bottom: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
}

.timeline-picker-list .sl-row:hover:not(.sl-disabled) {
    background: var(--yrh-apple-row-hover-bg, rgba(0, 0, 0, 0.04));
}

.timeline-picker-list .sl-row.sl-selected {
    background: var(--color-brand-primary-05, rgba(102, 126, 234, 0.05));
    box-shadow: inset 3px 0 0 0 var(--color-primary, #667eea);
}

.timeline-picker-list .sl-row.sl-selected:hover {
    background: var(--color-brand-primary-05, rgba(102, 126, 234, 0.05));
}


/* Bottom divider for last row */


/* Profile options menu positioning */
.sl-row .profile-options-container {
    position: relative;
}

.sl-row .profile-options-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    min-width: 140px;
    background: var(--color-bg-primary, white);
    border: 1px solid var(--color-border-light, #e5e5e5);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    display: none;
}

.sl-row .profile-options-menu.active,
.sl-row .profile-options-menu.show {
    display: block;
}

.sl-row .profile-options-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text-primary, #333);
}

.sl-row .profile-options-menu button:hover {
    background: var(--yrh-apple-row-hover-bg, rgba(0, 0, 0, 0.04));
}


/* ═══════════════════════════════════════════════════════════════════════════
   CANVAS CONTEXT SWITCHER (Profile Picker)
   Flat list styling for profile/friend selection
   ═══════════════════════════════════════════════════════════════════════════ */

.canvas-context-switcher-list .sl-row {
    /* Ensure flat styling: no cards, no margins, no gaps */
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    background: transparent;
    
    /* Divider above each row (avoid double-thick lines between rows) */
    border-top: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
}

/* Profile picker labels (Apple-like) */
.canvas-context-switcher-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted, #777);
    padding: 10px 12px 6px;
    border: none;
}

.canvas-context-switcher-helper {
    padding: 0 12px 8px;
}

/* Space after current profile row before legacy profiles label */
.canvas-context-switcher-section-you {
    margin-bottom: 10px;
    border-bottom: none;
    padding-bottom: 0;
}

/* Current profile row (“You”): top + bottom border (profile box) */
.canvas-context-switcher-section-you .sl-row {
    border-top: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
    border-bottom: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
}

/* Last profile row: add a bottom border to end the list cleanly */
.canvas-context-switcher-list .sl-row:last-of-type {
    border-bottom: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
}

/* Space between current profile and legacy profiles group */
.canvas-context-switcher-section + .canvas-context-switcher-section {
    margin-top: 10px;
}

.canvas-context-switcher-list .sl-row:hover:not(.sl-disabled) {
    background: var(--yrh-apple-row-hover-bg, rgba(0, 0, 0, 0.04));
}

.canvas-context-switcher-list .sl-row.sl-selected {
    background: var(--color-brand-primary-10, rgba(102, 126, 234, 0.08));
    box-shadow: inset 3px 0 0 0 var(--color-primary, #667eea);
}

/* ═══════════════════════════════════════════════════════════════════════════
   EVENT MANAGER TIMELINE PICKER
   Flat list styling for event library timeline filter
   ═══════════════════════════════════════════════════════════════════════════ */

#em-timeline-picker-list .sl-row {
    /* Ensure flat styling: no cards, no margins, no gaps */
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    background: transparent;
    
    /* Divider on top of every row */
    border-top: 1px solid var(--color-border-lighter, rgba(0, 0, 0, 0.08));
}

#em-timeline-picker-list .sl-row:hover:not(.sl-disabled) {
    background: var(--yrh-apple-row-hover-bg, rgba(0, 0, 0, 0.04));
}

#em-timeline-picker-list .sl-row.sl-selected {
    background: var(--color-brand-primary-05, rgba(102, 126, 234, 0.05));
    box-shadow: inset 3px 0 0 0 var(--color-primary, #667eea);
}

#em-timeline-picker-list .sl-row.sl-selected:hover {
    background: var(--color-brand-primary-05, rgba(102, 126, 234, 0.05));
}
