/* Tilretninger B.Dalgaard 2026 */
html, body {
    height: 100%;
    background-color: var(--bs-body-bg);
}
h5,h4,h3,h2,h1 {
    color: var(--bs-primary);
}
.container {
    display: block;
    overflow: visible;
    padding-left: 15px;  /* Tilføjer luft på mobil */
    padding-right: 15px; /* Tilføjer luft på mobil */
    margin: 0 auto;
}
#controls {
    position: sticky;
    top: 55px;
    z-index: 102;
    padding: 10px 15px;
    display: flex;
    background-color: #eee;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin-top: 10px;
}

#controls > div {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

#controls .left {
    justify-content: flex-start;
}

#controls .center {
    justify-content: center;
    gap: 8px;
}

#controls .right {
    justify-content: flex-end;
}

#controls .input-container {
    display: flex;
    align-items: center;
}

#listen, #indhold {
    padding-top: calc(55px + 10px);
}

#søgeFelt { 
    width: 50%; 
    max-width: 200px;
    border: 1px solid #ccc; 
    border-radius: 6px; 
    padding: 6px 10px; 
    font-size: 1rem; 
}

.icon-btn {
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--bs-primary);
}

.icon-btn.active {
    color: red;
}

/* Loader */
#spinner {
    display: none;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -20px;
    margin-left: -20px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
#topBtn { 
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    padding: 10px 15px;
    background-color: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    z-index: 1030;
}
#topBtn:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.85);
}

/* Wrapper for inputfelter */
.input-container {
    position: relative;       /* absolut-positionering refererer til container */
    display: inline-block;    /* container tilpasser sig inputfeltets bredde */
}

/* Inputfeltet */
.clearable {
    width: 200px;             /* fast bredde, kan ændres */
    height: 30px;
    font-size: 16px;
    box-sizing: border-box;
    padding-right: 25px;      /* plads til clear-knap */
}

/* Clear-knap */
.clear-btn {
    position: absolute;
    top: 50%;
    right: 5px;               /* sidder inde i inputfeltet */
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    color: #888;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Vis clear-knap ved hover eller når feltet har tekst */
.input-container.show-clear:hover .clear-btn,
.input-container.show-clear .clear-btn {
    opacity: 1;
}


.navbar {
    padding-top: 0.1rem !important;
    padding-bottom: 0.1rem !important;
}

.navbar-brand img {
    height: 40px;
    width: auto;
}
    /* Musiklisten - Grid layout med mobil-sikring */
    #musiklisten { 
        display: grid; 
        /* Prøv 320px, men vær aldrig bredere end 100% af skærmen */
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); 
        gap: 15px; 
        padding: 20px 15px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Styling af sang-kort (music-item) */
    .music-item { 
        display: flex; 
        align-items: center; 
        padding: 12px; 
        background: rgba(128,128,128,0.05); 
        border: 1px solid rgba(128,128,128,0.1); 
        border-radius: 10px; 
        cursor: pointer; 
        transition: 0.2s;
        user-select: none;
        width: 100%;           /* Vigtigt: Hold kortet inde i griddet */
        box-sizing: border-box;
        min-width: 0;          /* Tillader flex-krympning */
    }
    
    .music-item:hover { 
        background: rgba(128,128,128,0.1); 
        transform: translateY(-2px);
    }
    
    .music-item.active { 
        background: var(--bs-primary) !important; 
        color: white !important; 
    }

    /* Tekst-området i hvert kort */
    .music-info { 
        flex-grow: 1; 
        margin-left: 10px; 
        overflow: hidden; 
        min-width: 0; /* Gør det muligt for teksten at bruge ellipsis (...) */
    }

    .music-title { 
        font-weight: bold; 
        white-space: nowrap; 
        overflow: hidden; 
        text-overflow: ellipsis; 
        display: block;
    }

    .music-sub { 
        font-size: 0.85em; 
        opacity: 0.8; 
        white-space: nowrap; 
        overflow: hidden; 
        text-overflow: ellipsis; 
        display: block;
    }

    /* Varighed (tiden) */
    .music-duration {
        font-family: monospace;
        font-size: 0.85em;
        margin-left: 10px;
        flex-shrink: 0; /* Sørg for at tiden ikke bliver klemt */
    }
    /* Responsiv tilretning til mobil */
    @media (max-width: 768px) {
       
        #musiklisten { 
            grid-template-columns: 1fr; /* Tvinger én kolonne på små skærme */
            padding: 10px;
            gap: 10px;
        }

        .music-item {
            padding: 10px;
        }
    }
/* Container til tid og ID */
.music-duration-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    margin-left: 10px;
    flex-shrink: 0;
    min-width: 50px;
}

.music-duration {
    font-family: monospace;
    font-size: 0.9em;
    line-height: 1;
}

.music-id {
    font-family: monospace;
    opacity: 0.6;
    margin-top: 2px;
}
.player-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    margin: 0 10px;
}

#nu-spiller {
    font-size: .70rem;
    line-height: 1;
    margin-bottom: 2px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

#musikafspiller {
    width: 220px;
    height: 30px;
}


/* Mobil */
@media (max-width: 991.98px) {

    .player-wrapper {
        margin: 0 5px;
    }

    #musikafspiller {
        width: 120px;
        height: 24px;
    }

    #nu-spiller {
        max-width: 120px;
        font-size: .65rem;
    }
}

.forside-wrapper {
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.forside-wrapper picture,
.forside-wrapper .forside {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#messageBox {
    position: fixed;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    width: auto;
    max-width: 800px;
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    pointer-events: none;
}

#messageBox.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* --- MENU & DROPDOWN SYSTEM (PC) --- */
@media (min-width: 769px) {
    .dropdown-menu:not(:has(.dropdown-submenu)) {
        max-height: 80vh !important;
        overflow-y: auto !important;
    }
    .dropdown-menu:has(.dropdown-submenu) {
        overflow: visible !important;
    }
    .dropdown-submenu:hover > .dropdown-menu {
        display: block !important;
    }
    .dropdown-submenu { position: relative; }
    .dropdown-submenu > .dropdown-menu {
        top: 0; left: 100%; position: absolute; min-width: 200px;
    }
}

/* --- MOBIL LØSNING */
@media (max-width: 768px) {
    /* 1. TVING TOPPEN TIL AT BLIVE STÅENDE */
    .navbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60px !important; /* Fast højde er nødvendig her */
        z-index: 3000 !important; /* Skal være øverst af alt */
        background-color: var(--bs-body-bg) !important;
        display: block !important;
    }

    .navbar .container-fluid {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        height: 100% !important;
    }

    /* 2. MENU OVERLAY (Starter præcis under den låste top) */
.navbar-collapse {
        position: fixed !important;
        top: 60px !important; /* Skal matche navbarens højde */
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: calc(100vh - 60px) !important;
        background-color: var(--bs-body-bg) !important;
        z-index: 2999 !important;
        overflow-y: auto !important;
        display: none; /* Skjules indtil .show */

        /* NYE TILFØJELSER HERUNDER */
        padding-left: 20px !important;  /* Giver luft til menupunkterne i venstre side */
        padding-right: 20px !important; /* Giver luft i højre side */
        box-sizing: border-box !important; /* Vigtigt: sikrer at padding ikke gør menuen bredere end skærmen */
    }

    .navbar-collapse.show {
        display: block !important;
    }
/* Vi rammer selve 'kassen' der ruller, i stedet for linksne */
    .navbar-collapse::after {
        content: "";
        display: block;
        height: 120px; /* Her skaber vi pladsen til link 66 */
        width: 100%;
        pointer-events: none; /* Gør at man ikke kan klikke på det tomme felt */
    }

    /* Vi sikrer os, at vi ikke har mærkelige marginer på de enkelte items */
    .dropdown-item:last-child {
        margin-bottom: 0 !important;
    }

    /* 3. UNDERMENUER (Fixer forsvindings-nummeret) */
    /* Vi tvinger alle menuer til at være synlige i flowet når hovedmenuen er åben */
    .dropdown-menu {
        position: static !important; 
        float: none !important;
        display: none; /* Vises kun ved .show */
        width: 100% !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding-bottom: 0 !important;
    }

    .dropdown-menu.show {
        display: block !important; /* Viser undermenuen uden at skjule forælderen */
    }

    /* 4. Sørg for at bagvedliggende side ikke hopper */
    body.modal-open, body:has(.navbar-collapse.show) {
        overflow: hidden !important;
    }

    /* 5. Styling af links */
    .dropdown-item {
        padding: 6px 20px !important;
        border-bottom: 1px solid rgba(128,128,128,0.1) !important;
        color: var(--bs-body-color) !important;
    }

    /* Indryk undermenuer */
/* Niveau 2 (Første undermenu - f.eks. Slægtsforskning) */
    .dropdown-menu .dropdown-item {
        padding-left: 30px !important;
        background-color: rgba(128,128,128,0.02) !important;
    }

    /* Niveau 3 (Undermenu til en undermenu) */
    .dropdown-menu .dropdown-menu .dropdown-item {
        padding-left: 50px !important;
        background-color: rgba(128,128,128,0.04) !important;
    }

    /* Niveau 4 (Hvis du har endnu et niveau) */
    .dropdown-menu .dropdown-menu .dropdown-menu .dropdown-item {
        padding-left: 70px !important;
        background-color: rgba(128,128,128,0.06) !important;
    }

    /* Justering af pile (toggles) så de ikke overlapper teksten ved dybe indryk */
    .dropdown-toggle {
        padding-right: 10px !important;
    }
}

/* --- DEBUG & MAP MODALS --- */
#debugModal .modal-content {
    background-color: #1e1e1e;
    color: #f1f1f1;
    font-family: monospace;
    font-size: 0.9rem;
}

#debugModal pre {
    background-color: #2b2b2b;
    color: #f1f1f1;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
}

#map {
    width: 100%;
    height: 400px;
}

@media (min-width: 768px) {
    #mapModal.modal.fade.show {
        display: flex !important;
        justify-content: flex-end !important;
        padding-right: 0 !important;
    }

    .modal-dialog.mapDialog {
        margin: 0 !important;
        max-width: unset !important;
        width: 800px;
        align-self: flex-end;
        margin-right: 20px; 
    }

    #map {
        margin: 10px; 
        width: calc(100% - 20px); 
        box-sizing: border-box; 
        min-height: 400px; 
    }
}