/* ================================================================
 * SML Live Channels – Stylesheet
 * SML dark theme: --sml-bg #0f1117, --sml-surface #1a1d26,
 * --sml-border #2a2d3a, --sml-accent #22c55e, --sml-text #e2e8f0
 * ================================================================ */

:root {
    --lc-bg:        #0f1117;
    --lc-surface:   #1a1d26;
    --lc-surface2:  #22263a;
    --lc-border:    #2a2d3a;
    --lc-accent:    #22c55e;
    --lc-accent-dim:#166534;
    --lc-danger:    #ef4444;
    --lc-warn:      #f59e0b;
    --lc-text:      #e2e8f0;
    --lc-muted:     #94a3b8;
    --lc-host:      #a78bfa;
    --lc-speaker:   #38bdf8;
    --lc-listener:  #94a3b8;
    --lc-radius:    8px;
    --lc-shadow:    0 8px 32px rgba(0,0,0,0.5);
    --lc-transition:.15s ease;
}

/* ── Sidebar presence badges ──────────────────────────── */
.sml-live-badge {
    display:        inline-flex;
    align-items:    center;
    gap:            4px;
    font-size:      11px;
    color:          var(--lc-muted);
    padding:        1px 6px;
    border-radius:  10px;
    background:     transparent;
    transition:     all var(--lc-transition);
    margin-left:    6px;
}

.sml-live-badge.active {
    color:          var(--lc-accent);
    background:     rgba(34,197,94,.1);
}

.sml-live-dot {
    display:        inline-block;
    width:          6px;
    height:         6px;
    border-radius:  50%;
    background:     var(--lc-accent);
    animation:      lc-pulse 1.4s ease-in-out infinite;
}

@keyframes lc-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .6; transform: scale(.8); }
}

.sml-ch-live {
    color:          var(--lc-accent) !important;
}

/* ── Live Channel Panel ───────────────────────────────── */
.sml-live-panel {
    position:       fixed;
    bottom:         0;
    right:          0;
    width:          380px;
    max-height:     80vh;
    display:        flex;
    flex-direction: column;
    background:     var(--lc-surface);
    border:         1px solid var(--lc-border);
    border-radius:  var(--lc-radius) var(--lc-radius) 0 0;
    box-shadow:     var(--lc-shadow);
    z-index:        9999;
    overflow:       hidden;
    color:          var(--lc-text);
    font-family:    inherit;
}

@media (max-width: 480px) {
    .sml-live-panel {
        width:  100%;
        right:  0;
        left:   0;
    }
}

.sml-live-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         10px 14px;
    background:      var(--lc-bg);
    border-bottom:   1px solid var(--lc-border);
    flex-shrink:     0;
}

.sml-live-title {
    display:    flex;
    align-items:center;
    gap:        6px;
    font-weight:600;
    font-size:  14px;
    overflow:   hidden;
}

.sml-live-topic {
    font-size:  12px;
    color:      var(--lc-muted);
    overflow:   hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sml-live-header-actions {
    display: flex;
    gap:     6px;
    flex-shrink: 0;
}

.sml-live-settings-btn,
.sml-live-close {
    background:   transparent;
    border:       none;
    color:        var(--lc-muted);
    cursor:       pointer;
    font-size:    16px;
    padding:      2px 6px;
    border-radius:4px;
    transition:   color var(--lc-transition), background var(--lc-transition);
}

.sml-live-settings-btn:hover { color: var(--lc-text); background: var(--lc-border); }
.sml-live-close:hover         { color: var(--lc-danger); background: rgba(239,68,68,.1); }

.sml-live-loading {
    padding:    24px;
    text-align: center;
    color:      var(--lc-muted);
    font-size:  13px;
}

.sml-live-content {
    display:        flex;
    flex-direction: column;
    overflow:       hidden;
    flex:           1;
}

.sml-live-error {
    background: rgba(239,68,68,.12);
    border-left:3px solid var(--lc-danger);
    color:      var(--lc-danger);
    padding:    8px 12px;
    font-size:  12px;
    margin:     6px 10px;
    border-radius: 4px;
}

/* ── Screens area ─────────────────────────────────────── */
.sml-live-screens-area {
    padding:    8px;
    overflow-y: auto;
    max-height: 220px;
    display:    flex;
    flex-wrap:  wrap;
    gap:        6px;
    border-bottom: 1px solid var(--lc-border);
    scrollbar-width: thin;
    scrollbar-color: var(--lc-border) transparent;
}

.sml-no-screens {
    width:      100%;
    text-align: center;
    color:      var(--lc-muted);
    font-size:  12px;
    padding:    8px 0;
}

.sml-screen-card {
    flex:        1 1 160px;
    min-width:   140px;
    background:  var(--lc-surface2);
    border:      1px solid var(--lc-border);
    border-radius: 6px;
    overflow:    hidden;
    transition:  border-color var(--lc-transition);
}

.sml-screen-card.is-focused {
    border-color: var(--lc-accent);
    box-shadow:   0 0 0 2px rgba(34,197,94,.2);
}

.sml-screen-card.is-hidden {
    opacity: .4;
}

.sml-screen-header {
    display:     flex;
    align-items: center;
    gap:         4px;
    padding:     5px 8px;
    font-size:   11px;
    border-bottom: 1px solid var(--lc-border);
    background:  rgba(0,0,0,.2);
}

.sml-screen-slot  { color: var(--lc-muted); flex-shrink: 0; }
.sml-screen-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sml-screen-owner { color: var(--lc-muted); flex-shrink: 0; }

.sml-focused-badge {
    background:   var(--lc-accent);
    color:        #000;
    font-size:    10px;
    padding:      1px 5px;
    border-radius:10px;
    font-weight:  700;
}

.sml-screen-track {
    aspect-ratio: 16/9;
    background:   #0a0c14;
    display:      flex;
    align-items:  center;
    justify-content: center;
    color:        var(--lc-muted);
    font-size:    11px;
}

.sml-screen-track video {
    width:  100%;
    height: 100%;
    object-fit: contain;
}

.sml-screen-actions {
    display:     flex;
    gap:         4px;
    padding:     4px 6px;
    flex-wrap:   wrap;
}

.sml-screen-btn {
    font-size:    10px;
    padding:      3px 7px;
    border:       1px solid var(--lc-border);
    border-radius:4px;
    background:   transparent;
    color:        var(--lc-muted);
    cursor:       pointer;
    transition:   all var(--lc-transition);
}

.sml-screen-btn:hover {
    background: var(--lc-border);
    color:      var(--lc-text);
}

.sml-screen-stop-btn:hover {
    background: rgba(239,68,68,.15);
    color:      var(--lc-danger);
    border-color: var(--lc-danger);
}

/* ── Participants ─────────────────────────────────────── */
.sml-live-participants-area {
    flex:       1;
    overflow-y: auto;
    padding:    8px;
    scrollbar-width: thin;
    scrollbar-color: var(--lc-border) transparent;
}

.sml-no-participants {
    text-align: center;
    color:      var(--lc-muted);
    font-size:  12px;
    padding:    12px 0;
}

.sml-participant-group {
    margin-bottom: 10px;
}

.sml-participant-group-label {
    font-size:   10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color:       var(--lc-muted);
    padding:     2px 0 4px;
    border-bottom: 1px solid var(--lc-border);
    margin-bottom: 4px;
}

.sml-role-host    .sml-participant-group-label { color: var(--lc-host); }
.sml-role-speaker .sml-participant-group-label { color: var(--lc-speaker); }

.sml-participant {
    display:     flex;
    align-items: center;
    justify-content: space-between;
    padding:     5px 6px;
    border-radius: 5px;
    font-size:   13px;
    transition:  background var(--lc-transition);
    gap:         6px;
}

.sml-participant:hover { background: var(--lc-surface2); }

.sml-participant.is-me .sml-participant-name {
    color: var(--lc-accent);
}

.sml-participant-name {
    flex: 1;
    overflow:  hidden;
    text-overflow: ellipsis;
    white-space:   nowrap;
}

.sml-participant-state {
    font-size:  14px;
    flex-shrink: 0;
}

.sml-mod-controls {
    display:    flex;
    gap:        3px;
    flex-shrink: 0;
    opacity:    0;
    transition: opacity var(--lc-transition);
}

.sml-participant:hover .sml-mod-controls { opacity: 1; }

.sml-mod-btn {
    font-size:  10px;
    padding:    2px 6px;
    border:     1px solid var(--lc-border);
    border-radius: 3px;
    background: transparent;
    color:      var(--lc-muted);
    cursor:     pointer;
    white-space: nowrap;
    transition: all var(--lc-transition);
}

.sml-mod-btn:hover      { background: var(--lc-border); color: var(--lc-text); }
.sml-mod-remove:hover   { background: rgba(239,68,68,.15); color: var(--lc-danger); border-color: var(--lc-danger); }

/* ── Polls ────────────────────────────────────────────── */
.sml-live-polls-area {
    padding:       8px;
    border-top:    1px solid var(--lc-border);
    max-height:    180px;
    overflow-y:    auto;
    scrollbar-width: thin;
    scrollbar-color: var(--lc-border) transparent;
}

.sml-polls-header {
    font-size:  12px;
    color:      var(--lc-muted);
    margin-bottom: 6px;
}

.sml-poll {
    background: var(--lc-surface2);
    border:     1px solid var(--lc-border);
    border-radius: 6px;
    padding:    10px;
    margin-bottom: 8px;
}

.sml-poll-question {
    font-size:  13px;
    font-weight:600;
    margin-bottom: 8px;
}

.sml-poll-options {
    display:    flex;
    flex-direction: column;
    gap:        4px;
}

.sml-poll-option {
    padding:    6px 10px;
    border:     1px solid var(--lc-border);
    border-radius: 4px;
    background: transparent;
    color:      var(--lc-text);
    cursor:     pointer;
    text-align: left;
    font-size:  12px;
    transition: all var(--lc-transition);
}

.sml-poll-option:hover {
    background:   rgba(34,197,94,.12);
    border-color: var(--lc-accent);
    color:        var(--lc-accent);
}

.sml-poll-result {
    position:   relative;
    background: var(--lc-surface);
    border:     1px solid var(--lc-border);
    border-radius: 4px;
    padding:    6px 10px;
    overflow:   hidden;
    font-size:  12px;
}

.sml-poll-bar {
    position:   absolute;
    left:       0; top: 0; bottom: 0;
    background: rgba(34,197,94,.18);
    transition: width .4s ease;
    z-index:    0;
}

.sml-poll-pct {
    position:   relative;
    z-index:    1;
    color:      var(--lc-text);
}

/* ── Controls toolbar ─────────────────────────────────── */
.sml-live-controls {
    display:         flex;
    align-items:     center;
    justify-content: center;
    gap:             8px;
    padding:         10px 12px;
    background:      var(--lc-bg);
    border-top:      1px solid var(--lc-border);
    flex-shrink:     0;
    flex-wrap:       wrap;
}

.sml-ctrl-btn {
    padding:      7px 14px;
    border:       1px solid var(--lc-border);
    border-radius:6px;
    background:   var(--lc-surface2);
    color:        var(--lc-text);
    cursor:       pointer;
    font-size:    13px;
    font-weight:  500;
    transition:   all var(--lc-transition);
}

.sml-ctrl-btn:hover:not(:disabled) {
    background:   var(--lc-border);
    border-color: var(--lc-accent);
}

.sml-ctrl-btn:disabled {
    opacity: .4;
    cursor:  default;
}

.sml-ctrl-join {
    background:   var(--lc-accent);
    border-color: var(--lc-accent);
    color:        #000;
    font-weight:  700;
}

.sml-ctrl-join:hover:not(:disabled) {
    background:   #16a34a;
    border-color: #16a34a;
}

.sml-ctrl-leave {
    color:        var(--lc-danger);
    border-color: rgba(239,68,68,.3);
}

.sml-ctrl-leave:hover:not(:disabled) {
    background:   rgba(239,68,68,.12);
    border-color: var(--lc-danger);
}

/* ── Settings Modal ───────────────────────────────────── */
.sml-modal {
    position:    fixed;
    inset:       0;
    background:  rgba(0,0,0,.7);
    display:     flex;
    align-items: center;
    justify-content: center;
    z-index:     10000;
    padding:     16px;
}

.sml-modal-box {
    background:   var(--lc-surface);
    border:       1px solid var(--lc-border);
    border-radius:var(--lc-radius);
    padding:      20px 24px;
    width:        100%;
    max-width:    420px;
    max-height:   85vh;
    overflow-y:   auto;
    color:        var(--lc-text);
    scrollbar-width: thin;
    scrollbar-color: var(--lc-border) transparent;
}

.sml-modal-box h3 {
    margin:      0 0 16px;
    font-size:   16px;
    font-weight: 700;
}

.sml-modal-box label {
    display:       block;
    margin-bottom: 10px;
    font-size:     13px;
    color:         var(--lc-muted);
}

.sml-modal-box input[type="text"],
.sml-modal-box input[type="number"],
.sml-modal-box select,
.sml-modal-box textarea {
    display:      block;
    width:        100%;
    margin-top:   4px;
    padding:      7px 10px;
    background:   var(--lc-surface2);
    border:       1px solid var(--lc-border);
    border-radius:5px;
    color:        var(--lc-text);
    font-size:    13px;
    box-sizing:   border-box;
}

.sml-modal-box textarea { min-height: 60px; resize: vertical; }

.sml-modal-box input:focus,
.sml-modal-box select:focus,
.sml-modal-box textarea:focus {
    outline:      none;
    border-color: var(--lc-accent);
}

.sml-bool-field {
    display:     flex;
    align-items: center;
    gap:         6px;
    color:       var(--lc-text);
    cursor:      pointer;
    padding:     3px 0;
}

.sml-bool-field input[type="checkbox"] {
    width:  16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--lc-accent);
}

fieldset {
    border:        1px solid var(--lc-border);
    border-radius: 5px;
    padding:       8px 12px;
    margin:        10px 0;
}

legend {
    font-size:   11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color:       var(--lc-muted);
    padding:     0 4px;
}

.sml-modal-actions {
    display:    flex;
    gap:        8px;
    margin-top: 16px;
    justify-content: flex-end;
}

.sml-btn {
    padding:      7px 16px;
    border-radius:6px;
    border:       1px solid var(--lc-border);
    background:   var(--lc-surface2);
    color:        var(--lc-text);
    cursor:       pointer;
    font-size:    13px;
    font-weight:  500;
    transition:   all var(--lc-transition);
}

.sml-btn:hover { background: var(--lc-border); }

.sml-btn-primary {
    background:   var(--lc-accent);
    border-color: var(--lc-accent);
    color:        #000;
    font-weight:  700;
}

.sml-btn-primary:hover { background: #16a34a; border-color: #16a34a; }

/* ── Layout variants ──────────────────────────────────── */
#sml-live-panel[data-layout="gallery"] .sml-live-screens-area {
    max-height:  none;
}

#sml-live-panel[data-layout="focus"] .sml-screen-card:not(.is-focused) {
    display: none;
}

#sml-live-panel[data-layout="sidebar"] {
    width:    480px;
    max-width:100%;
}

#sml-live-panel[data-layout="sidebar"] .sml-live-screens-area {
    max-height: 320px;
}

/* ── Scrollbar styling ───────────────────────────────── */
.sml-live-screens-area::-webkit-scrollbar,
.sml-live-participants-area::-webkit-scrollbar,
.sml-live-polls-area::-webkit-scrollbar,
.sml-modal-box::-webkit-scrollbar {
    width: 4px;
}

.sml-live-screens-area::-webkit-scrollbar-track,
.sml-live-participants-area::-webkit-scrollbar-track,
.sml-live-polls-area::-webkit-scrollbar-track,
.sml-modal-box::-webkit-scrollbar-track {
    background: transparent;
}

.sml-live-screens-area::-webkit-scrollbar-thumb,
.sml-live-participants-area::-webkit-scrollbar-thumb,
.sml-live-polls-area::-webkit-scrollbar-thumb,
.sml-modal-box::-webkit-scrollbar-thumb {
    background:    var(--lc-border);
    border-radius: 2px;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 480px) {
    .sml-live-panel      { max-height: 92vh; }
    .sml-screen-card     { flex: 1 1 100%; }
    .sml-modal-box       { padding: 14px 16px; }
    .sml-live-controls   { gap: 5px; }
    .sml-ctrl-btn        { padding: 6px 10px; font-size: 12px; }
}

/* ================================================================
 * PARTICLE PORTAL
 * ================================================================ */

.sml-portal-area {
    display:         flex;
    justify-content: center;
    padding:         12px 0 4px;
    border-bottom:   1px solid var(--lc-border);
    margin-bottom:   8px;
}

.sml-portal-wrap {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             6px;
    cursor:          pointer;
}

.sml-portal-canvas {
    border-radius:   50%;
    display:         block;
    outline:         none;
    transition:      filter 0.2s ease, transform 0.15s ease;
    filter:          drop-shadow(0 0 12px rgba(80, 160, 255, 0.4));
}

.sml-portal-canvas:hover,
.sml-portal-canvas:focus {
    filter:          drop-shadow(0 0 24px rgba(80, 160, 255, 0.75))
                     drop-shadow(0 0 8px rgba(140, 80, 255, 0.5));
    transform:       scale(1.06);
}

.sml-portal-canvas:active {
    transform:       scale(0.97);
}

.sml-portal-label {
    font-size:       11px;
    color:           var(--lc-muted);
    letter-spacing:  0.03em;
    max-width:       150px;
    text-align:      center;
    overflow:        hidden;
    text-overflow:   ellipsis;
    white-space:     nowrap;
}

.sml-portal-wrap:hover .sml-portal-label {
    color: var(--lc-text);
}

/* Portal edit modal overrides */
.sml-portal-modal-box {
    max-width: 420px;
}

.sml-portal-hint {
    font-size:    12px;
    color:        var(--lc-muted);
    margin:       0 0 12px;
    line-height:  1.5;
}

.sml-portal-modal-error {
    color:        var(--lc-danger);
    font-size:    12px;
    margin-top:   8px;
    padding:      6px 8px;
    background:   rgba(239,68,68,0.1);
    border-radius:4px;
}

.sml-btn-portal {
    background:   #1e2a4a;
    color:        #93c5fd;
    border-color: #2d4080;
}

.sml-btn-portal:hover {
    background:   #263666;
    border-color: #3b5bdb;
}

.sml-btn-danger {
    background:   rgba(239,68,68,0.15);
    color:        var(--lc-danger);
    border-color: rgba(239,68,68,0.3);
}

.sml-btn-danger:hover {
    background:   rgba(239,68,68,0.3);
}

/* Sidebar badge: show portal icon on channels with a portal */
[data-channel-id].has-portal::after {
    content:          '🌀';
    font-size:        10px;
    margin-left:      4px;
    opacity:          0.7;
    vertical-align:   middle;
}
