/* ============================================================
   Signage — CSS
   ============================================================ */

:root {
    --sidebar-bg:     #1a1f2e;
    --sidebar-active: rgba(79,110,247,0.18);
    --sidebar-hover:  rgba(255,255,255,0.06);
    --sidebar-text:   rgba(255,255,255,0.78);
    --sidebar-muted:  rgba(255,255,255,0.32);
    --sidebar-accent: #4f6ef7;
}

/* ---- Layout ---- */
#wrapper {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
}
#content  { min-height: 100vh; }

/* Sidebar: fest links, volle Höhe, unabhängig scrollbar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
}

/* Content: Abstand links wegen fixed Sidebar */
#content {
    margin-left: 240px;
}

/* Topbar immer oben sichtbar beim Scrollen */
#topbar {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
}

/* Content: Abstand oben wegen fixed Topbar */
#content > *:not(#topbar):first-child,
#content > .p-4:first-of-type {
    margin-top: 0;
}
#content {
    padding-top: 50px;
}

/* ---- Sidebar Links ---- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sidebar-muted);
    transition: color .15s;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.sidebar-link:hover i { color: rgba(255,255,255,0.65); }
.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 500;
}
.sidebar-link.active i { color: var(--sidebar-accent); }

/* Gesperrte Feature-Links */
.sidebar-link-locked {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: rgba(255,255,255,0.25);
    font-size: .875rem; cursor: not-allowed;
    user-select: none;
}
.sidebar-link-locked i { font-size: 1rem; color: rgba(255,255,255,0.2); }

/* Untermenü-Links (eingerückt) */
.sidebar-link--sub {
    padding-left: 40px;
    font-size: .82rem;
}
.sidebar-link--sub i { font-size: .85rem; }

/* ---- Sidebar Abschnitts-Label ---- */
.sidebar-section {
    font-size: .67rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    padding: 16px 12px 5px;
    user-select: none;
}

.sidebar-section-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-section-chevron {
    font-size: .75rem;
    transition: transform .2s ease;
}

.sidebar-section-toggle[aria-expanded="false"] .sidebar-section-chevron {
    transform: rotate(-90deg);
}

/* ---- Cards ---- */
.card { border-radius: 12px; }

/* Hover-Effekt nur auf normale Cards, nicht Auswahl-Karten */
.card:not(.cycle-card):hover {
    transform: translateY(-2px);
    transition: transform 0.15s ease;
}

/* ---- Playlist Drag & Drop ---- */
#playlist-sortable .list-group-item { cursor: default; }
#playlist-sortable .bi-grip-vertical {
    cursor: grab;
    font-size: 1.1rem;
}

/* ---- Status Badges ---- */
.badge { font-weight: 500; }

/* ---- HTMX Loading ---- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }

/* ---- Progress Bars ---- */
.progress { border-radius: 4px; }

/* ---- Laufzeit-Auswahl Karten ---- */
.cycle-card.card {
    border: 2px solid #dee2e6 !important;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cycle-card.card:hover {
    border-color: #86b7fe !important;
    transform: none;
}
.cycle-card.card.cycle-card--active {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 3px rgba(13,110,253,.15) !important;
}

/* ---- Extra-Small Button ---- */
.btn-xs {
    padding: 2px 6px;
    font-size: 0.75rem;
    line-height: 1.4;
    border-radius: 4px;
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    /* Sidebar als Overlay — margin-left zurücksetzen */
    #content {
        margin-left: 0 !important;
        padding-top: 50px;
    }

    /* Topbar auf Mobile: volle Breite */
    #topbar {
        left: 0 !important;
    }

    /* Sidebar als Overlay */
    #sidebar {
        position: fixed !important;
        z-index: 1050;
        top: 0 !important;
        left: 0;
        bottom: 0 !important;
        height: 100% !important;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.4);
        overflow-y: auto !important;
        overflow-x: hidden;
    }
    #sidebar.show { transform: translateX(0); }

    /* Content nimmt vollen Viewport */
    #content { width: 100%; }

    /* Touch-freundlichere Buttons */
    .btn-xs {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Sidebar-Links auf Mobile größer */
    .sidebar-link { padding: 12px 14px; }

    /* Tabellen scrollbar machen */
    .table-responsive-stack { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .card-body .table { min-width: 500px; }
    .card-body .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Topbar: Hamburger + Avatar immer sichtbar, Breadcrumb kürzen */
    #content .bg-white.border-bottom {
        padding: 8px 12px !important;
        flex-wrap: nowrap !important;
        gap: 8px;
    }
    #content .bg-white.border-bottom h6 {
        font-size: .75rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100vw - 140px);
        flex: 1;
    }
    #content .bg-white.border-bottom h6 a {
        display: none;  /* Eltern-Breadcrumbs auf Mobile ausblenden */
    }
    #avatar-btn { flex-shrink: 0; }

    /* p-4 auf Mobile verkleinern */
    #content .p-4 { padding: 12px !important; }

    /* Playlist: Spalten untereinander mit sinnvollem Abstand */
    .playlist-cols > [class*="col-md"] { margin-bottom: 1rem; }

    /* Touch-Targets in Listen */
    .list-group-item { padding: 12px 14px !important; }

    /* Buttons in Tabellen auf Mobile größer */
    td .btn-xs, td .btn-sm { min-height: 36px; }

    /* KPI-Karten: icon kleiner */
    .kpi-icon { padding: 10px !important; }
    .kpi-icon i { font-size: 1.1rem !important; }

    /* Cards: weniger padding */
    .card-body { padding: 12px !important; }

    /* Row-Gaps verkleinern */
    .row.g-4 { --bs-gutter-y: 1rem; --bs-gutter-x: 1rem; }
}

@media (max-width: 576px) {
    /* Ganz kleine Screens: 1 Spalte erzwingen wo nötig */
    .row.g-3 > .col-sm-6 { flex: 0 0 100%; max-width: 100%; }
    .row.g-3 > .col-md-4,
    .row.g-3 > .col-md-6 { flex: 0 0 100%; max-width: 100%; }

    /* Modals: volle Breite */
    .modal-dialog { margin: 8px; }
    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg { max-width: calc(100vw - 16px); }

    /* Media-Library Filter: untereinander */
    #filter-form { flex-direction: column !important; width: 100%; }
    #filter-form .form-select,
    #filter-form input[type=search] {
        width: 100% !important;
        min-width: unset !important;
    }

    /* Playlist: Thumbnails etwas größer */
    .playlist-thumb { width: 56px !important; height: 42px !important; }

    /* Buttons: nur Icon auf Mobile */
    .btn-mobile-icon-only .btn-text { display: none; }

    /* Screen-Detail: Zeitpläne-Tabelle scrollbar */
    .schedules-table-wrap { overflow-x: auto; }
    .schedules-table-wrap table { min-width: 480px; }

    /* Flex-wrap für Aktionsleisten */
    .action-bar { flex-wrap: wrap !important; gap: 8px !important; }
}
