/* ==== CF Player CMS - SiteKiosk-style dashboard ============================
   Layout: full-width navy topbar + fixed sidebar + scrolling content area.
   Palette
     navy        #1f3864      (topbar, primary accents, sidebar active)
     navy-deep   #142544      (topbar hover)
     ink         #2c3e50      (body text)
     muted       #6b7a8c      (secondary text)
     line        #d4dae0      (borders)
     surface     #ffffff      (cards)
     panel       #f6f8fb      (table headers, card title bar)
     bg          #ebeef2      (content background)
     ok          #2ec27e
     warn        #f1b829
     err         #e34d4d
     gray        #94a3b3
=========================================================================== */

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 13px;
    color: #2c3e50;
    background: #ebeef2;
}
a { color: #1f6fb5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------- Top bar ----------- */
.topbar {
    height: 44px;
    background: #1f3864;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.15);
    position: relative;
    z-index: 20;
}
.topbar .brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
}
.topbar .brand .accent { color: #f1b829; }
.topbar .version {
    font-size: 10px;
    color: rgba(255,255,255,0.55);
    margin-left: 6px;
}
.topbar .spacer { flex: 1; }
.topbar .who, .topbar .topbar-link {
    color: rgba(255,255,255,0.85);
    padding: 6px 12px;
    border-radius: 3px;
    font-size: 12px;
}
.topbar .who::before {
    content: "\1F464";
    margin-right: 6px;
    font-size: 13px;
    opacity: 0.85;
}
.topbar .topbar-link:hover { background: rgba(255,255,255,0.1); text-decoration: none; }

/* ----------- Frame: sidebar + main ----------- */
.frame {
    display: flex;
    min-height: calc(100vh - 44px);
}

/* ----------- Sidebar ----------- */
.sidebar {
    width: 56px;
    flex: 0 0 56px;
    background: #ffffff;
    border-right: 1px solid #d4dae0;
    transition: width 0.15s ease;
    overflow: hidden;
    position: relative;
}
.sidebar:hover { width: 200px; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 0; }
.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #5b6b7d;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    border-left: 3px solid transparent;
    transition: background 0.1s, color 0.1s;
}
.sidebar a:hover { background: #f0f3f7; color: #1f3864; text-decoration: none; }
.sidebar a.active {
    background: #e7eef7;
    color: #1f3864;
    border-left-color: #1f3864;
}
.sidebar a svg {
    flex: 0 0 24px;
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sidebar .label { opacity: 0; transition: opacity 0.15s 0.05s; }
.sidebar:hover .label { opacity: 1; }

/* ----------- Content ----------- */
.content {
    flex: 1;
    padding: 16px 20px 32px;
    min-width: 0;
}
.content h1 {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 600;
    color: #1f3864;
}
.content h2 {
    margin: 24px 0 10px;
    font-size: 14px;
    color: #1f3864;
    font-weight: 600;
}
.crumbs {
    display: flex;
    gap: 6px;
    color: #6b7a8c;
    font-size: 12px;
    margin-bottom: 12px;
}
.crumbs a { color: #1f6fb5; }
.crumbs .sep { color: #b0bbc7; }

/* ----------- Cards ----------- */
.card {
    background: #fff;
    border: 1px solid #d4dae0;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    margin-bottom: 16px;
    overflow: hidden;
}
.card-head {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f6f8fb;
    border-bottom: 1px solid #d4dae0;
    font-size: 12px;
    font-weight: 600;
    color: #1f3864;
}
.card-head .spacer { flex: 1; }
.card-head .iconbtn {
    width: 22px; height: 22px;
    display: inline-flex;
    align-items: center; justify-content: center;
    color: #1f6fb5;
    border-radius: 3px;
}
.card-head .iconbtn:hover { background: #e7eef7; }
.card-body { padding: 12px; }
.card-body.tight { padding: 0; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
@media (max-width: 1100px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ----------- Tables ----------- */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 12.5px;
}
table.data th, table.data td {
    padding: 7px 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f4;
    vertical-align: middle;
}
table.data thead th {
    background: #f6f8fb;
    font-weight: 600;
    color: #5b6b7d;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #d4dae0;
    cursor: default;
}
table.data thead th.sort::after {
    content: " \2195";
    color: #b0bbc7;
    font-size: 10px;
}
table.data tbody tr:hover { background: #f7f9fc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ----------- Status pill / dot ----------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}
.pill::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.6) inset;
}
.pill.online   { color: #1c8b5d; background: #e1f5eb; }
.pill.offline  { color: #b53a3a; background: #fce6e6; }
.pill.unknown  { color: #6b7a8c; background: #eef1f4; }
.pill.warn     { color: #b07b00; background: #fdf3da; }
.pill.queued   { color: #1c5fa6; background: #e2eefb; }
.pill.sent     { color: #6b7a8c; background: #eef1f4; }
.pill.ack_ok   { color: #1c8b5d; background: #e1f5eb; }
.pill.ack_error{ color: #b53a3a; background: #fce6e6; }

/* ----------- Buttons ----------- */
button, .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1f3864;
    color: #fff;
    border: 1px solid #1f3864;
    border-radius: 3px;
    padding: 6px 14px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}
button:hover, .btn:hover { background: #142544; border-color: #142544; text-decoration: none; }
button.secondary, .btn.secondary {
    background: #fff; color: #1f3864; border-color: #c4ccd6;
}
button.secondary:hover, .btn.secondary:hover { background: #f0f3f7; }
button.danger, .btn.danger { background: #b53a3a; border-color: #b53a3a; }
button.danger:hover, .btn.danger:hover { background: #8e2727; border-color: #8e2727; }
button.success, .btn.success { background: #1c8b5d; border-color: #1c8b5d; }
button.success:hover, .btn.success:hover { background: #156a47; border-color: #156a47; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }

/* ----------- Forms ----------- */
form.cfp-form fieldset {
    border: none;
    background: #fff;
    border: 1px solid #d4dae0;
    border-radius: 4px;
    margin: 0 0 14px;
    padding: 0;
}
form.cfp-form legend {
    width: 100%;
    background: #f6f8fb;
    border-bottom: 1px solid #d4dae0;
    padding: 8px 12px;
    font-weight: 600;
    color: #1f3864;
    font-size: 12px;
}
form.cfp-form fieldset > .row {
    display: grid;
    grid-template-columns: 14rem 1fr;
    gap: 14px;
    align-items: center;
    padding: 7px 12px;
    border-bottom: 1px solid #f0f3f7;
}
form.cfp-form fieldset > .row:last-child { border-bottom: 0; }
form.cfp-form label { color: #5b6b7d; font-size: 12px; }
form.cfp-form input[type="text"],
form.cfp-form input[type="number"],
form.cfp-form input[type="password"],
form.cfp-form select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #c4ccd6;
    border-radius: 3px;
    background: #fff;
    font-size: 12.5px;
    color: #2c3e50;
}
form.cfp-form input:focus, form.cfp-form select:focus {
    outline: none;
    border-color: #1f6fb5;
    box-shadow: 0 0 0 2px rgba(31,111,181,0.18);
}

/* ----------- Flash messages ----------- */
.flash {
    border-radius: 3px;
    padding: 8px 12px;
    margin-bottom: 14px;
    border: 1px solid;
    font-size: 12.5px;
}
.flash.ok    { background: #e1f5eb; border-color: #b9e3cd; color: #1c5d3f; }
.flash.err   { background: #fce6e6; border-color: #f1bdbd; color: #862c2c; }
.flash.info  { background: #e2eefb; border-color: #bdd5f1; color: #1c4980; }

/* ----------- Donut (pure CSS) ----------- */
.donut-wrap {
    display: flex;
    gap: 18px;
    align-items: center;
}
.donut {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    flex: 0 0 130px;
    position: relative;
    background: #ecf0f4;
}
.donut::after {
    content: "";
    position: absolute;
    inset: 22px;
    background: #fff;
    border-radius: 50%;
}
.donut .num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #1f3864;
    z-index: 1;
}
.legend { font-size: 12px; color: #2c3e50; }
.legend .item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 3px 0;
}
.legend .swatch {
    width: 11px; height: 11px;
    border-radius: 2px;
    flex: 0 0 11px;
}

/* ----------- Notifications list ----------- */
.notif {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid #f0f3f7;
    font-size: 12.5px;
}
.notif:last-child { border-bottom: 0; }
.notif .badge {
    flex: 0 0 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    display: flex; align-items: center; justify-content: center;
}
.notif .badge.err  { background: #e34d4d; }
.notif .badge.warn { background: #f1b829; color: #2c3e50; }
.notif .badge.ok   { background: #2ec27e; }
.notif .text { flex: 1; }
.notif .text small { color: #6b7a8c; display: block; font-size: 11px; }
.notif .more { color: #1f6fb5; font-size: 11.5px; }

/* ----------- Login ----------- */
.login-card {
    width: 320px;
    margin: 8vh auto;
    background: #fff;
    padding: 28px 26px;
    border-radius: 4px;
    border: 1px solid #d4dae0;
    box-shadow: 0 4px 16px rgba(20,37,68,0.08);
}
.login-card h2 {
    margin: 0 0 16px;
    color: #1f3864;
    font-size: 18px;
    text-align: center;
}
.login-card label { display: block; font-size: 11.5px; color: #5b6b7d; margin: 6px 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.login-card input {
    width: 100%; padding: 7px 10px;
    border: 1px solid #c4ccd6; border-radius: 3px;
    font-size: 13px;
}
.login-card button { width: 100%; margin-top: 14px; justify-content: center; }

/* ============================================================
 * Responsive Breakpoints
 *  - 1100px : grid-2/grid-3 stacken (greift schon weiter oben)
 *  - 1024px : Tablets - Sidebar bleibt schmal, Padding kompakter
 *  -  768px : Phone-Landscape / kleine Tablets - Sidebar als Drawer
 *  -  480px : Phone-Portrait (iPhone 15 Pro 393px) - kompaktes Layout
 * ============================================================ */

/* Burger-Button Default: versteckt auf grossen Screens */
.topbar-burger {
    display: none;
    background: transparent; border: 0; color: #fff;
    width: 36px; height: 36px; padding: 0;
    margin-right: 6px; cursor: pointer;
    align-items: center; justify-content: center;
    border-radius: 4px;
}
.topbar-burger:hover { background: rgba(255,255,255,.12); }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 25;
    background: rgba(20,37,68,0.45);
    -webkit-tap-highlight-color: transparent;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* ===== ≤1024px : Tablets ===== */
@media (max-width: 1024px) {
    .content { padding: 12px 14px 24px; }
    .content h1 { font-size: 17px; }
    .content h2 { font-size: 13.5px; margin: 18px 0 8px; }
    .card { margin-bottom: 12px; }
    .card-body { padding: 10px; }
    /* Sidebar nur Icons - kein Hover-Expand auf Touch-Geraeten */
    @media (hover: none) {
        .sidebar { width: 48px; flex-basis: 48px; }
        .sidebar:hover { width: 48px; }
        .sidebar .label { display: none; }
    }
}

/* ===== ≤768px : Phone-Landscape / kleine Tablets ===== */
@media (max-width: 768px) {
    html, body { font-size: 12.5px; }
    .topbar { padding: 0 10px; height: 48px; }
    .topbar-burger { display: inline-flex; }
    .topbar .brand { font-size: 14px; }
    .topbar .version { display: none; }

    /* Sidebar wird Slide-Out-Drawer */
    .frame { display: block; min-height: calc(100vh - 48px); }
    .sidebar {
        position: fixed; top: 48px; left: -240px; bottom: 0;
        width: 220px; flex-basis: 220px;
        z-index: 30;
        transition: left .18s ease;
        box-shadow: 4px 0 12px rgba(0,0,0,0.2);
    }
    .sidebar:hover { width: 220px; }
    .sidebar .label { opacity: 1; }
    body.sidebar-open .sidebar { left: 0; }
    .content { padding: 10px 12px 20px; }
    .content h1 { font-size: 16px; margin-bottom: 10px; }
    .content h2 { font-size: 13px; }

    /* Cards in 1 Spalte */
    .grid-2, .grid-3 { grid-template-columns: 1fr !important; gap: 10px; }
    .card { margin-bottom: 10px; border-radius: 3px; }
    .card-head { padding: 7px 10px; font-size: 11.5px; flex-wrap: wrap; gap: 4px; }
    .card-body { padding: 8px; }

    /* Tabellen scrollen horizontal statt zu sprengen */
    table.data { font-size: 11.5px; }
    table.data th, table.data td { padding: 5px 6px; }
    .card-body.tight { overflow-x: auto; }

    /* Form-Buttons grosser fuer Touch */
    .btn-row { gap: 6px; }
    button, .btn { min-height: 32px; }

    /* Modale schoepfen viewport */
    .login-card { width: 92vw; }
}

/* ===== ≤480px : Phone-Portrait ===== */
@media (max-width: 480px) {
    html, body { font-size: 12px; }
    .topbar { height: 44px; }
    .topbar .brand { font-size: 13px; }
    .topbar .who { display: none; }
    .topbar .topbar-link { font-size: 11px; padding: 4px 8px; }

    .sidebar { top: 44px; width: 200px; }

    .content { padding: 8px 10px 16px; }
    .content h1 { font-size: 15px; margin: 0 0 8px; }
    .content h2 { font-size: 12.5px; margin: 12px 0 6px; }

    .crumbs { font-size: 11px; flex-wrap: wrap; }

    .card-head { padding: 6px 8px; font-size: 11px; }
    .card-head button { font-size: 10.5px !important; padding: 3px 8px !important; }
    .card-body { padding: 6px; }

    /* Mediathek-Grid-Tiles kompakter */
    .media-grid { grid-template-columns: repeat(auto-fill,minmax(140px,1fr)) !important; gap: 8px !important; }
    .media-tile .meta { padding: 4px 6px; font-size: 11px; }
    .media-tile .tile-del,
    .media-tile .tile-rn,
    .media-tile .tile-info,
    .media-tile .tile-tp { display: block; opacity: .85; } /* dauerhaft sichtbar - kein Hover auf Touch */

    /* Datei-Browser im Projekt: noch enger */
    #proj-files-card .media-grid { grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 8px; }

    /* Tabellen sehr kompakt */
    table.data { font-size: 11px; }
    table.data th, table.data td { padding: 4px 5px; }

    /* Quota-Anzeige weg auf Phone */
    .quota-bar, .quota-text { display: none; }

    /* Login-Card */
    .login-card { width: 94vw; padding: 18px 16px; }
}

/* Drag-Targets etwas grosser auf Touch */
@media (hover: none) {
    .media-tile .tile-del,
    .media-tile .tile-rn,
    .media-tile .tile-info,
    .media-tile .tile-tp { display: block; }
}
