/* Preact Library View — scoped styles (lv- prefix) */

/* ---- Mount point ---- */
#library-view-root {
    height: 100%;
}

/* ---- Root ---- */
.lv-root {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--ctrl-bg, #0a0a0a);
    color: var(--ctrl-text, #e5e5e5);
}

.lv-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--ctrl-text-muted, #8a8a8a);
    font-size: 0.85rem;
}

/* ---- Header ---- */
.lv-header {
    display: flex;
    align-items: center;
    padding: 14px 16px 10px;
    gap: 10px;
    flex-shrink: 0;
}

.lv-header-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    flex: 1;
    min-width: 0;
}

.lv-header-btn {
    background: none;
    border: none;
    color: var(--ctrl-text-muted, #8a8a8a);
    font-size: 1.1rem;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
}

.lv-header-btn:active {
    background: var(--ctrl-border, #2a2a2a);
}

.lv-search-input {
    flex: 1;
    background: var(--ctrl-surface, #141414);
    border: 1px solid var(--ctrl-border, #2a2a2a);
    border-radius: 10px;
    color: var(--ctrl-text, #e5e5e5);
    font-size: 0.88rem;
    padding: 8px 12px;
    outline: none;
    font-family: 'Inter', sans-serif;
}

.lv-search-input::placeholder {
    color: var(--ctrl-text-dim, #555);
}

.lv-search-input:focus {
    border-color: var(--ctrl-accent, #4a9eff);
}

/* ---- Filter Chips ---- */
.lv-chips {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.lv-chips::-webkit-scrollbar {
    display: none;
}

.lv-chip {
    background: transparent;
    border: 1px solid var(--ctrl-border, #2a2a2a);
    border-radius: 16px;
    color: var(--ctrl-text-muted, #8a8a8a);
    font-size: 0.78rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 6px 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.lv-chip.active {
    background: var(--ctrl-accent, #4a9eff);
    border-color: var(--ctrl-accent, #4a9eff);
    color: #fff;
}

/* ---- Scrollable Content ---- */
.lv-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 100px;
    -webkit-overflow-scrolling: touch;
}

/* ---- Section Header ---- */
.lv-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 10px;
}

.lv-section-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ctrl-text-muted, #8a8a8a);
}

.lv-section-action {
    background: none;
    border: 1px solid var(--ctrl-border, #2a2a2a);
    border-radius: 8px;
    color: var(--ctrl-accent, #4a9eff);
    font-size: 0.72rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.lv-section-action:active {
    background: var(--ctrl-border, #2a2a2a);
}

/* ---- Playlist Grid ---- */
.lv-playlist-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-bottom: 8px;
}

.lv-playlist-card {
    border-radius: 12px;
    padding: 14px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
}

.lv-playlist-card:active {
    transform: scale(0.97);
}

.lv-playlist-card-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.25);
}

.lv-playlist-card-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lv-playlist-card-count {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 4px;
}

/* ---- Category Filter ---- */
.lv-cat-chips {
    display: flex;
    gap: 6px;
    padding-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.lv-cat-chips::-webkit-scrollbar {
    display: none;
}

.lv-cat-chip {
    background: transparent;
    border: 1px solid var(--ctrl-border, #2a2a2a);
    border-radius: 12px;
    color: var(--ctrl-text-muted, #8a8a8a);
    font-size: 0.72rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 4px 10px;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.lv-cat-chip.active {
    background: var(--ctrl-surface, #141414);
    border-color: var(--ctrl-text-dim, #555);
    color: var(--ctrl-text, #e5e5e5);
}

.lv-cat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ---- Song Row ---- */
.lv-song-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--ctrl-border, #2a2a2a);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.lv-song-row:last-child {
    border-bottom: none;
}

.lv-song-row:active {
    background: var(--ctrl-surface, #141414);
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
}

.lv-song-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lv-song-info {
    flex: 1;
    min-width: 0;
}

.lv-song-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lv-song-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    color: var(--ctrl-text-muted, #8a8a8a);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lv-audio-badge {
    color: var(--ctrl-accent, #4a9eff);
    font-size: 0.75rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.lv-public-badge {
    color: var(--ctrl-text-dim, #555);
    font-size: 0.65rem;
    flex-shrink: 0;
}

/* ---- Empty States ---- */
.lv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--ctrl-text-muted, #8a8a8a);
}

.lv-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.3;
}

.lv-empty-text {
    font-size: 0.85rem;
    line-height: 1.5;
}

.lv-empty-btn {
    margin-top: 16px;
    background: var(--ctrl-accent, #4a9eff);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
}

/* ---- Image grid ---- */
.lv-image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.lv-image-card {
    position: relative;
    aspect-ratio: 1 / 1;
    border: none;
    padding: 0;
    background: var(--ctrl-surface, #141414);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.1s;
}

.lv-image-card:active {
    transform: scale(0.97);
}

.lv-image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lv-image-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.65rem;
}

/* ---- Image viewer overlay ---- */
.lv-image-viewer {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
}

.lv-image-viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px calc(8px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
}

.lv-image-viewer-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.95rem;
}

.lv-image-viewer-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.lv-image-viewer-name {
    flex: 1;
    color: #ddd;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lv-image-viewer-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}

.lv-image-viewer-stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

/* ---- Responsive ---- */
@media (min-width: 600px) {
    .lv-playlist-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .lv-image-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
