/* Unified Side Panel — full-height right panel with Quiz + Chat tabs */

/* ── Toggle button in toolbar ────────────────────── */
.ls-panel-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(13, 17, 23, 0.92);
    border: 1px solid rgba(152, 195, 121, 0.25);
    color: #98c379;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.ls-panel-toggle:hover {
    background: rgba(152, 195, 121, 0.12);
    border-color: rgba(152, 195, 121, 0.5);
    transform: scale(1.05);
}
.ls-panel-toggle.active {
    background: rgba(152, 195, 121, 0.18);
    border-color: rgba(152, 195, 121, 0.6);
}
.ls-panel-toggle svg { width: 18px; height: 18px; }

/* ── Panel container ─────────────────────────────── */
.ls-sidepanel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: rgba(13, 17, 23, 0.98);
    border-left: 1px solid #30363d;
    z-index: 10002;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    transition: right 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}
.ls-sidepanel.open {
    right: 0;
}

/* ── Header with tabs ────────────────────────────── */
.ls-sidepanel-header {
    display: flex;
    align-items: center;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 0;
    flex-shrink: 0;
}
.ls-sidepanel-tabs {
    display: flex;
    flex: 1;
}
.ls-sidepanel-tab {
    flex: 1;
    padding: 0.7rem 0.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #8b949e;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    text-align: center;
}
.ls-sidepanel-tab:hover {
    color: #c9d1d9;
}
.ls-sidepanel-tab.active {
    color: #98c379;
    border-bottom-color: #98c379;
}
.ls-sidepanel-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.5rem 0.8rem;
    line-height: 1;
    flex-shrink: 0;
}
.ls-sidepanel-close:hover { color: #e6edf3; }

/* ── Slide context indicator ─────────────────────── */
.ls-sidepanel-context {
    padding: 0.4rem 0.9rem;
    background: rgba(22, 27, 34, 0.8);
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    font-size: 0.68rem;
    color: #6e7681;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ls-sidepanel-context-heading {
    color: #8b949e;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Tab content area ────────────────────────────── */
.ls-sidepanel-content {
    flex: 1;
    overflow-y: auto;
    display: none;
    flex-direction: column;
}
.ls-sidepanel-content.active {
    display: flex;
}
.ls-sidepanel-content::-webkit-scrollbar { width: 5px; }
.ls-sidepanel-content::-webkit-scrollbar-thumb {
    background: rgba(139, 148, 158, 0.25);
    border-radius: 3px;
}

/* ── QUIZ TAB ────────────────────────────────────── */
.ls-sq-body { flex: 1; overflow-y: auto; padding: 0.9rem; }
.ls-sq-footer {
    flex-shrink: 0;
    padding: 0.6rem 0.9rem;
    border-top: 1px solid #30363d;
    background: #161b22;
    display: none;
}
.ls-sq-footer.visible { display: flex; gap: 0.4rem; }

/* Idle */
.ls-sq-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    padding: 2rem 1rem;
    text-align: center;
}
.ls-sq-idle-icon { color: #98c379; opacity: 0.5; }
.ls-sq-idle-text {
    font-size: 0.82rem;
    color: #8b949e;
    line-height: 1.5;
}
.ls-sq-generate-btn {
    padding: 0.55rem 1.6rem;
    background: #98c379;
    color: #0d1117;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.ls-sq-generate-btn:hover { background: #a9d08e; }
.ls-sq-generate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ls-sq-stats {
    font-size: 0.72rem;
    color: #6e7681;
}

/* Loading */
.ls-sq-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 3rem 0;
    color: #8b949e;
    font-size: 0.82rem;
}
.ls-sq-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #30363d;
    border-top-color: #98c379;
    border-radius: 50%;
    animation: ls-sq-spin 0.8s linear infinite;
}
@keyframes ls-sq-spin { to { transform: rotate(360deg); } }

/* Question */
.ls-sq-question-text {
    font-size: 0.88rem;
    line-height: 1.55;
    color: #e6edf3;
    margin-bottom: 0.7rem;
}

.ls-sq-choices {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
}
.ls-sq-choice {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.35rem;
    background: rgba(30, 37, 48, 0.8);
    border: 1px solid rgba(48, 54, 61, 0.8);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.84rem;
    line-height: 1.5;
    color: #c9d1d9;
}
.ls-sq-choice:hover {
    border-color: #98c379;
    background: rgba(152, 195, 121, 0.06);
}
.ls-sq-choice.selected {
    border-color: #98c379;
    background: rgba(152, 195, 121, 0.1);
}
.ls-sq-choice.correct {
    border-color: #98c379;
    background: rgba(152, 195, 121, 0.12);
}
.ls-sq-choice.incorrect {
    border-color: #e06c75;
    background: rgba(224, 108, 117, 0.12);
}
.ls-sq-choice.disabled {
    pointer-events: none;
    opacity: 0.7;
}
.ls-sq-choice-label {
    font-weight: 600;
    color: #c678dd;
    min-width: 1.3em;
    flex-shrink: 0;
}

/* Hint */
.ls-sq-hint {
    padding: 0.4rem 0.7rem;
    background: rgba(229, 192, 123, 0.1);
    border-left: 3px solid #e5c07b;
    border-radius: 0 4px 4px 0;
    font-size: 0.78rem;
    color: #e5c07b;
    display: none;
    line-height: 1.45;
    margin-bottom: 0.5rem;
}
.ls-sq-hint.show { display: block; }

/* Feedback */
.ls-sq-feedback {
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.55;
    margin-top: 0.5rem;
}
.ls-sq-feedback.correct {
    background: rgba(152, 195, 121, 0.12);
    border-left: 3px solid #98c379;
    color: #c3e6a0;
}
.ls-sq-feedback.incorrect {
    background: rgba(224, 108, 117, 0.12);
    border-left: 3px solid #e06c75;
    color: #f0b0b4;
}

/* Slide refs */
.ls-sq-refs { margin-top: 0.6rem; }
.ls-sq-refs-title {
    font-size: 0.7rem;
    color: #8b949e;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ls-sq-ref {
    display: inline-block;
    padding: 0.25rem 0.55rem;
    margin: 0.15rem 0.15rem 0.15rem 0;
    background: rgba(86, 182, 194, 0.1);
    border: 1px solid rgba(86, 182, 194, 0.25);
    border-radius: 4px;
    font-size: 0.72rem;
    color: #56b6c2;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}
.ls-sq-ref:hover {
    background: rgba(86, 182, 194, 0.2);
    border-color: #56b6c2;
}

/* Rating */
.ls-sq-rating {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.7rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(48, 54, 61, 0.6);
}
.ls-sq-rating-label {
    font-size: 0.75rem;
    color: #8b949e;
}
.ls-sq-rate-btn {
    background: none;
    border: 1px solid #30363d;
    border-radius: 5px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: #8b949e;
    transition: all 0.15s;
}
.ls-sq-rate-btn:hover { border-color: #8b949e; color: #e6edf3; }
.ls-sq-rate-btn.active-up { border-color: #98c379; color: #98c379; background: rgba(152, 195, 121, 0.1); }
.ls-sq-rate-btn.active-down { border-color: #e06c75; color: #e06c75; background: rgba(224, 108, 117, 0.1); }

/* Footer buttons */
.ls-sq-next-btn {
    flex: 1;
    padding: 0.4rem 0.8rem;
    background: rgba(152, 195, 121, 0.15);
    color: #98c379;
    border: 1px solid rgba(152, 195, 121, 0.3);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
}
.ls-sq-next-btn:hover { background: rgba(152, 195, 121, 0.25); }
.ls-sq-skip-btn {
    padding: 0.4rem 0.8rem;
    background: transparent;
    color: #8b949e;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}
.ls-sq-skip-btn:hover { border-color: #8b949e; }
.ls-sq-submit-btn {
    flex: 1;
    padding: 0.4rem 0.8rem;
    background: #98c379;
    color: #0d1117;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
}
.ls-sq-submit-btn:hover { background: #a9d08e; }
.ls-sq-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ls-sq-hint-btn {
    padding: 0.35rem 0.7rem;
    background: transparent;
    color: #8b949e;
    border: 1px solid #30363d;
    border-radius: 5px;
    font-size: 0.75rem;
    cursor: pointer;
}
.ls-sq-hint-btn:hover { border-color: #8b949e; }

/* ── CHAT TAB ────────────────────────────────────── */
.ls-sc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ls-sc-messages::-webkit-scrollbar { width: 5px; }
.ls-sc-messages::-webkit-scrollbar-thumb {
    background: rgba(139, 148, 158, 0.25);
    border-radius: 3px;
}

.ls-sc-msg {
    max-width: 88%;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.84rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.ls-sc-msg.user {
    align-self: flex-end;
    background: rgba(97, 175, 239, 0.18);
    color: #c5dff6;
    border-bottom-right-radius: 2px;
}
.ls-sc-msg.assistant {
    align-self: flex-start;
    background: #1c2128;
    color: #e6edf3;
    border-bottom-left-radius: 2px;
}
.ls-sc-msg.assistant p { margin: 0.3em 0; }
.ls-sc-msg.assistant code {
    background: rgba(110, 118, 129, 0.2);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
}
.ls-sc-loading {
    align-self: flex-start;
    color: #8b949e;
    font-size: 0.82rem;
    padding: 0.5rem 0.75rem;
}
.ls-sc-loading::after {
    content: '';
    animation: ls-sc-dots 1.2s steps(3, end) infinite;
}
@keyframes ls-sc-dots {
    0%   { content: '.'; }
    33%  { content: '..'; }
    66%  { content: '...'; }
}

.ls-sc-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem 0.8rem;
    border-top: 1px solid #30363d;
    background: #161b22;
    flex-shrink: 0;
}
.ls-sc-input {
    flex: 1;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    padding: 0.5rem 0.6rem;
    font-size: 0.84rem;
    font-family: inherit;
    resize: none;
}
.ls-sc-input:focus { outline: none; border-color: #61afef; }
.ls-sc-send {
    padding: 0.5rem 1rem;
    background: #61afef;
    color: #0d1117;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    align-self: flex-end;
}
.ls-sc-send:hover { background: #79bff5; }
.ls-sc-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Login prompt */
.ls-sp-login {
    text-align: center;
    padding: 2rem 1rem;
    color: #8b949e;
    font-size: 0.85rem;
}
.ls-sp-login a { color: #98c379; text-decoration: underline; }

/* ── Mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
    .ls-sidepanel {
        width: calc(100vw - 16px);
        right: -100vw;
    }
    .ls-sidepanel.open { right: 0; }
}
