/* =====================================================
   KissBook TV  – Style Zattoo
   ===================================================== */

/* ── Custom properties (overridable from admin settings via JS) ── */
:root {
    --kbt-bg: #0d0d14;
    --kbt-accent: #ff3333;
    --kbt-sidebar: 230px;
}

/* ── Reset ── */
#kbt-app,
#kbt-app * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Popup launcher button ── */
#kbt-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0ff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    box-shadow: 0 0 0 1px rgba(100, 120, 255, .3);
    position: relative;
    order: 10;
    /* appears after radio button */
}

#kbt-open-btn:hover {
    background: linear-gradient(135deg, #d10000 0%, #ff3333 100%);
    box-shadow: 0 0 10px rgba(220, 50, 50, .5);
    color: #fff;
}

#kbt-open-btn .kbt-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff3333;
    animation: kbt-pulse 1.4s ease-in-out infinite;
}

@keyframes kbt-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .4;
        transform: scale(.7);
    }
}

/* ── Overlay ── */
#kbt-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(4px);
    z-index: 99990;
    align-items: center;
    justify-content: center;
}

#kbt-overlay.kbt-open {
    display: flex;
}

/* ── Fenêtre principale ── */
#kbt-modal {
    width: clamp(700px, 92vw, 1400px);
    height: clamp(480px, 88vh, 860px);
    background: var(--kbt-bg, #0d0d14);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .07);
    position: relative;
    flex-direction: column;
}

/* ── Barre de titre ── */
#kbt-titlebar {
    height: 46px;
    background: #13131f;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
}

#kbt-titlebar .kbt-logo {
    font-weight: 900;
    font-size: 15px;
    color: #fff;
    letter-spacing: 1px;
}

#kbt-titlebar .kbt-logo span {
    color: var(--kbt-accent, #ff3333);
}

#kbt-search {
    flex: 1;
    max-width: 260px;
    height: 30px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 6px;
    padding: 0 10px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: border .2s;
}

#kbt-search:focus {
    border-color: rgba(255, 100, 100, .6);
}

#kbt-search::placeholder {
    color: rgba(255, 255, 255, .35);
}

#kbt-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .5);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all .2s;
}

#kbt-close:hover {
    background: rgba(255, 50, 50, .2);
    color: #ff5555;
}

/* ── Corps (sidebar + player) ── */
#kbt-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ── Sidebar chaînes ── */
#kbt-sidebar {
    width: var(--kbt-sidebar, 230px);
    min-width: var(--kbt-sidebar, 230px);
    background: color-mix(in srgb, var(--kbt-bg, #0d0d14) 80%, #fff 20%);
    border-right: 1px solid rgba(255, 255, 255, .06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Filtres catégories ── */
#kbt-cats {
    padding: 10px 10px 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex-shrink: 0;
}

.kbt-cat {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: transparent;
    color: rgba(255, 255, 255, .5);
    cursor: pointer;
    transition: all .18s;
    letter-spacing: .4px;
}

.kbt-cat:hover,
.kbt-cat.active {
    background: var(--kbt-accent, #ff3333);
    border-color: var(--kbt-accent, #ff3333);
    color: #fff;
    box-shadow: 0 0 8px rgba(255, 50, 50, .35);
}

/* ── Liste ── */
#kbt-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .12) transparent;
}

#kbt-list::-webkit-scrollbar {
    width: 4px;
}

#kbt-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .12);
    border-radius: 2px;
}

.kbt-ch {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all .18s;
}

.kbt-ch:hover {
    background: rgba(255, 255, 255, .04);
}

.kbt-ch.active {
    background: rgba(255, 50, 50, .12);
    border-left-color: var(--kbt-accent, #ff3333);
}

.kbt-ch img {
    width: 38px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
    background: rgba(255, 255, 255, .08);
    padding: 2px;
    flex-shrink: 0;
}

.kbt-ch img.kbt-img-error {
    filter: brightness(.4);
}

.kbt-ch-info {
    overflow: hidden;
}

.kbt-ch-name {
    font-size: 13px;
    font-weight: 600;
    color: #eef;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kbt-ch-cat {
    font-size: 10px;
    color: rgba(255, 255, 255, .35);
    margin-top: 1px;
}

/* ── Zone Player ── */
#kbt-player-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
    min-width: 0;
}

#kbt-player-header {
    padding: 10px 16px;
    background: #13131f;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    flex-shrink: 0;
}

#kbt-player-header .kbt-live-badge {
    background: #cc0000;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 4px;
    letter-spacing: 1px;
}

#kbt-now-playing {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

#kbt-pip-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, .07);
    border: none;
    color: rgba(255, 255, 255, .6);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s;
}

#kbt-pip-btn:hover {
    background: rgba(255, 255, 255, .14);
    color: #fff;
}

#kbt-frame-wrap {
    flex: 1;
    position: relative;
    background: #000;
    min-height: 0;
}

#kbt-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
}

#kbt-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: rgba(255, 255, 255, .3);
    font-size: 14px;
}

#kbt-placeholder .kbt-tv-icon {
    font-size: 64px;
    opacity: .2;
}

/* ── Fullscreen standalone ── */
/* ── Standalone (fenêtre popup) ── */
body.kbt-standalone,
html.kbt-standalone {
    background: var(--kbt-bg, #0d0d14);
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

body.kbt-standalone #kbt-app {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--kbt-bg, #0d0d14);
}

body.kbt-standalone #kbt-overlay {
    display: flex !important;
    position: static;
    flex: 1;
    background: none;
    backdrop-filter: none;
    width: 100%;
    height: 100%;
}


body.kbt-standalone #kbt-modal {
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-width: none;
    max-height: none;
}

body.kbt-standalone #kbt-close {
    display: none;
}

body.kbt-standalone #kbt-titlebar .kbt-popup-hint {
    display: none;
}

/* ── Responsive ── */
@media (max-width: 700px) {
    #kbt-modal {
        flex-direction: column;
        max-height: none;
        height: 100dvh;
    }

    #kbt-sidebar {
        width: 100%;
        min-width: 0;
        height: 160px;
        flex-direction: row;
        overflow-x: auto;
    }

    #kbt-list {
        display: flex;
        flex-direction: row;
    }

    .kbt-ch {
        min-width: 120px;
        flex-direction: column;
        text-align: center;
    }
}