:root {
    --primary-color: #0056b3;
    --primary-hover: #004085;
    --primary-light: #e8f1fb;
    --bg-color: #f4f6f8;
    --card-bg: #ffffff;
    --text-color: #222222;
    --muted-text: #5a6577;
    --border-color: #dce2ea;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    min-width: 0;
    background: var(--card-bg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

.app-header {
    background-color: var(--primary-color);
    color: #fff;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 58px;
}

.app-header h1 {
    font-size: 1.25rem;
    text-align: center;
    padding: 0 110px;
}

.back-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.45);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.88rem;
    position: absolute;
    left: 16px;
    transition: background 0.2s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.app-content {
    padding: 20px 24px;
    flex-grow: 1;
    min-width: 0;
    width: 100%;
}

.view {
    min-width: 0;
    width: 100%;
}

.hidden {
    display: none !important;
}

.view h2 {
    font-size: 1.15rem;
    margin-bottom: 16px;
    color: var(--muted-text);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 8px;
}

/* Izbira postaj */
.nav-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.nav-list a {
    display: block;
    padding: 15px 18px;
    background: var(--bg-color);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.nav-list a:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: #b6d2f5;
}

/* Vodoravni trak z dnevi */
.days-bar {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    scrollbar-width: thin;
}

.day-pill {
    flex: 0 0 auto;
    padding: 9px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.day-pill:hover {
    background: #e6ecf4;
}

.day-pill.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    font-weight: 600;
}

/* Panel za filtre (skok na uro + iskalnik) */
.filters-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    width: 100%;
}

/* Iskalnik */
.search-wrapper {
    position: relative;
    flex: 1 1 260px;
    min-width: 0;
}

.search-wrapper input {
    width: 100%;
    padding: 9px 32px 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.92rem;
    background: #fff;
    color: var(--text-color);
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.15);
}

.clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--muted-text);
    cursor: pointer;
    line-height: 1;
}

#epgContainer {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
}

/* Tabela rezultatov */
.data-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.data-table col.col-time {
    width: 68px;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-color);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-text);
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.data-table th:first-child,
.time-cell {
    width: 68px;
    white-space: nowrap;
}

.time-cell {
    font-weight: 700;
    vertical-align: middle;
    color: var(--primary-color);
}

.title-cell {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.track-title {
    font-weight: 500;
    word-break: break-word;
}

.title-cell small {
    color: var(--muted-text);
    display: inline-block;
    margin-top: 3px;
}

.spinner,
.no-data,
.error-msg {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted-text);
}

/* ---------- Samodejno osveževanje ---------- */
.refresh-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.82rem;
    color: var(--muted-text);
}

.refresh-note {
    opacity: 0.8;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1f9d55;
    flex: 0 0 auto;
    animation: livePulse 2.4s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.data-table tr.is-new td {
    animation: newRow 5s ease-out;
}

@keyframes newRow {
    from { background-color: #fff4c2; }
    to { background-color: transparent; }
}

/* ---------- Gumb za možnosti na desni ---------- */
.track-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.track-text {
    flex: 1 1 auto;
    min-width: 0;
}

.track-actions {
    display: flex;
    flex: 0 0 auto;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted-text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn .ico {
    display: block;
    width: 20px;
    height: 20px;
}

.more-btn:hover {
    color: var(--primary-color);
    background: var(--primary-light);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 0;
}

@media (min-width: 641px) {
    .time-cell {
        vertical-align: middle;
    }
}

/* ---------- Popup / Action sheet za skladbo ---------- */
.action-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.42);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.14s ease-out;
}

.action-sheet {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
    animation: slideUp 0.18s ease-out;
}

.action-sheet.is-popover {
    position: fixed;
    width: 250px;
    max-width: 250px;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.12s ease-out;
}

.action-sheet-header {
    padding: 4px 8px 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
}

.action-sheet-title {
    font-weight: 700;
    font-size: 0.96rem;
    color: var(--text-color);
    line-height: 1.3;
}

.action-sheet-sub {
    font-size: 0.8rem;
    color: var(--muted-text);
    margin-top: 2px;
}

.action-sheet-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font: inherit;
    font-size: 0.94rem;
    font-weight: 500;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease;
}

.action-sheet.is-popover .action-item {
    padding: 8px 10px;
    font-size: 0.88rem;
}

.action-item:hover {
    background: var(--bg-color);
}

.action-item .ico {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.action-item.is-done {
    color: #1f7a45;
    background: #eaf7ef;
}

.action-sep {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---------- Skok na uro ---------- */
.hour-jump {
    flex: 0 0 auto;
}

.hour-jump select {
    min-height: 38px;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
    color: var(--text-color);
    font: inherit;
    font-size: 0.92rem;
    cursor: pointer;
}

.hour-jump select:focus-visible {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.15);
}

.hour-jump select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------- Lepljivi naslovi (ure / dnevi) ---------- */
.data-table tr.group-row th {
    position: sticky;
    top: 0;
    z-index: 2;
    width: auto;
    white-space: normal;
    padding: 8px 14px;
    background: #eaf1fa;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    border-bottom: 0;
    box-shadow: 0 1px 0 var(--border-color);
}

.data-table tr.is-target td {
    animation: newRow 3s ease-out;
}

.data-table tr.group-row.is-target th {
    animation: groupFlash 1.8s ease-out;
}

@keyframes groupFlash {
    from { background: #fff1b8; }
    to { background: #eaf1fa; }
}

/* ---------- Skeleton ---------- */
.skeleton {
    padding: 4px 0;
}

.skeleton-row {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 14px;
    align-items: start;
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
}

.sk {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, #e9eef4 25%, #f5f7fa 45%, #e9eef4 65%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

.sk-time {
    width: 44px;
    height: 16px;
}

.sk-lines {
    display: grid;
    gap: 8px;
}

.sk-line {
    height: 14px;
}

.sk-sub {
    height: 12px;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Iskanje čez teden ---------- */
.btn-link {
    background: none;
    border: none;
    padding: 6px 2px;
    color: var(--primary-color);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.btn-link:hover {
    color: var(--primary-hover);
}

.btn-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

.other-days {
    text-align: center;
    padding: 0 16px 24px;
}

.other-days-compact {
    padding: 14px 0 0;
    text-align: left;
}

.week-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary-color);
    font-size: 0.92rem;
    font-weight: 600;
}

.week-note {
    padding: 14px 4px 0;
    font-size: 0.85rem;
    color: var(--muted-text);
}

/* ---------- Mobilni zasloni ---------- */
@media (max-width: 640px) {
    /* Gumb Nazaj je na telefonu v toku (ne absolutno pozicioniran), da se nikoli ne prekriva
       z naslovom, ne glede na dolžino napisa v posameznem jeziku */
    .app-header {
        justify-content: center;
        gap: 10px;
        padding: 12px 14px;
    }

    .app-header h1 {
        font-size: 1.05rem;
        text-align: center;
        padding: 0;
        min-width: 0;
    }

    /* V postaji prikažemo samo ime postaje, brez "Glasbeni SOS –" */
    .app-header h1 .title-app {
        display: none;
    }

    .app-header:has(.back-btn:not(.hidden)) {
        justify-content: flex-start;
    }

    .app-header:has(.back-btn:not(.hidden)) h1 {
        flex: 1 1 auto;
        text-align: left;
    }

    .back-btn {
        position: static;
        flex: 0 0 auto;
        padding: 5px 10px;
        font-size: 0.82rem;
    }

    .app-content {
        padding: 14px;
    }

    .nav-list {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .data-table col.col-time,
    .data-table th:first-child,
    .time-cell {
        width: 56px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }

    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .filters-panel {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        padding: 8px;
        margin-bottom: 10px;
    }

    .hour-jump {
        flex: 0 0 auto;
    }

    .hour-jump select {
        width: 88px;
        padding: 8px 22px 8px 10px;
    }

    .search-wrapper {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    .search-wrapper input {
        font-size: 0.88rem;
        padding-left: 10px;
    }

    .days-bar {
        margin-bottom: 10px;
    }

    .track-main {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .track-actions {
        margin: 0 -6px 0 0;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .skeleton-row {
        grid-template-columns: 56px 1fr;
        padding: 12px 8px;
    }

    .data-table tr.group-row th {
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .live-dot,
    .data-table tr.is-new td,
    .sk,
    .data-table tr.is-target td,
    .data-table tr.group-row.is-target th {
        animation: none;
    }
}

/* ---------- Status osveževanja znotraj prve grupe ure ---------- */
.group-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.group-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted-text);
    text-align: right;
    min-width: 0;
}

@media (max-width: 640px) {
    .group-refresh {
        font-size: 0.72rem;
    }

    /* Na ozkih zaslonih skrijemo "(samodejno osveževanje)", da ostane ena čista vrstica */
    .group-refresh .refresh-note {
        display: none;
    }
}
/* ---------- Meni: majhni zasloni in zaklep ozadja ---------- */
.action-backdrop {
    overscroll-behavior: contain;
    touch-action: none; /* ozadje se na dotik ne premika */
}

.action-sheet {
    max-height: 90vh;
    max-height: calc(100dvh - 24px); /* tudi v ležečem načinu ostane meni znotraj zaslona */
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y; /* sam meni lahko drsi */
}
