/* ============================================================
   MUSICSTREAMER TEMA
   ============================================================ */

:root {
    --bg:               #111118;
    --surface:          #18181f;
    --surface-elevated: #24242e;
    --surface-hover:    #2c2c38;
    --accent:           #8b5cf6;
    --accent-hover:     #a78bfa;
    --text:             #ffffff;
    --text-muted:       #b3b3b3;
    --text-subdued:     #535353;
    --player-bg:        #18181f;
    --sidebar-width:    240px;
    --topbar-height:    64px;
    --player-height:    90px;
}

/* --- RESET & BODY --- */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    --player-offset: 0px;
}
body.has-player {
    padding-bottom: var(--player-height);
    --player-offset: var(--player-height);
}

audio { display: none; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: calc(100vh - var(--player-offset));
    background: #0c0c12;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    padding-bottom: 24px;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
    padding: 24px 24px 16px;
    flex-shrink: 0;
}
.sidebar-logo img {
    height: 38px;
    width: auto;
    display: block;
}

.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    flex-shrink: 0;
}
.sidebar-nav li { display: block; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: color 0.1s;
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.sidebar-link i {
    font-size: 1.4rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}
.sidebar-link:hover { color: var(--text); text-decoration: none; }
.sidebar-link.active {
    color: var(--text);
    border-left-color: var(--accent);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.07);
    margin: 8px 24px;
    flex-shrink: 0;
}
.sidebar-section-label {
    padding: 16px 24px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-subdued);
}

/* ============================================================
   MAIN WRAPPER + TOPBAR + APP-CONTENT
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--player-offset));
    overflow: hidden;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(to bottom,
        rgba(18, 18, 18, 1)   0%,
        rgba(18, 18, 18, 0.95) 85%,
        rgba(18, 18, 18, 0)    100%);
    flex-shrink: 0;
}

.topbar-nav {
    display: flex;
    gap: 8px;
}
.topbar-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.15s;
}
.topbar-nav-btn:hover { opacity: 0.75; }
.topbar-nav-btn:disabled { opacity: 0.35; cursor: default; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    flex-shrink: 0;
}
.topbar-username {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.topbar-username:hover { text-decoration: underline; color: var(--text); }
.topbar-search { flex-shrink: 0; }
@media (max-width: 768px) { .topbar-search { display: none; } }

#app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 32px 48px;
}

/* ============================================================
   MOBILE NAV (bottom, < 768px)
   ============================================================ */
.mobile-nav {
    display: none;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 18, 18, 0.88);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text);
}

/* ============================================================
   KORT (SPOTIFY-STIL — INGA GLASSMORPHISM)
   ============================================================ */
.card {
    background-color: var(--surface) !important;
    border: none !important;
    border-radius: 8px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    color: var(--text) !important;
    transition: background-color 0.3s ease;
}
.card:hover { background-color: var(--surface-elevated) !important; }

/* ============================================================
   ALBUMKORT
   ============================================================ */
.album-card {
    background: var(--surface) !important;
    border: none !important;
    border-radius: 8px !important;
    overflow: hidden;
    transition: background-color 0.25s ease;
    cursor: pointer;
    position: relative;
}
.album-card:hover {
    background: var(--surface-elevated) !important;
}
/* Ingen transform/lift på hover — Spotify-beteende */

.album-card-cover {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--surface-elevated);
    border-radius: 6px 6px 0 0;
}
.album-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: none;
}

.album-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.25s;
}
.album-card:hover .album-card-overlay {
    background: rgba(0, 0, 0, 0.4);
}

/* Spotify-stil: play-knapp i nedre högra hörnet, animerar uppåt */
.btn-play-overlay {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.1s;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    position: absolute;
    bottom: 8px;
    right: 8px;
    text-decoration: none;
    cursor: pointer;
}
.album-card:hover .btn-play-overlay {
    opacity: 1;
    transform: translateY(0);
}
.btn-play-overlay:hover {
    background: var(--accent-hover) !important;
    transform: scale(1.06) translateY(0) !important;
    color: #fff !important;
    text-decoration: none;
}

.album-card-badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ============================================================
   GENRE-BADGES
   ============================================================ */
.badge-genre {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border: none;
    font-size: 0.62rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: inline-block;
}

/* ============================================================
   GENRE-FILTER PILLS
   ============================================================ */
.genre-pill {
    background: var(--surface-elevated);
    border: none;
    color: var(--text);
    border-radius: 4px;
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s;
    text-decoration: none;
    white-space: nowrap;
    display: inline-block;
}
.genre-pill:hover {
    background: #3e3e3e;
    color: var(--text);
    text-decoration: none;
}
.genre-pill.active {
    background: var(--text);
    color: #000;
}

/* ============================================================
   KNAPPAR
   ============================================================ */
.btn-primary {
    background: var(--text) !important;
    color: #000 !important;
    border: none !important;
    font-weight: 700 !important;
    border-radius: 500px !important;
}
.btn-primary:hover {
    background: #e0e0e0 !important;
    transform: none;
    filter: none;
    color: #000 !important;
}

.btn-success {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
    font-weight: 700;
    border-radius: 500px !important;
}
.btn-success:hover {
    background-color: var(--accent-hover) !important;
    border-color: var(--accent-hover) !important;
    color: #fff !important;
    filter: none;
    box-shadow: none;
}

.btn-outline-success {
    color: var(--text) !important;
    border-color: var(--text-subdued) !important;
    border-radius: 500px !important;
    font-weight: 700;
    background: transparent !important;
}
.btn-outline-success:hover {
    background: transparent !important;
    border-color: var(--text) !important;
    color: var(--text) !important;
}

.btn-outline-danger {
    border-radius: 500px !important;
    font-weight: 700;
}
.btn-outline-secondary {
    border-radius: 500px !important;
}
.btn-outline-light {
    border-radius: 500px !important;
    font-weight: 700;
}

/* ============================================================
   FORMULÄR
   ============================================================ */
.form-control, .form-select {
    background-color: var(--surface-elevated) !important;
    border: 1px solid rgba(255,255,255,0.18) !important;
    color: var(--text) !important;
    border-radius: 4px !important;
}
.form-control:focus, .form-select:focus {
    background-color: var(--surface-elevated) !important;
    border: 1px solid rgba(255,255,255,0.55) !important;
    box-shadow: none !important;
    outline: none;
    color: var(--text) !important;
}
.form-control::placeholder { color: var(--text-subdued) !important; opacity: 1; }
select.form-select option { background: var(--surface-elevated); color: var(--text); }

/* ============================================================
   TABELLER
   ============================================================ */
.table { color: var(--text) !important; }
.table-dark { --bs-table-bg: transparent; --bs-table-border-color: transparent; }
.table-hover {
    --bs-table-hover-bg: rgba(255,255,255,0.05);
    --bs-table-hover-color: var(--text);
}
.table-hover tbody tr:hover td { background-color: rgba(255,255,255,0.05) !important; color: var(--text) !important; }
tr.track-row:hover { background: rgba(255, 255, 255, 0.04) !important; }
tr.track-playing { background: rgba(29, 185, 84, 0.07) !important; }
tr.track-playing td { color: var(--accent) !important; }
.track-row { cursor: default; }

/* ============================================================
   GILLA-KNAPP
   ============================================================ */
.btn-like {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    transition: color 0.15s, transform 0.1s;
    line-height: 1;
}
.btn-like:hover { color: var(--accent); transform: scale(1.1); }
.btn-like.liked, .btn-like.liked i { color: var(--accent); }

/* ============================================================
   SPÅRRÄKNARE
   ============================================================ */
.play-count-text {
    color: var(--text-subdued);
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* ============================================================
   LANDNINGSSIDA HERO
   ============================================================ */
.landing-hero {
    margin: 0 -32px;
    position: relative;
    overflow: hidden;
    min-height: 420px;
    display: flex;
    align-items: center;
    background-size: cover;
    background-position: center 30%;
}
.landing-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to right,
        rgba(0,0,0,0.88) 0%,
        rgba(0,0,0,0.65) 55%,
        rgba(0,0,0,0.2) 100%);
}
.landing-hero-content {
    position: relative;
    z-index: 1;
    padding: 64px 48px;
    max-width: 580px;
}
.landing-stats {
    margin: 0 -32px;
    padding: 28px 48px;
    background: var(--surface);
    display: flex;
    gap: 48px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .landing-hero { margin: 0 -16px; min-height: 320px; }
    .landing-hero-content { padding: 40px 24px; }
    .landing-stats { margin: 0 -16px; padding: 20px 24px; gap: 28px; }
}

/* ============================================================
   ALBUM HERO (DETAILS-SIDAN)
   ============================================================ */
.album-hero {
    position: relative;
    overflow: hidden;
    border-radius: 1.5rem;
    padding: 2.5rem 3rem;
    margin-bottom: 2.5rem;
}
.album-hero-bg {
    position: absolute;
    inset: -20px;
    background-size: cover;
    background-position: center;
    filter: blur(50px) brightness(0.25) saturate(1.8);
    z-index: 0;
}
.album-hero > .row { position: relative; z-index: 1; }

/* ============================================================
   GLOBAL MUSIKSPELARE
   ============================================================ */
.global-player-bar {
    background: var(--player-bg) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-top: 1px solid var(--surface-elevated) !important;
    z-index: 1050;
}

.player-range, .volume-range {
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    transition: height 0.1s;
}
.player-range::-webkit-slider-thumb, .volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}
.player-range:hover, .volume-range:hover { height: 6px; }
.player-range:hover::-webkit-slider-thumb,
.volume-range:hover::-webkit-slider-thumb { background: var(--accent); }

#play-pause-btn {
    transition: transform 0.15s, background-color 0.15s;
}
#play-pause-btn:hover {
    transform: scale(1.06);
    background-color: #f0f0f0 !important;
}

#global-track-cover {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    display: none;
}

/* ============================================================
   QUEUE PANEL
   ============================================================ */
#queue-panel {
    position: fixed;
    bottom: var(--player-height);
    right: 16px;
    width: 320px;
    max-height: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(calc(100% + var(--player-height)));
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1045;
}
#queue-panel.open { transform: translateY(0); }
.queue-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.queue-panel-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}
.queue-list { overflow-y: auto; flex: 1; }
.queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}
.queue-item:hover { background: rgba(255,255,255,0.04); }
.queue-item.active { background: rgba(139,92,246,0.1); }
.queue-item.dragging { opacity: 0.35; }
.queue-item.drag-over { border-top: 2px solid var(--accent); }
.queue-drag-handle {
    color: var(--text-subdued);
    font-size: 0.75rem;
    cursor: grab;
    flex-shrink: 0;
    padding: 0 2px;
}
.queue-item-num {
    font-size: 0.65rem;
    color: var(--text-subdued);
    min-width: 16px;
    text-align: right;
    flex-shrink: 0;
}
.queue-item-cover {
    width: 30px; height: 30px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface-elevated);
    display: flex; align-items: center; justify-content: center;
}
.queue-item-info { flex: 1; min-width: 0; }
.queue-item-title {
    font-size: 0.78rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-item-artist {
    font-size: 0.68rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-item.active .queue-item-title { color: var(--accent); }
.queue-item-remove {
    background: transparent; border: none;
    color: var(--text-subdued); padding: 2px 5px;
    cursor: pointer; font-size: 0.72rem; border-radius: 4px;
    flex-shrink: 0; opacity: 0; transition: opacity 0.12s, color 0.12s;
}
.queue-item:hover .queue-item-remove { opacity: 1; }
.queue-item-remove:hover { color: #f1707a; }
.queue-empty {
    padding: 24px; text-align: center;
    color: var(--text-subdued); font-size: 0.8rem;
}
/* Sleep timer section inside queue panel */
.queue-sleep-section {
    border-top: 1px solid var(--border);
    padding: 10px 14px;
    flex-shrink: 0;
}
.queue-sleep-opts {
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px;
}
.sleep-opt {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 3px 10px;
    font-size: 0.72rem; border-radius: 20px;
    cursor: pointer; transition: background 0.15s, color 0.15s;
}
.sleep-opt:hover { background: rgba(139,92,246,0.15); color: var(--accent); }
.sleep-opt.active { background: rgba(139,92,246,0.2); color: var(--accent); border-color: var(--accent); }
#sleep-countdown {
    font-size: 0.68rem; color: var(--accent);
    display: none; margin-left: 6px; font-variant-numeric: tabular-nums;
}
@@media (max-width: 768px) {
    #queue-panel { right: 0; left: 0; width: 100%; border-radius: 12px 12px 0 0; max-height: 50vh; }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-content {
    background: var(--surface-elevated) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px !important;
}
.modal-backdrop { background: rgba(0, 0, 0, 0.7); }

/* ============================================================
   CARD IMG TOP
   ============================================================ */
.card-img-top {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* ============================================================
   GRANSKNINGSLOGG BADGES
   ============================================================ */
.badge-audit {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-audit-success { background: rgba(139,92,246,0.15); color: var(--accent); border: 1px solid rgba(139,92,246,0.3); }
.badge-audit-danger  { background: rgba(220,53,69,0.15);  color: #ff6b7a; border: 1px solid rgba(220,53,69,0.3); }
.badge-audit-warning { background: rgba(255,193,7,0.15);  color: #ffc107; border: 1px solid rgba(255,193,7,0.3); }
.badge-audit-info    { background: rgba(255,255,255,0.07); color: var(--text-muted); border: 1px solid rgba(255,255,255,0.12); }

/* ============================================================
   PAGINERING
   ============================================================ */
.pagination .page-link {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}
.pagination .page-item.active .page-link {
    background: var(--text);
    border-color: var(--text);
    color: #000;
}
.pagination .page-link:hover {
    background: var(--surface-elevated);
    color: var(--text);
}
.pagination .page-item.disabled .page-link { opacity: 0.3; }

/* ============================================================
   HJÄLPKLASSER
   ============================================================ */
.extra-small { font-size: 0.72rem; }
.rounded-4 { border-radius: 1rem !important; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.45); }

/* ============================================================
   PROGRESS BAR (FILUPPLADDNING)
   ============================================================ */
.progress { background: var(--surface-elevated); border-radius: 4px; }
.progress-bar { background: var(--accent); transition: width 0.3s ease; }

/* ============================================================
   MOBIL (< 768px)
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { display: none; }

    .main-wrapper {
        margin-left: 0;
        height: calc(100vh - var(--player-offset) - 56px);
    }

    #app-content { padding: 0 16px 32px; }

    .topbar { padding: 0 16px; }

    body { padding-bottom: 56px; }
    body.has-player { padding-bottom: calc(var(--player-height) + 56px); }

    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: var(--player-offset);
        left: 0;
        right: 0;
        height: 56px;
        background: #0c0c12;
        border-top: 1px solid var(--surface-elevated);
        z-index: 90;
        justify-content: space-around;
        align-items: center;
    }
    .mobile-nav .sidebar-link {
        padding: 8px;
        flex-direction: column;
        gap: 2px;
        font-size: 0.6rem;
        border-left: none;
        border-top: 2px solid transparent;
    }
    .mobile-nav .sidebar-link.active { border-top-color: var(--accent); }
    .mobile-nav .sidebar-link i { font-size: 1.3rem; width: auto; }

    .album-hero { padding: 1.5rem; border-radius: 1rem; }
    .album-hero-bg { filter: blur(30px) brightness(0.2) saturate(1.5); }
    .genre-pills-wrapper { overflow-x: auto; flex-wrap: nowrap !important; padding-bottom: 4px; }
    .global-player-bar .col-md-3:last-child { display: none !important; }
}
