/**
 * Show Row Component Styles
 *
 * Scoped with .sr-* prefix to avoid conflicts.
 * Uses CSS custom properties from design-tokens.css.
 */

/* Section Container */
.sr-section {
    margin-bottom: 24px;
    max-width: 100%;
}

/* Remove margin from last section to avoid extra space above nav */
.sr-section:last-child,
.sr-section:last-of-type {
    margin-bottom: 0;
}

/* Section Header */
.sr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.sr-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.sr-link {
    font-size: 14px;
    color: var(--accent-primary);
    text-decoration: none;
}

.sr-link:hover {
    text-decoration: underline;
}

/* Segmented Control Tabs */
.sr-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 4px;
}

.sr-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sr-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sr-tab--selected {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sr-tab--selected:hover {
    background: var(--bg-secondary);
}

/* Loading state for tab content */
.sr-section.sr-loading .sr-scroll {
    opacity: 0.5;
    pointer-events: none;
}

@media (max-width: 768px) {
    .sr-tabs {
        padding: 3px;
    }

    .sr-tab {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* Scroll Container */
.sr-container {
    position: relative;
    max-width: 100%;
}

.sr-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-behavior: smooth;
    max-width: 100%;
    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sr-scroll::-webkit-scrollbar {
    display: none;
}

/* Fade edges to indicate more content */
.sr-container::before,
.sr-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 8px;
    width: 40px;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sr-container::before {
    left: 0;
    background: linear-gradient(to right, var(--bg-primary) 0%, transparent 100%);
}

.sr-container::after {
    right: 0;
    background: linear-gradient(to left, var(--bg-primary) 0%, transparent 100%);
}

.sr-container.sr-can-scroll-left::before {
    opacity: 1;
}

.sr-container.sr-can-scroll-right::after {
    opacity: 1;
}

/* Navigation Arrows */
.sr-arrow {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(calc(-50% - 4px));
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    z-index: 3;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    box-shadow: var(--shadow-md);
}

.sr-arrow:hover {
    background: var(--bg-hover);
}

.sr-arrow svg {
    width: 20px;
    height: 20px;
}

.sr-arrow-left {
    left: 8px;
}

.sr-arrow-right {
    right: 8px;
}

/* Show arrows on desktop when hovering the container */
@media (min-width: 769px) {
    .sr-arrow {
        display: flex;
    }

    .sr-container:hover .sr-arrow-left.sr-visible {
        opacity: 1;
    }

    .sr-container:hover .sr-arrow-right.sr-visible {
        opacity: 1;
    }
}

/* Show Card */
.sr-card {
    flex: 0 0 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.sr-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

/* Card Image */
.sr-card-image {
    width: 100%;
    height: 120px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    position: relative;
}

.sr-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
}

.sr-card-image .sr-venue-logo {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.sr-card-image > svg {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
}

/* Favorite Button */
.sr-favorite-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    z-index: 2;
}

.sr-card:hover .sr-favorite-btn,
.sr-favorite-btn.sr-favorited {
    opacity: 1;
}

.sr-favorite-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.sr-favorite-btn svg {
    width: 18px;
    height: 18px;
}

.sr-favorite-btn.sr-favorited {
    color: var(--color-error, #e74c3c);
    background: rgba(255, 255, 255, 0.9);
}

.sr-favorite-btn.sr-favorited:hover {
    background: rgba(255, 255, 255, 1);
}

@keyframes sr-favorite-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.sr-favorite-btn.sr-pulse {
    animation: sr-favorite-pulse 0.3s ease-in-out;
}

/* Card Content */
.sr-card-content {
    padding: 14px 14px 8px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Glass effect background - blurred image behind text */
.sr-card-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--card-bg-image);
    background-size: cover;
    background-position: center;
    opacity: 0.45;
    filter: blur(12px);
    transform: scale(1.1); /* Prevent blur edge artifacts */
    z-index: 0;
}

/* Gradient overlay for text readability */
.sr-card-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(30, 30, 30, 0.35) 0%,
        rgba(30, 30, 30, 0.5) 50%,
        rgba(30, 30, 30, 0.65) 100%
    );
    z-index: 1;
}

/* Ensure all content sits above glass effect */
.sr-card-top-row,
.sr-card-artists,
.sr-card-bottom-row,
.sr-card-attribution {
    position: relative;
    z-index: 2;
}

/* Subtle text shadow for readability on glass background */
.sr-card-when-where,
.sr-card-match,
.sr-card-artists,
.sr-card-genre,
.sr-card-attribution {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Top Row (genres left, match right) */
.sr-card-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

/* Match Score */
.sr-card-match {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-left: auto;
}

.sr-card-match.sr-good-match {
    color: var(--accent-primary);
}

/* Artists (main content) */
.sr-card-artists {
    font-size: 14px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
    line-height: 1.4;
}

/* Genre Tag */
.sr-card-genre {
    font-size: 10px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

/* When/Where (date · venue) */
.sr-card-when-where {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Clickable venue name */
.sr-venue-name {
    cursor: pointer;
    transition: color 0.15s ease;
}

.sr-venue-name:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

/* Bottom Row (genres + menu trigger) */
.sr-card-bottom-row {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Action Menu Trigger in Card */
.sr-card-bottom-row .am-wrapper {
    flex-shrink: 0;
    margin-left: auto;
    /* Push closer to card edge (compensate for content padding) */
    margin-right: -6px;
}

.sr-card-bottom-row .am-trigger {
    width: 28px;
    height: 28px;
    color: var(--text-tertiary);
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.sr-card:hover .sr-card-bottom-row .am-trigger {
    opacity: 1;
}

.sr-card-bottom-row .am-trigger:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sr-card-bottom-row .am-trigger i,
.sr-card-bottom-row .am-trigger svg {
    width: 18px;
    height: 18px;
}

/* Attribution ("Because you liked...") */
.sr-card-attribution {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-primary);
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading State */
.sr-card.sr-loading {
    pointer-events: none;
    opacity: 0.5;
}

.sr-card.sr-loading .sr-card-image {
    animation: sr-pulse 1.5s ease-in-out infinite;
}

@keyframes sr-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.3; }
}

/* Empty State */
.sr-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
}

.sr-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    color: var(--text-tertiary);
}

.sr-empty p {
    margin: 0;
}

/* Trending Badge */
.sr-trending-badge {
    display: inline;
    margin-right: 2px;
    font-size: 0.8em;
}

.sr-card-artists.sr-trending {
    /* Slightly emphasize trending artists */
}

/* Liked Artist Icons (heart for favorited, thumbs-up for rated) */
.sr-artist-icon {
    width: 12px;
    height: 12px;
    vertical-align: middle;
    margin-right: 2px;
    flex-shrink: 0;
    display: inline;
}

.sr-artist-icon--heart {
    color: var(--color-error, #e74c3c);
}

.sr-artist-icon--thumbsup {
    color: var(--accent-primary);
    width: 13px;
    height: 13px;
    position: relative;
    top: -1px;
}

.sr-liked-artist {
    white-space: nowrap;
}

/* ============================================
   AUDIO CONTROLS CONTAINER
   ============================================ */

/* Container for all audio controls (top-right, below heart) */
.sr-audio-controls {
    position: absolute;
    top: 44px;  /* Below heart (8px + 32px heart + 4px gap) */
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    z-index: 2;
    pointer-events: none;  /* Allow clicks to pass through empty space */
}

.sr-audio-controls > * {
    pointer-events: auto;  /* But buttons are clickable */
}

/* Row containing thumbs + play button */
.sr-audio-row {
    display: flex;
    align-items: center;
    /* No gap - thumbs animate from 0 width */
}

/* ============================================
   AUDIO PLAY BUTTON
   ============================================ */

.sr-audio-btn {
    position: relative;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    flex-shrink: 0;
}

.sr-card:hover .sr-audio-btn,
.sr-audio-btn[data-state="playing"],
.sr-audio-btn[data-state="playing-last"],
.sr-card--audio-expanded .sr-audio-btn {
    opacity: 1;
}

.sr-audio-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.sr-audio-btn:active {
    transform: scale(0.95);
}

/* Audio button icons */
.sr-audio-icon {
    width: 14px;
    height: 14px;
    position: absolute;
    transition: opacity 0.15s ease;
}

/* Icon visibility based on state */
.sr-audio-btn[data-state="idle"] .sr-audio-icon--play { opacity: 1; }
.sr-audio-btn[data-state="idle"] .sr-audio-icon--next { opacity: 0; }
.sr-audio-btn[data-state="idle"] .sr-audio-icon--pause { opacity: 0; }

.sr-audio-btn[data-state="playing"] .sr-audio-icon--play { opacity: 0; }
.sr-audio-btn[data-state="playing"] .sr-audio-icon--next { opacity: 1; }
.sr-audio-btn[data-state="playing"] .sr-audio-icon--pause { opacity: 0; }

.sr-audio-btn[data-state="playing-last"] .sr-audio-icon--play { opacity: 0; }
.sr-audio-btn[data-state="playing-last"] .sr-audio-icon--next { opacity: 0; }
.sr-audio-btn[data-state="playing-last"] .sr-audio-icon--pause { opacity: 1; }

/* Circular progress indicator */
.sr-audio-progress {
    position: absolute;
    width: 32px;
    height: 32px;
    pointer-events: none;
}

.sr-audio-progress-bg {
    opacity: 0.3;
}

.sr-audio-progress-bar {
    transition: stroke-dashoffset 0.1s linear;
}

/* Hide progress when idle */
.sr-audio-btn[data-state="idle"] .sr-audio-progress {
    opacity: 0;
}

.sr-audio-btn[data-state="playing"] .sr-audio-progress,
.sr-audio-btn[data-state="playing-last"] .sr-audio-progress {
    opacity: 1;
}

/* ============================================
   THUMBS UP/DOWN BUTTONS
   ============================================ */

.sr-audio-thumb {
    position: relative;
    width: 0;
    height: 32px;
    padding: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 0;
    margin-right: 0;
    transition: width 200ms ease-out, opacity 200ms ease-out, margin-right 200ms ease-out, background 0.15s ease, transform 0.15s ease;
}

.sr-audio-thumb svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Expanded state - show thumbs */
.sr-card--audio-expanded .sr-audio-thumb {
    width: 32px;
    margin-right: 4px;
    opacity: 1;
}

.sr-audio-thumb:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* Active states (matching artist_card) */
.sr-audio-thumb--up.sr-audio-thumb--active {
    background: rgba(34, 197, 94, 0.8);
    color: white;
}

.sr-audio-thumb--down.sr-audio-thumb--active {
    background: rgba(239, 68, 68, 0.8);
    color: white;
}

/* Hover on active states */
.sr-audio-thumb--up.sr-audio-thumb--active:hover {
    background: rgba(34, 197, 94, 1);
}

.sr-audio-thumb--down.sr-audio-thumb--active:hover {
    background: rgba(239, 68, 68, 1);
}

/* Hide thumbs for songs without song_id */
.sr-audio-thumb[style*="visibility: hidden"] {
    width: 0 !important;
    opacity: 0 !important;
    margin-left: 0 !important;
}

/* ============================================
   SONG TITLE
   ============================================ */

.sr-audio-song {
    /* Styling */
    font-size: 10px;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 3px 8px;
    border-radius: 10px;
    /*
     * Position: right-aligned, size to content
     * Don't use fit-content - it doesn't resolve correctly in this flex context
     */
    display: inline-flex;
    max-width: 250px;
    margin-left: auto;  /* Push to right */
    /* Truncate if too long */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Hidden by default */
    opacity: 0;
    transition: opacity 200ms ease-out 50ms;
}

/* Expanded state - show song title */
.sr-card--audio-expanded .sr-audio-song {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   ARTIST HIGHLIGHTING
   ============================================ */

/* Artist playing highlight - color only, no layout changes */
.sr-artist--playing {
    color: var(--color-success, #1DB954) !important;
}

/* Ensure icons inside playing artists also get the color */
.sr-artist--playing .sr-artist-icon {
    color: var(--color-success, #1DB954);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .sr-section {
        margin-bottom: 20px;
    }

    .sr-title {
        font-size: 18px;
    }

    .sr-card {
        flex: 0 0 240px;
    }

    .sr-card-image {
        height: 100px;
    }

    .sr-card-content {
        padding: 12px;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .sr-card-artists {
        font-size: 13px;
    }

    .sr-card-genre {
        font-size: 9px;
    }

    .sr-card-when-where {
        font-size: 10px;
    }

    .sr-card-match {
        font-size: 10px;
    }

    .sr-card-attribution {
        font-size: 10px;
    }

    /* Always show favorite button on mobile (no hover state) */
    .sr-favorite-btn {
        opacity: 0.6;
        background: rgba(0, 0, 0, 0.35);
    }

    .sr-favorite-btn.sr-favorited {
        opacity: 1;
    }

    /* Slightly larger touch target on mobile */
    .sr-favorite-btn:active {
        transform: scale(0.95);
        opacity: 1;
    }

    /* Always show menu trigger on mobile (no hover state) */
    .sr-card-bottom-row .am-trigger {
        opacity: 0.7;
    }

    .sr-card-bottom-row .am-trigger:active {
        opacity: 1;
        transform: scale(0.95);
    }

    /* Always show audio button on mobile (no hover state) */
    .sr-audio-btn {
        opacity: 0.7;
        background: rgba(0, 0, 0, 0.5);
    }

    .sr-audio-btn[data-state="playing"],
    .sr-audio-btn[data-state="playing-last"],
    .sr-card--audio-expanded .sr-audio-btn {
        opacity: 1;
    }

    .sr-audio-btn:active {
        opacity: 1;
        transform: scale(0.9);
    }

    /* Thumbs buttons on mobile */
    .sr-audio-thumb:active {
        transform: scale(0.9);
    }

    /* Song title on mobile - same behavior as desktop */
    .sr-audio-song {
        font-size: 9px;
    }
}

/* Skeleton Loading Cards - matches real .sr-card dimensions */
.sr-card--skeleton {
    flex: 0 0 280px;
    min-width: 280px;
    max-width: 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.sr-card--skeleton::before {
    content: '';
    display: block;
    height: 120px; /* Match .sr-card-image height */
    background: var(--bg-tertiary);
    animation: sr-skeleton-pulse 1.5s ease-in-out infinite;
}

.sr-card--skeleton::after {
    content: '';
    display: block;
    height: 100px; /* Match .sr-card-content approximate height */
    background: var(--bg-secondary);
}

@keyframes sr-skeleton-pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.3;
    }
}

/* Mobile skeleton adjustments */
@media (max-width: 640px) {
    .sr-card--skeleton {
        flex: 0 0 240px;
        min-width: 240px;
        max-width: 240px;
    }

    .sr-card--skeleton::before {
        height: 100px; /* Match mobile .sr-card-image height */
    }
}

/* Hide section if no recommendations after load attempt */
.sr-section--empty {
    display: none;
}
