/* ============================================================================
 * YTP — Site styles
 *
 * NOTE: this file is served STATICALLY (not via F3). Do not use
 * `{{ @dir == 'rtl' ? ... }}` style expressions — they won't be processed.
 * Use `[dir="rtl"]` selectors for direction-specific rules instead.
 *
 * @created 2026-05-15
 * ============================================================================ */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Heebo', 'Arial', sans-serif;
    background: #f4f6fa;
    color: #2c3e50;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Navbar ─── */
.ytp-navbar {
    background: linear-gradient(135deg, #c4302b 0%, #ff6b6b 100%) !important;
    color: #fff !important;
    min-height: 56px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    position: sticky;
    top: 0;
    z-index: 100;
}
.ytp-navbar .w3-bar-item { color: #fff !important; }
.ytp-navbar .w3-button:hover { background: rgba(255,255,255,.12) !important; }
.ytp-navbar .ytp-active {
    background: rgba(255,255,255,.18) !important;
    box-shadow: inset 0 -3px 0 #fff;
}

/* ─── Main / Layout ─── */
.ytp-main {
    flex: 1;
    padding: 14px 12px 80px;
}
.ytp-rcol-wrap { padding: 6px; }
.ytp-page-body { padding: 6px 10px; }

/* Pin page-body content to the RCOL edge (LTR → left, RTL → right). */
.ytp-rcol-aligned {
    max-width: 1000px;
    margin-left: 0;
    margin-right: auto;
}
[dir="rtl"] .ytp-rcol-aligned {
    margin-left: auto;
    margin-right: 0;
}

/* ─── Stats (RCOL list) ─── */
.ytp-stat-list { display: flex; flex-direction: column; gap: 6px; }
.ytp-stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid #c4302b;
}
[dir="rtl"] .ytp-stat-row { border-left: 0; border-right: 3px solid #c4302b; }
.ytp-stat-ico {
    width: 28px; height: 28px;
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85em;
}
.ytp-stat-lbl { flex: 1; font-size: .95em; }
.ytp-stat-num { font-weight: bold; color: #2c3e50; font-family: monospace; }

/* ─── Stats (home circles) ─── */
.ytp-stat-circles {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
.ytp-stat-circ {
    width: 90px; height: 90px;
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: .8em;
    line-height: 1.2;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.ytp-stat-circ b { font-size: 1.5em; margin: 2px 0; }
.ytp-stat-circ span { font-size: .85em; opacity: .92; }

/* ─── Footer (reserves space for the fixed bottom utility bar) ─── */
.ytp-footer {
    background: #2c3e50;
    color: #ecf0f1;
    margin-top: auto;
    padding-bottom: 48px;
}
.ytp-footer-link { color: #5dade2; text-decoration: none; }
.ytp-footer-link:hover { text-decoration: underline; }

/* ─── Bottom utility bar ─── */
.ytp-bottom-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(44,62,80,.92);
    padding: 6px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 50;
    height: 40px;
    box-sizing: border-box;
}
.ytp-bb-btn {
    color: #fff;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(255,255,255,.08);
    font-size: 1.1em;
}
.ytp-bb-btn:hover { background: rgba(255,255,255,.18); }

/* ─── Tables ─── */
.w3-responsive { overflow-x: auto; }

/* ─── Admin section cards (dashboard grid) ─── */
.ytp-admin-card {
    display: block;
    padding: 14px;
    margin: 6px;
    background: #fff;
    border-radius: 10px;
    text-decoration: none;
    color: #2c3e50;
    border-left: 4px solid var(--c, #c4302b);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    transition: transform .12s ease, box-shadow .12s ease;
    position: relative;
    min-height: 64px;
}
[dir="rtl"] .ytp-admin-card { border-left: 0; border-right: 4px solid var(--c, #c4302b); }
.ytp-admin-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,.13);
    color: var(--c, #c4302b);
}
.ytp-admin-card i { color: var(--c, #c4302b); margin-right: 6px; }
[dir="rtl"] .ytp-admin-card i { margin-right: 0; margin-left: 6px; }
.ytp-admin-card-cnt {
    position: absolute;
    top: 10px;
    right: 12px;
    font-family: monospace;
    font-weight: bold;
    font-size: 1.1em;
    color: var(--c, #c4302b);
}
[dir="rtl"] .ytp-admin-card-cnt { right: auto; left: 12px; }

/* ─── JSON-meta rendering (output of decorateMeta) ─── */
.ytp-mval-row { line-height: 1.5; padding: 1px 0; }
.ytp-mval-k {
    color: #7f8c8d;
    font-weight: 600;
    margin-right: 4px;
}
[dir="rtl"] .ytp-mval-k { margin-right: 0; margin-left: 4px; }
.ytp-mval-row a { color: #c4302b; text-decoration: none; }
.ytp-mval-row a:hover { text-decoration: underline; }

/* ─── Tech docs ─── */
.ytp-tech-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: #2c3e50;
}
.ytp-tech-item:last-child { border-bottom: 0; }
.ytp-tech-item:hover { background: #f8fafc; }
.ytp-tech-item i { color: #c4302b; }
.ytp-tech-title { flex: 1; font-weight: 600; }
.ytp-tech-meta { color: #95a5a6; font-size: .85em; font-family: monospace; }

.ytp-md-doc {
    background: #fff;
    border-radius: 10px;
    padding: 22px 26px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    line-height: 1.65;
    font-size: 1em;
}
.ytp-md-doc h1, .ytp-md-doc h2,
.ytp-md-doc h3, .ytp-md-doc h4 {
    color: #c4302b; margin-top: 1.2em;
}
.ytp-md-doc h1 { border-bottom: 2px solid #e6f0fa; padding-bottom: .25em; }
.ytp-md-doc pre {
    background: #f5f7fa; padding: 10px 14px; border-radius: 6px;
    overflow-x: auto; font-size: .9em;
}
.ytp-md-doc code {
    background: #eef2f7; padding: 1px 5px; border-radius: 3px;
    font-size: .92em; font-family: 'Consolas', monospace;
}
.ytp-md-doc pre code { background: transparent; padding: 0; }
.ytp-md-doc table { border-collapse: collapse; margin: .8em 0; }
.ytp-md-doc th, .ytp-md-doc td { border: 1px solid #d6e0ea; padding: 6px 10px; }
.ytp-md-doc th { background: #f4f8fc; }
.ytp-md-doc blockquote {
    border-left: 4px solid #ff6b6b; margin: .8em 0; padding: .2em 1em;
    background: #f8fbff; color: #4a6478;
}
[dir="rtl"] .ytp-md-doc blockquote {
    border-left: 0; border-right: 4px solid #ff6b6b;
}

/* ─── RTL tweaks ─── */
body[dir="rtl"] .w3-bar-item { float: right; }
body[dir="rtl"] .w3-bar .w3-left { float: left; }

/* ─── Public — playlist grid tiles ─── */
.ytp-pl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    padding: 4px;
}
.ytp-pl-tile {
    display: block;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: #2c3e50;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    transition: transform .12s, box-shadow .12s;
}
.ytp-pl-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 14px rgba(0,0,0,.14);
}
.ytp-pl-thumb {
    aspect-ratio: 16/9;
    background-size: cover;
    background-position: center;
    background-color: #ddd;
    position: relative;
}
.ytp-pl-count {
    position: absolute;
    bottom: 6px;
    right: 8px;
    background: rgba(0,0,0,.75);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .85em;
}
[dir="rtl"] .ytp-pl-count { right: auto; left: 8px; }
.ytp-pl-meta { padding: 8px 10px; }
.ytp-pl-title {
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ytp-pl-channel {
    font-size: .85em;
    color: #888;
    margin-top: 4px;
}

/* ─── Public — search / video list rows ─── */
.ytp-vid-list { display: flex; flex-direction: column; gap: 6px; }
.ytp-vid-row {
    display: flex;
    gap: 10px;
    padding: 8px;
    background: #fff;
    border-radius: 8px;
    text-decoration: none;
    color: #2c3e50;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.ytp-vid-row:hover { background: #fdf3f2; }
.ytp-vid-thumb {
    flex: 0 0 160px;
    aspect-ratio: 16/9;
    background-size: cover;
    background-position: center;
    background-color: #ddd;
    border-radius: 4px;
}
.ytp-vid-info { flex: 1; min-width: 0; }
.ytp-vid-title { font-weight: 600; line-height: 1.3; }
.ytp-vid-artist { color: #c4302b; font-size: .92em; margin-top: 2px; }
.ytp-vid-credits {
    color: #666;
    font-size: .85em;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ytp-vid-meta { color: #999; font-size: .8em; margin-top: 4px; }

/* ─── Player page — sticky player + scrollable list ─── */
.ytp-pl-page { display: flex; flex-direction: column; height: calc(100vh - 110px); }
.ytp-player-stack {
    position: sticky; top: 56px; z-index: 20;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,.10);
    margin-bottom: 10px;
}
.ytp-player-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.ytp-np-cover {
    width: 100px; height: 100px;
    object-fit: cover;
    border-radius: 6px;
    background: #f0f0f0;
    flex-shrink: 0;
}
.ytp-player-center { flex: 1; min-width: 0; display: flex; gap: 14px; }
.ytp-player-stack.ytp-mode-bg #youtube-player {
    width: 1px; height: 1px;
    position: absolute;
    overflow: hidden;
    opacity: 0;
}
.ytp-player-stack.ytp-mode-std #youtube-player {
    width: 280px; height: 158px;
    flex-shrink: 0;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
}
.ytp-np-text { flex: 1; min-width: 0; }
.ytp-np-title  { font-size: 1.15em; font-weight: 700; color: #c4302b; line-height: 1.3; }
.ytp-np-artist { color: #1f6feb; margin-top: 4px; font-weight: 600; }
.ytp-np-credits { color: #666; font-size: .9em; margin-top: 4px; }

/* Controls row */
.ytp-progress-row, .ytp-toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.ytp-ctrl-btn {
    background: #1f6feb;
    color: #fff;
    border: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .9em;
}
.ytp-ctrl-btn:hover { background: #155bb5; }
.ytp-ctrl-btn.ytp-ctrl-play { background: #c4302b; }
.ytp-ctrl-btn.ytp-ctrl-play:hover { background: #9c2620; }
.ytp-ctrl-btn.ytp-ctrl-info { background: #f0883e; }
.ytp-seek {
    flex: 1;
    accent-color: #c4302b;
    height: 6px;
}
.ytp-time { font-family: monospace; color: #555; min-width: 42px; text-align: center; font-size: .9em; }
.ytp-filter-input {
    flex: 0 1 220px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: .95em;
}
.ytp-sort-btn {
    background: #f4f6fa;
    border: 1px solid #d0d7de;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .9em;
    color: #555;
}
.ytp-sort-btn:hover { background: #fdf3f2; }
.ytp-sort-btn.is-active { background: #c4302b; color: #fff; border-color: #c4302b; }
.ytp-filter-status { color: #888; font-size: .85em; margin-inline-start: auto; }

/* Track scroll container */
.ytp-track-scroll {
    flex: 1;
    overflow-y: auto;
    border-radius: 8px;
    padding: 4px;
    background: #f9fafc;
    border: 1px solid #e5e7eb;
}
.ytp-track-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: track;
}
.ytp-track {
    display: flex;
    gap: 10px;
    padding: 6px 8px;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background .12s;
}
.ytp-track::before {
    counter-increment: track;
    content: counter(track);
    flex: 0 0 26px;
    text-align: center;
    color: #999;
    font-family: monospace;
    align-self: center;
}
.ytp-track:hover { background: #fdf3f2; }
.ytp-track.is-active {
    background: #fff5f5;
    box-shadow: inset 0 0 0 2px #c4302b;
}
.ytp-track-thumb {
    flex: 0 0 80px;
    aspect-ratio: 16/9;
    background-size: cover;
    background-position: center;
    background-color: #ddd;
    border-radius: 3px;
}
.ytp-track-info { flex: 1; min-width: 0; }
.ytp-track-title { font-weight: 600; line-height: 1.3; }
.ytp-track-artist { color: #c4302b; font-size: .9em; }
.ytp-track-credits { color: #666; font-size: .82em; }
.ytp-track-dur { color: #999; font-family: monospace; font-size: .9em; align-self: center; }

/* Modals */
.ytp-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ytp-modal.is-open { display: flex; }
.ytp-modal-box {
    background: #fff;
    border-radius: 10px;
    padding: 20px 24px;
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}
.ytp-modal-close {
    position: absolute;
    top: 8px;
    inset-inline-end: 14px;
    font-size: 1.8em;
    color: #888;
    cursor: pointer;
    line-height: 1;
}
.ytp-modal-close:hover { color: #c4302b; }

/* ─── Admin sub-nav ─── */
.ytp-admin-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
    margin-bottom: 8px;
}
.ytp-subnav-link {
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: #555;
    font-size: .92em;
}
.ytp-subnav-link:hover { background: #f4f6fa; color: #c4302b; }
.ytp-subnav-link.is-active {
    background: #c4302b;
    color: #fff;
}
.ytp-subnav-link.ytp-subnav-cta {
    background: #fff5f5;
    color: #c4302b;
    font-weight: bold;
}
.ytp-subnav-link.ytp-subnav-cta.is-active {
    background: #c4302b;
    color: #fff;
}

/* ─── Status badges ─── */
.ytp-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: .8em;
    font-weight: bold;
    color: #fff;
}
.ytp-status-A { background: #2ea043; }
.ytp-status-U { background: #999; }
.ytp-status-H { background: #555; }
.ytp-status-R { background: #f0883e; }

/* ─── Mobile ─── */
@media (max-width: 600px) {
    .ytp-stat-circ { width: 70px; height: 70px; font-size: .7em; }
    .ytp-stat-circ b { font-size: 1.2em; }
    .ytp-admin-subnav { flex-direction: column; }
    .ytp-player-wrap { flex-direction: column; }
    .ytp-player-wrap.ytp-mode-std #youtube-player { flex-basis: auto; width: 100%; }
    .ytp-vid-thumb { flex: 0 0 100px; }
}
