/* ════════════════════════════════════════════════
   YT Playlist Player — Frontend Styles
   ════════════════════════════════════════════════ */

.ytpp-root {
    --ytpp-accent:      #ff2d55;
    --ytpp-accent2:     #ff6b35;
    --ytpp-radius:      10px;
    --ytpp-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-family:        var(--ytpp-font);
    position:           relative;
    width:              100%;
    overflow:           hidden;
    border-radius:      var(--ytpp-radius);
    box-shadow:         0 8px 40px rgba(0,0,0,.35);
}

/* ── THEMES ── */
.ytpp-root.ytpp-dark  { --bg: #0e0e14; --surface: #16161f; --surface2: #1e1e2a; --border: rgba(255,255,255,.07); --text: #f0f0f5; --muted: #6b6b85; }
.ytpp-root.ytpp-light { --bg: #f5f5f8; --surface: #ffffff; --surface2: #f0f0f5; --border: rgba(0,0,0,.08); --text: #111118; --muted: #888899; }

.ytpp-root { background: var(--bg); color: var(--text); }

/* ── LAYOUT: SIDEBAR ── */
.ytpp-root.ytpp-layout-sidebar .ytpp-inner {
    display:               grid;
    grid-template-columns: 1fr var(--ytpp-sidebar, 340px);
    grid-template-rows:    var(--ytpp-height, 480px) auto;
    height:                calc(var(--ytpp-height, 480px) + 56px);
}

.ytpp-root.ytpp-layout-sidebar .ytpp-video    { grid-column: 1; grid-row: 1; }
.ytpp-root.ytpp-layout-sidebar .ytpp-now-bar  { grid-column: 1; grid-row: 2; }
.ytpp-root.ytpp-layout-sidebar .ytpp-playlist { grid-column: 2; grid-row: 1 / span 2; border-left: 1px solid var(--border); }

/* ── LAYOUT: BOTTOM ── */
.ytpp-root.ytpp-layout-bottom .ytpp-inner {
    display:        flex;
    flex-direction: column;
}
.ytpp-root.ytpp-layout-bottom .ytpp-video    { height: var(--ytpp-height, 480px); flex-shrink: 0; }
.ytpp-root.ytpp-layout-bottom .ytpp-playlist { max-height: 280px; border-top: 1px solid var(--border); }
.ytpp-root.ytpp-layout-bottom .ytpp-now-bar  { display: none; }

/* ── LAYOUT: MINIMAL ── */
.ytpp-root.ytpp-layout-minimal .ytpp-inner    { display: flex; flex-direction: column; }
.ytpp-root.ytpp-layout-minimal .ytpp-video    { height: var(--ytpp-height, 480px); flex-shrink: 0; }
.ytpp-root.ytpp-layout-minimal .ytpp-playlist { display: none; }
.ytpp-root.ytpp-layout-minimal .ytpp-now-bar  { display: flex; }

/* ── VIDEO AREA ── */
.ytpp-video {
    background: #000;
    position:   relative;
    overflow:   hidden;
}

.ytpp-video iframe {
    display:  block;
    width:    100%;
    height:   100%;
    border:   none;
}

/* ── NOW BAR ── */
.ytpp-now-bar {
    display:     flex;
    align-items: center;
    gap:         12px;
    padding:     10px 16px;
    background:  var(--surface);
    border-top:  1px solid var(--border);
    min-height:  56px;
}

.ytpp-now-thumb {
    width:         60px;
    height:        38px;
    border-radius: 5px;
    object-fit:    cover;
    flex-shrink:   0;
    background:    var(--surface2);
}

.ytpp-now-info { flex: 1; overflow: hidden; }

.ytpp-now-title {
    font-size:     13px;
    font-weight:   600;
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
    color:         var(--text);
}

.ytpp-now-channel {
    font-size:     11px;
    color:         var(--muted);
    margin-top:    2px;
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
}

.ytpp-now-badge {
    display:       flex;
    align-items:   center;
    gap:           5px;
    background:    rgba(255,45,85,.12);
    border:        1px solid rgba(255,45,85,.3);
    border-radius: 999px;
    padding:       4px 10px;
    font-size:     10px;
    font-weight:   700;
    color:         var(--ytpp-accent);
    letter-spacing:.06em;
    flex-shrink:   0;
    text-transform:uppercase;
}

.ytpp-now-badge .ytpp-dot {
    width:         6px;
    height:        6px;
    background:    var(--ytpp-accent);
    border-radius: 50%;
    animation:     ytpp-pulse 1.2s ease-in-out infinite;
}

/* ── PLAYLIST SIDEBAR/LIST ── */
.ytpp-playlist {
    display:        flex;
    flex-direction: column;
    background:     var(--surface);
    overflow:       hidden;
}

.ytpp-pl-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         12px 14px 10px;
    border-bottom:   1px solid var(--border);
    flex-shrink:     0;
}

.ytpp-pl-header-title {
    font-size:   11px;
    font-weight: 700;
    letter-spacing:.05em;
    text-transform:uppercase;
    color:       var(--text);
}

.ytpp-pl-count {
    font-size:     10px;
    color:         var(--muted);
    background:    var(--surface2);
    border-radius: 999px;
    padding:       2px 8px;
}

.ytpp-pl-name {
    padding:       8px 14px;
    font-size:     11px;
    color:         var(--muted);
    border-bottom: 1px solid var(--border);
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
    flex-shrink:   0;
}

.ytpp-pl-scroll {
    flex:     1;
    overflow-y: auto;
    padding:  6px 0;
}

.ytpp-pl-scroll::-webkit-scrollbar { width: 3px; }
.ytpp-pl-scroll::-webkit-scrollbar-track { background: transparent; }
.ytpp-pl-scroll::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 2px; }

/* ── PLAYLIST ITEM ── */
.ytpp-pl-item {
    display:       grid;
    grid-template-columns: 22px 90px 1fr;
    align-items:   center;
    gap:           8px;
    padding:       7px 10px;
    cursor:        pointer;
    border-radius: 7px;
    margin:        0 5px 2px;
    transition:    background .12s;
    border:        1px solid transparent;
}

.ytpp-pl-item:hover  { background: var(--surface2); }
.ytpp-pl-item.active { background: rgba(255,45,85,.08); border-color: rgba(255,45,85,.25); }

.ytpp-pl-index {
    font-size:   10px;
    color:       var(--muted);
    text-align:  center;
}

.ytpp-pl-item.active .ytpp-pl-index   { display: none; }
.ytpp-pl-item.active .ytpp-pl-eq      { display: flex; }

.ytpp-pl-eq {
    display:      none;
    align-items:  flex-end;
    gap:          2px;
    height:       14px;
    justify-content: center;
}

.ytpp-pl-eq span {
    width:         3px;
    background:    var(--ytpp-accent);
    border-radius: 2px;
    animation:     ytpp-eq .8s ease-in-out infinite;
    animation-play-state: paused;  /* démarré en pause, JS active quand ça joue vraiment */
}
.ytpp-pl-eq span:nth-child(2) { animation-delay: .2s; }
.ytpp-pl-eq span:nth-child(3) { animation-delay: .4s; }

@keyframes ytpp-eq {
    0%,100% { height: 3px; }
    50%     { height: 12px; }
}

.ytpp-pl-thumb-wrap {
    position:      relative;
    width:         90px;
    height:        52px;
    border-radius: 5px;
    overflow:      hidden;
    flex-shrink:   0;
    background:    var(--surface2);
}

.ytpp-pl-thumb {
    width:      100%;
    height:     100%;
    object-fit: cover;
    display:    block;
}

.ytpp-pl-thumb-overlay {
    position:   absolute;
    inset:      0;
    background: rgba(0,0,0,.5);
    display:    flex;
    align-items:center;
    justify-content:center;
    opacity:    0;
    transition: opacity .12s;
}

.ytpp-pl-item:hover  .ytpp-pl-thumb-overlay { opacity: 1; }
.ytpp-pl-item.active .ytpp-pl-thumb-overlay { opacity: 1; background: rgba(255,45,85,.4); }

.ytpp-play-btn {
    width:         22px;
    height:        22px;
    background:    rgba(255,255,255,.9);
    border-radius: 50%;
    display:       flex;
    align-items:   center;
    justify-content:center;
}

.ytpp-play-btn svg { margin-left: 2px; }

.ytpp-pl-meta { overflow: hidden; }

.ytpp-pl-title {
    font-size:   12px;
    font-weight: 600;
    color:       var(--text);
    line-height: 1.3;
    display:     -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow:    hidden;
}

.ytpp-pl-item.active .ytpp-pl-title { color: var(--ytpp-accent); }

.ytpp-pl-channel {
    font-size:     10px;
    color:         var(--muted);
    margin-top:    3px;
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
}

/* ── FACADE (click-to-play) ── */
.ytpp-facade {
    position:   absolute;
    inset:      0;
    cursor:     pointer;
    z-index:    5;
    overflow:   hidden;
    border-radius: inherit;
}

.ytpp-facade-bg {
    position:            absolute;
    inset:               0;
    background-size:     cover;
    background-position: center;
    transition:          transform .4s ease;
}
.ytpp-facade:hover .ytpp-facade-bg { transform: scale(1.04); }

.ytpp-facade-overlay {
    position:   absolute;
    inset:      0;
    background: linear-gradient(to top, rgba(0,0,0,.7) 0%, rgba(0,0,0,.15) 60%, transparent 100%);
    transition: background .3s;
}
.ytpp-facade:hover .ytpp-facade-overlay { background: linear-gradient(to top, rgba(0,0,0,.8) 0%, rgba(0,0,0,.25) 60%, rgba(0,0,0,.1) 100%); }

/* Central play button */
.ytpp-facade-btn {
    position:        absolute;
    top:             50%;
    left:            50%;
    transform:       translate(-50%, -52%);
    width:           72px;
    height:          72px;
    background:      rgba(255,255,255,.95);
    border:          none;
    border-radius:   50%;
    display:         flex;
    align-items:     center;
    justify-content: center;
    cursor:          pointer;
    transition:      transform .2s, background .2s, box-shadow .2s;
    box-shadow:      0 4px 32px rgba(0,0,0,.5);
}
.ytpp-facade:hover .ytpp-facade-btn {
    transform:   translate(-50%, -52%) scale(1.1);
    background:  var(--ytpp-accent, #ff6c00);
    box-shadow:  0 8px 40px rgba(0,0,0,.6);
}

.ytpp-facade-icon {
    width:       30px;
    height:      30px;
    color:       var(--ytpp-accent, #ff6c00);
    margin-left: 4px;
    transition:  color .2s;
}
.ytpp-facade:hover .ytpp-facade-icon { color: #fff; }

/* Loading spinner replaces play icon */
.ytpp-facade-spinner {
    width:         26px;
    height:        26px;
    border:        3px solid rgba(0,0,0,.15);
    border-top-color: var(--ytpp-accent, #ff6c00);
    border-radius: 50%;
    animation:     ytpp-spin .7s linear infinite;
}
@keyframes ytpp-spin { to { transform: rotate(360deg); } }

/* Title overlay */
.ytpp-facade-title {
    position:      absolute;
    bottom:        0;
    left:          0;
    right:         0;
    padding:       28px 18px 16px;
    font-size:     14px;
    font-weight:   600;
    color:         #fff;
    font-family:   var(--ytpp-font);
    line-height:   1.3;
    background:    linear-gradient(transparent, rgba(0,0,0,.6));
    display:       -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow:      hidden;
    text-shadow:   0 1px 4px rgba(0,0,0,.5);
}

/* Loading state */
.ytpp-facade.ytpp-facade-loading .ytpp-facade-btn { background: rgba(255,255,255,.9); }
.ytpp-facade.ytpp-facade-loading .ytpp-facade-bg  { filter: brightness(.7); }

/* Pulsing ring animation on load */
.ytpp-facade-btn::after {
    content:       '';
    position:      absolute;
    inset:         -8px;
    border-radius: 50%;
    border:        2px solid rgba(255,255,255,.3);
    animation:     ytpp-pulse-ring 2s ease-out infinite;
}
@keyframes ytpp-pulse-ring {
    0%   { opacity: .8; transform: scale(1); }
    100% { opacity: 0;  transform: scale(1.35); }
}

/* ── NO API KEY MESSAGE ── */
.ytpp-no-api {
    padding:     20px 16px;
    font-size:   12px;
    color:       var(--muted);
    line-height: 1.7;
    text-align:  center;
}

.ytpp-no-api strong { color: var(--text); }

/* ── ERROR ── */
.ytpp-error {
    background:    rgba(255,45,85,.1);
    border:        1px solid rgba(255,45,85,.3);
    border-radius: 8px;
    padding:       12px 16px;
    font-size:     13px;
    color:         #ff2d55;
}

/* ── ANIMATIONS ── */
@keyframes ytpp-pulse {
    0%,100% { opacity:1; transform:scale(1); }
    50%     { opacity:.3; transform:scale(.6); }
}

/* ── RESPONSIVE ── */
@media (max-width: 680px) {
    .ytpp-root.ytpp-layout-sidebar .ytpp-inner {
        display:        flex;
        flex-direction: column;
        height:         auto;
    }
    .ytpp-root.ytpp-layout-sidebar .ytpp-video    { height: 56vw; min-height: 180px; }
    .ytpp-root.ytpp-layout-sidebar .ytpp-playlist { border-left: none; border-top: 1px solid var(--border); max-height: 280px; }
    .ytpp-root.ytpp-layout-sidebar .ytpp-now-bar  { display: none; }
}

/* ════════════════════════════════════════════════
   STICKMAN BAR
   ════════════════════════════════════════════════ */
.ytpp-stickman-bar {
    position:   relative;
    width:      100%;
    height:     80px;
    background: #1c2023;
    overflow:   visible;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.07));
}

.ytpp-stickman-canvas {
    display:  block;
    width:    100%;
    height:   80px;
}

/* Mic button — discreet top-right corner */
.ytpp-stickman-mic {
    position:    absolute;
    top:         6px;
    right:       8px;
    background:  rgba(255,255,255,.08);
    border:      1px solid rgba(255,255,255,.15);
    border-radius: 999px;
    color:       rgba(255,255,255,.5);
    padding:     4px 9px 4px 7px;
    font-size:   10px;
    cursor:      pointer;
    display:     flex;
    align-items: center;
    gap:         4px;
    transition:  background .15s, color .15s;
    font-family: var(--ytpp-font);
    white-space: nowrap;
    z-index:     5;
}
.ytpp-stickman-mic::after {
    content: 'son';
}
.ytpp-stickman-mic:hover {
    background: rgba(255,255,255,.15);
    color:      #fff;
}

/* Light theme — same dark bar, no invert needed */
.ytpp-root.ytpp-light .ytpp-stickman-bar {
    background: #1c2023;
}
.ytpp-root.ytpp-light .ytpp-stickman-mic {
    background: rgba(0,0,0,.06);
    border-color: rgba(0,0,0,.15);
    color: rgba(0,0,0,.5);
}
.ytpp-root.ytpp-light .ytpp-stickman-mic:hover {
    background: rgba(0,0,0,.1);
    color: #000;
}
