/**
 * Jitsi Sidebar Layout
 * Video panel alongside learning content for supervised learning sessions
 */

/* Main container with sidebar */
.learning-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Learning content area */
.learning-content {
    flex: 1;
    overflow-y: auto;
    transition: margin-right 0.3s ease;
}

.learning-content.with-jitsi {
    margin-right: 320px;
}

/* Jitsi sidebar */
.jitsi-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 320px;
    height: 100vh;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.jitsi-sidebar.active {
    transform: translateX(0);
}

/* Sidebar header */
.jitsi-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
}

.jitsi-sidebar-header h3 {
    margin: 0;
    color: #e94560;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.jitsi-sidebar-header .live-badge {
    background: #e94560;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.jitsi-sidebar-header .close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
    line-height: 1;
}

.jitsi-sidebar-header .close-btn:hover {
    opacity: 1;
}

/* Video container */
.jitsi-video-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
}

.jitsi-video-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Loading state */
.jitsi-video-container.loading::after {
    content: 'Connecting...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
    font-size: 14px;
}

/* Controls panel */
.jitsi-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    background: #16213e;
    border-top: 1px solid #0f3460;
}

.jitsi-control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.jitsi-control-btn svg {
    width: 20px;
    height: 20px;
}

.jitsi-control-btn.mute {
    background: #2d3436;
    color: #fff;
}

.jitsi-control-btn.muted {
    background: #e94560;
    color: #fff;
}

.jitsi-control-btn.video {
    background: #2d3436;
    color: #fff;
}

.jitsi-control-btn.video-off {
    background: #e94560;
    color: #fff;
}

.jitsi-control-btn.hand {
    background: #2d3436;
    color: #fff;
}

.jitsi-control-btn.hand-raised {
    background: #f39c12;
    color: #fff;
    animation: hand-wave 0.5s ease-in-out;
}

@keyframes hand-wave {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

.jitsi-control-btn.leave {
    background: #c0392b;
    color: #fff;
}

.jitsi-control-btn:hover {
    transform: scale(1.1);
}

.jitsi-control-btn:active {
    transform: scale(0.95);
}

/* Tooltip */
.jitsi-control-btn::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 4px;
}

.jitsi-control-btn:hover::after {
    opacity: 1;
}

/* App speaking indicator */
.app-speaking-overlay {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(233, 69, 96, 0.95);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.app-speaking-overlay.active {
    display: flex;
}

.app-speaking-overlay .pulse {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* Participant count badge */
.participant-count {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
}

/* Toggle button (when sidebar is hidden) */
.jitsi-toggle-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e94560;
    color: #fff;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
    z-index: 999;
    transition: all 0.3s;
}

.jitsi-toggle-btn.visible {
    display: flex;
}

.jitsi-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(233, 69, 96, 0.5);
}

.jitsi-toggle-btn svg {
    width: 24px;
    height: 24px;
}

.jitsi-toggle-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #27ae60;
    color: #fff;
    font-size: 10px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Room notification banner */
.jitsi-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #16213e;
    border: 1px solid #e94560;
    border-radius: 8px;
    padding: 12px 16px;
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slide-in 0.3s ease;
}

.jitsi-notification.visible {
    display: flex;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.jitsi-notification .icon {
    color: #e94560;
}

.jitsi-notification .text {
    color: #fff;
    font-size: 13px;
}

.jitsi-notification .text strong {
    display: block;
    margin-bottom: 2px;
}

.jitsi-notification .join-btn {
    background: #e94560;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.jitsi-notification .join-btn:hover {
    background: #d63651;
}

.jitsi-notification .close-notification {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .jitsi-sidebar {
        width: 100%;
        height: 50vh;
        top: auto;
        bottom: 0;
        transform: translateY(100%);
    }

    .jitsi-sidebar.active {
        transform: translateY(0);
    }

    .learning-content.with-jitsi {
        margin-right: 0;
        margin-bottom: 50vh;
    }

    .jitsi-toggle-btn {
        right: 10px;
        bottom: 10px;
        width: 48px;
        height: 48px;
    }

    .jitsi-notification {
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 70px;
    }
}

/* Dark mode adjustments (already dark, but ensure consistency) */
@media (prefers-color-scheme: dark) {
    .jitsi-sidebar {
        background: #1a1a2e;
    }

    .jitsi-sidebar-header {
        background: #16213e;
    }

    .jitsi-controls {
        background: #16213e;
    }
}
