/* DiNAManiak ------------------------------------------------------------- */

:root {
    color-scheme: dark;
    --bg: #182028;
    --surface: #323e4d;
    --text: #b8bbbf;
    --muted: #8a9099;
    --link: #ffffff;
    --border: #455160;
    --input-bg: #323e4d;
    --input-border: #455160;
    --hover: rgba(255, 255, 255, .05);
}

/*
 * La page elle-même ne défile jamais (pas d'ascenseur de fenêtre dans l'iframe SAGA/DiNA) :
 * l'en-tête est fixe et seule la liste (<main>) défile, avec son ascenseur masqué.
 */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 720px;
}

.app > .sticky-top {
    position: relative; /* référence du badge "copié" */
    flex: none;
}

.app > main {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;      /* Firefox, Safari 18.2+, Chrome 121+ */
    -ms-overflow-style: none;
}

/* Safari < 18.2, anciens Chrome */
.app > main::-webkit-scrollbar,
.menu::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.menu { scrollbar-width: none; }

/* Header ----------------------------------------------------------------- */

header,
.searchbar,
#info-bar { background: var(--bg); }

.nav-btn {
    display: block;
    min-width: 60px;
    padding: 4px 10px;
    border: 0;
    background: none;
    color: var(--link);
    font-size: 11px;
    text-align: center;
    user-select: none;
}

.nav-btn i {
    display: block;
    font-size: 1.5rem;
}

#btn-clock { width: 80px; }
#btn-clock.warn { color: orange; }
#btn-clock.alert { color: red; }

/* Recherche -------------------------------------------------------------- */

.searchbar { padding: 0 5px 5px; }

#search,
#search:focus {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: #fff;
}

#search::placeholder { color: var(--muted); }

/* Player ----------------------------------------------------------------- */

.embed-container {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000 url('../img/tv-static.gif') center / cover no-repeat;
}

.embed-container iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Notification "copié" --------------------------------------------------- */

#copied {
    position: absolute;
    right: 4px;
    bottom: 32px;
    z-index: 2;
    visibility: hidden;
}

#copied.show { visibility: visible; }
#copied.ok { background: var(--surface); color: #fff; }

#info-bar {
    border-bottom: 1px solid var(--border);
}

#active-function {
    font-size: .7rem;
    font-weight: bold;
}

/* Liste des médias ------------------------------------------------------- */

#data-load { margin-bottom: 1rem; }

.list-results {
    position: relative;
    margin: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.list-results:hover,
.list-results:focus-visible {
    background-image: linear-gradient(var(--hover), var(--hover));
    outline: none;
}

.list-results img {
    width: 80px;
    height: 80px;
    object-fit: cover;
}

.list-results > .col-8 { min-width: 0; }

/* Nom sur 2 lignes max, coupé proprement même sans espaces (VSHK_Kanal_9_…) */
.list-item-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-size: .7rem;
    font-weight: bold;
}

.list-item-date {
    font-size: .6rem;
    color: var(--muted);
}

.list-results .badge {
    position: absolute;
    right: 6px;
    bottom: 6px;
}

.list-error {
    padding: .5rem 1rem;
    font-size: .75rem;
    color: #dc3545;
}

.list-empty {
    padding: 1rem;
    font-size: .75rem;
    color: var(--muted);
    text-align: center;
}

/* Recherches perso ------------------------------------------------------- */

.search-row {
    display: flex;
    gap: 4px;
}

.search-row #search { flex: 1; }

.icon-btn {
    flex: none;
    width: 38px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: #fff;
    font-size: 1rem;
}

.icon-btn:hover:not(:disabled) { border-color: #6c7a8c; }
.icon-btn:disabled { opacity: .35; }
.icon-btn.active { color: #ffc107; }

.menu-wrap {
    position: relative;
    display: flex;
}

.menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1100;
    width: min(340px, calc(100vw - 10px));
    max-height: 70vh;
    overflow-y: auto;
    padding: 4px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    font-size: .8rem;
}

.menu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.menu-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px 2px;
    color: var(--muted);
    font-size: .65rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.menu-title + ul + .menu-title {
    margin-top: 4px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.menu-link {
    border: 0;
    background: none;
    color: var(--muted);
    font-size: .65rem;
    text-transform: none;
    text-decoration: underline;
}

.menu-link:hover { color: #fff; }

.menu-item {
    display: flex;
    align-items: center;
    padding: 0 6px;
}

.menu-item:hover { background: var(--hover); }

.menu-apply {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 5px 6px;
    border: 0;
    background: none;
    color: #fff;
    text-align: left;
}

.menu-apply:has(> .bi) {
    flex-direction: row;
    align-items: center;
}

.menu-name,
.menu-sub {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.menu-sub {
    color: var(--muted);
    font-size: .65rem;
}

.menu-sub:empty { display: none; }

.menu-icon {
    flex: none;
    padding: 4px 6px;
    border: 0;
    background: none;
    color: var(--muted);
    visibility: hidden;
}

.menu-item:hover .menu-icon,
.menu-icon:focus-visible { visibility: visible; }
.menu-icon:hover { color: #fff; }

.menu-empty {
    padding: 4px 12px 6px;
    color: var(--muted);
    font-style: italic;
}

.menu-input {
    margin: 3px 0;
    background: var(--bg);
    border-color: var(--input-border);
    color: #fff;
}

@media (hover: none) {
    .menu-icon { visibility: visible; } /* tactile : toujours visibles */
}
