/**
 * Live Dashboard Styles
 */

/* Page Container */
#live-dashboard-page {
    display: none;
    min-height: 100vh;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 100%;
    position: relative;
}

#live-dashboard-page.active {
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    left: auto !important;
    opacity: 1 !important;
    z-index: 10 !important;
}

/* Override inline styles from navigation system */
#live-dashboard-page[style*="visibility: hidden"] {
    visibility: visible !important;
}

#live-dashboard-page[style*="position: absolute"] {
    position: relative !important;
}

#live-dashboard-page[style*="left: -9999px"] {
    left: auto !important;
}

/* Override content scrolling for dashboard */
.content:has(#live-dashboard-page.active) {
    overflow-y: hidden !important;
}

/* Fallback for browsers without :has support */
@supports not selector(:has(*)) {
    .content {
        overflow-y: auto !important;
    }
    
    #live-dashboard-page.active {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
    }
}

/* Dashboard Container */
.live-dashboard-layout {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - 84px); /* 60px header + 24px padding */
    height: calc(100vh - 84px);
    overflow-y: auto;
    position: relative;
}

/* Content Grid */
.dashboard-content-grid {
    display: grid !important;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    flex: 1;
    min-height: 0;
    opacity: 1 !important;
    visibility: visible !important;
}

.dashboard-main {
    min-width: 0;
    display: flex !important;
    flex-direction: column;
    gap: 20px;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Chat Section */
.dashboard-chat {
    background: var(--bg-secondary);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 600px;
    position: sticky;
    top: 24px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-message {
    margin-bottom: 8px;
    word-wrap: break-word;
}

.chat-username {
    font-weight: 600;
    color: var(--primary-color);
    margin-right: 4px;
}

.chat-text {
    color: var(--text-primary);
}

.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--text-primary);
    font-size: 14px;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
}

.chat-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Responsive Layout */
@media (max-width: 1200px) {
    .dashboard-content-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-chat {
        height: 400px;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .camera-controls-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }
    
    .camera-control-btn {
        flex: 1;
        min-width: 140px;
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .camera-control-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Fullscreen Styles */
#dashboard-video-container:fullscreen {
    background: #000;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
}

#dashboard-video-container:fullscreen #live-dashboard-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#dashboard-video-container:fullscreen .player-overlay {
    opacity: 0;
}

#dashboard-video-container:fullscreen:hover .player-overlay {
    opacity: 1;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.dashboard-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
}

.stream-controls {
    display: flex;
    gap: 12px;
}

/* Video Player Section - Matching viewer page exactly */
.video-player-wrapper {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    min-height: 0; /* Allow shrinking in flex container */
}

#dashboard-video-container,
.video-container {
    position: relative !important;
    width: 100% !important;
    background: #000 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    aspect-ratio: 16 / 9 !important;
    display: block !important;
    visibility: visible !important;
    z-index: 1 !important;
}

#live-dashboard-video,
.video-player {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.player-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#dashboard-video-container:hover .player-overlay {
    opacity: 1;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.player-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

.spacer {
    flex: 1;
}

/* Camera Controls Bar - Horizontal below video */
.camera-controls-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-top: 12px;
}

.camera-control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.camera-control-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.camera-control-btn.disabled {
    opacity: 0.5;
    color: var(--text-secondary);
}

.camera-control-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

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

/* Stream Timer Section */
.stream-timer-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    margin-top: 8px;
}

.stream-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.stream-timer svg {
    width: 18px;
    height: 18px;
}

/* Stream Info Bar */
.stream-info-bar {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

.stream-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.live-indicator {
    width: 12px;
    height: 12px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-card.primary {
    background: rgba(147, 51, 234, 0.1);
    border: 1px solid rgba(147, 51, 234, 0.2);
}

.stat-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* Stream Preview */
.stream-preview-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
}

.preview-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.preview-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Chat Section */
.chat-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    height: 600px;
    display: flex;
    flex-direction: column;
}

/* Dashboard Message */
.dashboard-message {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    margin-top: 24px;
}

.dashboard-message p {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: var(--text-primary);
}

.dashboard-message p:last-child {
    margin-bottom: 0;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .stream-info-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}