/* ────────────────────────────────────────────────────────────────────────
   Nokib Live TV — web client styles.

   Tokens (mirrored from Android res/values/colors.xml + dimens.xml so the
   web and Android apps feel identical):
     - Brand:    indigo-500 / indigo-300 / indigo-900
     - Surfaces: slate-950 / slate-900 / slate-800
     - Text:     slate-50 (primary) / slate-400 (secondary)
     - Status:   green-500 (active) / slate-500 (inactive)
   ──────────────────────────────────────────────────────────────────────── */

:root {
    --brand-color:        #0F1E3D;
    --brand-accent:       #6366F1;
    --brand-accent-dim:   #A5B4FC;
    --brand-accent-soft:  #312E81;

    --bg:                 #020617;
    --surface-card:       #0F172A;
    --surface-card-hi:    #1E293B;
    --surface-divider:    #1E293B;

    --text-primary:       #F8FAFC;
    --text-secondary:     #94A3B8;
    --search-color:       #FFFFFF;

    --status-active:      #22C55E;
    --status-inactive:    #64748B;

    --player-bg:          #000000;

    /* Layout split (matches Android LinearLayout weightSum=4, sidebar=1, player=3) */
    --sidebar-weight:     1;
    --player-weight:      3;

    /* Dimens translated to rem (1dp = 0.0625rem at 16px base) */
    --topbar-h:           4.5rem;     /* 72dp */
    --row-h:              5.5rem;     /* 88dp */
    --logo-size:          3.5rem;     /* 56dp */
    --logo-radius:        0.625rem;   /* 10dp */
    --fs-btn-size:        2.75rem;    /* 44dp */
    --fs-btn-margin:      1.5rem;     /* 24dp */
    --focus-scale:        1.03;

    --sidebar-min-w:      22rem;
    --player-min-w:       36rem;

    --shadow-focus:       0 0 0 2px var(--brand-accent), 0 8px 24px rgba(99, 102, 241, 0.25);
}

/* ────────── Reset ────────── */

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
                 Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button { font: inherit; cursor: pointer; }

input[type="search"]::-webkit-search-cancel-button { display: none; }

::selection { background: var(--brand-accent-soft); color: var(--text-primary); }

/* ────────── Layout ────────── */

.layout {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    background: var(--bg);
}

/* ────────── Sidebar ────────── */

.sidebar {
    flex: var(--sidebar-weight) 1 0;
    min-width: var(--sidebar-min-w);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
    transition: opacity 160ms ease, flex-basis 160ms ease;
}

.divider {
    width: 1px;
    flex: 0 0 1px;
    background: var(--surface-divider);
    transition: opacity 160ms ease, width 160ms ease;
}

.topbar {
    flex: 0 0 auto;
    padding: 1rem 1.5rem;       /* 16dp / 24dp */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-bottom: 1px solid var(--surface-divider);
    background: linear-gradient(180deg, rgba(15, 30, 61, 0.6) 0%, rgba(2, 6, 23, 0) 100%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand__mark {
    width: 2.75rem;              /* 44dp */
    height: 2.75rem;
    border-radius: 50%;
    background: var(--brand-accent-soft);
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 1px rgba(165, 180, 252, 0.12);
}

.brand__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.brand__subtitle {
    margin: 0.125rem 0 0 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Search field — same look as Android drawable/bg_search_field.xml */
.search {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-card);
    border: 1px solid var(--surface-card-hi);
    border-radius: 9999px;
    height: 2.75rem;              /* 44dp (slightly tighter than Android's 48dp) */
    padding: 0 1rem 0 2.5rem;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search:focus-within {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search__icon {
    position: absolute;
    left: 0.875rem;
    pointer-events: none;
}

.search__input {
    flex: 1 1 auto;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--search-color);
    font-size: 0.9375rem;
    height: 100%;
    min-width: 0;
}

.search__input::placeholder { color: var(--text-secondary); }

/* Channel list */

.channel-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0.75rem 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-card-hi) transparent;
}

.channel-list::-webkit-scrollbar { width: 10px; }
.channel-list::-webkit-scrollbar-thumb { background: var(--surface-card-hi); border-radius: 9999px; }
.channel-list::-webkit-scrollbar-track { background: transparent; }

.channel-list:focus { outline: none; }

.channel {
    list-style: none;
    display: grid;
    grid-template-columns: var(--logo-size) 1fr auto;
    align-items: center;
    gap: 0.875rem;
    height: var(--row-h);
    padding: 0 0.875rem;
    margin: 0.25rem 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
    outline: none;
}

.channel:hover {
    background: var(--surface-card);
}

.channel:focus,
.channel:focus-visible {
    outline: none;
    background: var(--surface-card);
    border-color: var(--surface-card-hi);
    transform: scale(var(--focus-scale));
    box-shadow: var(--shadow-focus);
}

.channel.is-selected {
    background: var(--surface-card);
    border-color: var(--brand-accent-soft);
}

.channel.is-selected .channel__name {
    color: var(--brand-accent-dim);
}

.channel.is-selected .channel__dot {
    background: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.channel__logo {
    width: var(--logo-size);
    height: var(--logo-size);
    border-radius: var(--logo-radius);
    object-fit: cover;
    background: var(--surface-card-hi);
    display: block;
}

.channel__logo--placeholder {
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    font-size: 1.5rem;
    font-weight: 700;
}

.channel__logo--placeholder svg { width: 28px; height: 28px; }

.channel__text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.channel__name {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel__group {
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel__dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--status-active);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.empty-state {
    margin: 1.5rem;
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.875rem;
}

/* ────────── Player pane ────────── */

.player-pane {
    flex: var(--player-weight) 1 0;
    min-width: var(--player-min-w);
    background: var(--player-bg);
    position: relative;
    overflow: hidden;
}

.player-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--player-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.player-wrapper:focus { outline: none; }

.video {
    width: 100%;
    height: 100%;
    background: var(--player-bg);
    object-fit: contain;
    outline: none;
}

/* Channel name overlay (top-left) */
.player-overlay {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.625rem 0.875rem;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 0.625rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
    max-width: calc(100% - 6rem);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.player-overlay.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.player-overlay__name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-overlay__group {
    font-size: 0.75rem;
    color: var(--brand-accent-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Fullscreen toggle button (top-right) */
.fullscreen-btn {
    position: absolute;
    top: var(--fs-btn-margin);
    right: var(--fs-btn-margin);
    width: var(--fs-btn-size);
    height: var(--fs-btn-size);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-primary);
    display: grid;
    place-items: center;
    padding: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background-color 140ms ease, transform 140ms ease, border-color 140ms ease;
    z-index: 4;
}

.fullscreen-btn:hover { background: rgba(30, 41, 59, 0.9); border-color: rgba(255, 255, 255, 0.3); }
.fullscreen-btn:focus { outline: none; transform: scale(1.05); box-shadow: var(--shadow-focus); }
.fullscreen-btn:active { transform: scale(0.96); }

/* Buffering indicator (centered) */
.buffering {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: rgba(2, 6, 23, 0.6);
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
    z-index: 3;
}

.buffering__spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid rgba(165, 180, 252, 0.2);
    border-top-color: var(--brand-accent-dim);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.buffering__text {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ────────── Fullscreen state ────────── */
/*
   When the user toggles fullscreen (button, F11, or Esc), <body> gets
   .fullscreen-on. We hide the sidebar + divider, and the player pane
   naturally fills the row.
*/
.fullscreen-on .sidebar { display: none; }
.fullscreen-on .divider { display: none; }

/* ────────── Small screens ────────── */

@media (max-width: 900px) {
    :root {
        --sidebar-min-w: 16rem;
        --player-min-w:  20rem;
    }
    .topbar { padding: 0.75rem 1rem; }
    .brand__title { font-size: 1.0625rem; }
}

@media (max-width: 640px) {
    .layout { flex-direction: column; }
    .sidebar { flex: 0 0 auto; max-height: 40vh; }
    .divider { width: 100%; height: 1px; }
    .player-pane { flex: 1 1 auto; }
}
