/* ==========================================================================
   CoP Spaces — Jitsi-powered live meeting rooms
   ========================================================================== */

.cop-space-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-radius: var(--cop-radius, 10px);
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.cop-space-live {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
}
.cop-space-scheduled {
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    color: #1e293b;
}
.cop-space-banner-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.cop-space-banner-info strong { font-size: 15px; display: block; }
.cop-space-banner-meta { font-size: 12px; opacity: .8; display: block; margin-top: 2px; }
.cop-space-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cop-space-start-bar { display: flex; gap: 8px; margin-bottom: 16px; }

.cop-space-live-dot {
    width: 12px; height: 12px;
    background: #ef4444;
    border-radius: 50%;
    flex-shrink: 0;
    animation: copSpacesPulse 1.5s ease-in-out infinite;
}
@keyframes copSpacesPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); }
    50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.cop-space-btn-danger { background: #ef4444 !important; color: #fff !important; }

/* Highlight pulse when a share link deep-links to this banner */
.cop-space-banner-highlight {
    animation: copSpaceBannerHighlight 2.2s ease-out;
}
@keyframes copSpaceBannerHighlight {
    0%   { box-shadow: 0 0 0 0 rgba(59,130,246,.6); }
    40%  { box-shadow: 0 0 0 12px rgba(59,130,246,0); }
    100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}
.cop-space-share-btn { border-color: rgba(255,255,255,.4); color: inherit; }
.cop-space-live .cop-space-share-btn { color: #fff; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.08); }
.cop-space-live .cop-space-share-btn:hover { background: rgba(255,255,255,.15); }

/* Invite chip/result styles */
.cop-space-invite-result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    background: #fff;
    transition: background .15s;
}
.cop-space-invite-result:hover { background: #f1f5f9; }
.cop-space-invite-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--cop-bg, #f1f5f9);
    border: 1px solid var(--cop-border, #e2e8f0);
    border-radius: 16px;
    font-size: 12px;
}
.cop-space-invite-chip-x {
    cursor: pointer;
    color: var(--cop-danger, #ef4444);
    font-weight: 700;
}

/* Jitsi iframe mount */
.cop-spaces-jitsi-container {
    margin-bottom: 16px;
    border-radius: var(--cop-radius-lg, 12px);
    overflow: hidden;
    background: #1a1a2e;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.cop-spaces-jitsi-container #cop-spaces-jitsi-frame {
    width: 100%;
    min-height: 560px;
    background: #1a1a2e;
}
.cop-spaces-jitsi-container iframe {
    display: block;
    width: 100%;
    border: 0;
}
.cop-spaces-jitsi-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: #0f172a;
    border-top: 1px solid #334155;
}

/* LiveKit meeting UI (custom-built — LiveKit is SDK-level so we render our own) */
.cop-lk-stage {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 560px;
    background: #0f172a;
    color: #fff;
}
.cop-lk-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    align-content: start;
}
.cop-lk-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #1e293b;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    transition: border-color .15s;
}
.cop-lk-tile.speaking { border-color: var(--cop-primary, #75b83d); box-shadow: 0 0 0 2px rgba(117, 184, 61, .35); }
.cop-lk-tile-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    position: relative;
    overflow: hidden;
}
.cop-lk-tile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #334155 center/cover no-repeat;
    color: #fff;
    font-size: 28px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cop-lk-track-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cop-lk-track-audio { display: none !important; }
.cop-lk-tile-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(15, 23, 42, .92);
    color: #fff;
}
.cop-lk-tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 72%; }
/* Mic state pill. Text rather than an emoji so it reads the same on every OS
   and is announced sensibly by screen readers. */
.cop-lk-tile-mic {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .6px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(117, 184, 61, .22);
    color: #a8d47a;
}
.cop-lk-tile.mic-off .cop-lk-tile-mic { background: rgba(239, 68, 68, .2); color: #fca5a5; }

/* Raised-hand badge, only shown while the participant has their hand up. */
.cop-lk-tile-hand {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    display: none;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f59e0b;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.cop-lk-tile.hand-raised .cop-lk-tile-hand { display: block; }
.cop-lk-tile.hand-raised { border-color: #f59e0b; }

.cop-lk-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: #0b1220;
    border-top: 1px solid #334155;
    flex-wrap: wrap;
}
/* Control states. "off" is the muted/stopped state, "active" marks a raised
   hand, and the pulse draws the eye after a host invites you to speak. */
.cop-lk-bar .cop-btn[disabled] { opacity: .55; cursor: progress; }
.cop-lk-btn-off { background: #ef4444 !important; border-color: #ef4444 !important; color: #fff !important; }
.cop-lk-btn-active { background: #f59e0b !important; border-color: #f59e0b !important; color: #1e293b !important; }
@keyframes copLkPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(117, 184, 61, .8); }
    50%      { box-shadow: 0 0 0 8px rgba(117, 184, 61, 0); }
}
.cop-lk-btn-pulse { animation: copLkPulse 1.4s ease-out infinite; }

/* Audio-playback recovery banner. Browsers block autoplay until a gesture, so
   without this the room looks connected but silent. */
.cop-lk-audio-blocked {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: #f59e0b;
    color: #1e293b;
    font-size: 13px;
    font-weight: 600;
}

/* Raised-hand queue, ordered by when each person asked. */
.cop-lk-hands {
    padding: 10px 14px;
    background: #0f172a;
    border-top: 1px solid #334155;
}
.cop-lk-hands-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: #f59e0b;
    margin-bottom: 8px;
}
.cop-lk-hands-list { display: flex; flex-direction: column; gap: 6px; }
.cop-lk-hand-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: #1e293b;
    border-radius: 8px;
    font-size: 13px;
    color: #e2e8f0;
}
.cop-lk-hand-pos {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    color: #1e293b;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cop-lk-hand-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cop-lk-hand-row .cop-btn { flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
    .cop-lk-btn-pulse { animation: none; }
    .cop-lk-tile { transition: none; }
}

/* "Live Now" sidebar widget (rendered from the theme's sidebar.php) */
.copt-sidebar-live {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    border-radius: 8px;
    margin-bottom: 8px;
    text-decoration: none;
    transition: opacity .2s;
}
.copt-sidebar-live:hover { opacity: .9; }
.copt-sidebar-live-title { font-size: 12px; font-weight: 600; line-height: 1.3; }
.copt-sidebar-live-meta { font-size: 10px; opacity: .7; }

@media (max-width: 768px) {
    .cop-space-banner { flex-direction: column; text-align: center; }
    .cop-space-banner-info { justify-content: center; }
    .cop-spaces-jitsi-container #cop-spaces-jitsi-frame { min-height: 400px; }
}
