/**
 * SV Livestream Manager - Frontend Styles
 */

/* Base Styles */
.sv-livestream-wrapper {
    --sv-primary: #e74c3c;
    --sv-secondary: #3498db;
    --sv-dark: #1a1a2e;
    --sv-light: #f8f9fa;
    --sv-border: #dee2e6;
    --sv-text: #333;
    --sv-text-light: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 1400px;
    margin: 0 auto 20px;
    background: var(--sv-bg-color, var(--sv-dark));
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border: var(--sv-wrapper-border-width, 0) solid var(--sv-wrapper-border-color, transparent);
}

/* Header */
.sv-livestream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sv-livestream-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--sv-text-light);
}

.sv-livestream-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.sv-status-live { background: var(--sv-primary); color: #fff; animation: pulse 2s infinite; }
.sv-status-upcoming { background: #f39c12; color: #fff; }
.sv-status-ended { background: #6c757d; color: #fff; }

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

/* Channel Tabs */
.sv-channel-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: var(--sv-bg-color, rgba(255,255,255,0.05));
}

.sv-channel-tab {
    padding: 10px 20px;
    border: var(--sv-btn-border-width, 0) solid var(--sv-btn-border-color, transparent);
    border-radius: 8px;
    background: var(--sv-btn-bg, rgba(255,255,255,0.1));
    color: var(--sv-btn-text, #fff);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sv-channel-tab:hover {
    opacity: 0.85;
    filter: brightness(1.2);
}

.sv-channel-tab.active {
    background: var(--sv-btn-active-bg, #e74c3c);
    color: var(--sv-btn-active-text, #fff);
    border-color: var(--sv-btn-active-bg, #e74c3c);
}

/* Button Sizes */
.sv-btn-sm .sv-channel-tab {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.sv-btn-md .sv-channel-tab {
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 8px;
}

.sv-btn-lg .sv-channel-tab {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: 10px;
}

/* Video Container */
.sv-video-container {
    position: relative;
    width: 100%;
    background: #000;
}

.sv-video-player {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    display: block;
    background: #000;
}

.sv-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.7);
}

.sv-video-overlay.loading { display: flex; }

.sv-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: var(--sv-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Chat Container */
.sv-chat-container {
    background: #f8f9fa;
}

.sv-chat-content { height: 100%; overflow: hidden; }
.sv-chat-box { display: none; height: 100%; }
.sv-chat-box.active { display: block; }
.sv-chat-box iframe { width: 100%; height: 100%; border: none; }

/* Mobile Chat Toggle - deprecated */
.sv-mobile-chat-toggle {
    display: none;
    width: 100%;
    padding: 15px;
    border: none;
    background: var(--sv-secondary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Error Message */
.sv-error {
    padding: 20px;
    text-align: center;
    color: var(--sv-primary);
    background: #fff5f5;
    border: 1px solid var(--sv-primary);
    border-radius: 8px;
}

/* ========== BASE LAYOUT FOR ALL STYLES ========== */
.sv-livestream-wrapper .sv-livestream-content {
    display: grid !important;
    grid-template-columns: 1fr 380px !important;
    grid-template-rows: auto !important;
    min-height: 450px;
    gap: 0 !important;
}

.sv-livestream-wrapper .sv-video-container {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 100% !important;
}

.sv-livestream-wrapper .sv-chat-container {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
}

.sv-livestream-wrapper .sv-chat-content {
    flex: 1;
    height: auto;
    min-height: 400px;
}

/* ========== STYLE 1: Classic - Video Left, Chat Right ========== */
.sv-livestream-wrapper.sv-style-1 .sv-livestream-content {
    display: grid !important;
    grid-template-columns: 1fr 380px !important;
}

.sv-style-1 .sv-livestream-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* ========== STYLE 2: Video Focus - Chat Below (Stacked) ========== */
.sv-livestream-wrapper.sv-style-2 .sv-livestream-content {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: unset !important;
}

.sv-livestream-wrapper.sv-style-2 .sv-video-container {
    width: 100% !important;
    grid-column: unset !important;
    grid-row: unset !important;
}

.sv-livestream-wrapper.sv-style-2 .sv-chat-container {
    width: 100% !important;
    grid-column: unset !important;
    grid-row: unset !important;
}

.sv-style-2 .sv-chat-content {
    height: 350px;
    min-height: 350px;
    flex: none;
}

.sv-style-2 .sv-livestream-header {
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 100%);
}

/* ========== STYLE 3: Chat Left - Video Right ========== */
.sv-livestream-wrapper.sv-style-3 .sv-livestream-content {
    display: grid !important;
    grid-template-columns: 350px 1fr !important;
}

.sv-livestream-wrapper.sv-style-3 .sv-chat-container {
    grid-column: 1 !important;
    grid-row: 1 !important;
}

.sv-livestream-wrapper.sv-style-3 .sv-video-container {
    grid-column: 2 !important;
    grid-row: 1 !important;
}

.sv-style-3 .sv-livestream-header {
    background: linear-gradient(135deg, #2d3436 0%, #636e72 100%);
}

/* ========== STYLE 4: Gaming/Esports Theme ========== */
.sv-style-4 {
    --sv-primary: #ff6b35;
    border-radius: 0;
    border: 2px solid #ff6b35;
}

.sv-style-4 .sv-livestream-header {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    border-bottom: 2px solid #ff6b35;
    padding: 12px 20px;
}

.sv-style-4 .sv-livestream-title {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sv-style-4 .sv-channel-tabs {
    background: #0a0a0a;
    padding: 10px 20px;
    border-bottom: 1px solid #333;
}

.sv-style-4 .sv-channel-tab {
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.sv-style-4 .sv-channel-tab:hover {
    border-color: #ff6b35;
}

.sv-style-4 .sv-channel-tab.active {
    background: #ff6b35;
    border-color: #ff6b35;
}

.sv-livestream-wrapper.sv-style-4 .sv-livestream-content {
    display: grid !important;
    grid-template-columns: 1fr 320px !important;
}

.sv-style-4 .sv-chat-container {
    background: #111;
}

/* ========== TABLET RESPONSIVE (992px - 768px) ========== */
@media (max-width: 992px) {
    .sv-livestream-wrapper .sv-livestream-content,
    .sv-livestream-wrapper.sv-style-1 .sv-livestream-content,
    .sv-livestream-wrapper.sv-style-3 .sv-livestream-content,
    .sv-livestream-wrapper.sv-style-4 .sv-livestream-content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
    }

    .sv-livestream-wrapper .sv-video-container,
    .sv-livestream-wrapper.sv-style-3 .sv-video-container {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    .sv-livestream-wrapper .sv-chat-container,
    .sv-livestream-wrapper.sv-style-3 .sv-chat-container {
        grid-column: 1 !important;
        grid-row: 2 !important;
        order: 0 !important;
    }

    .sv-livestream-wrapper .sv-chat-content {
        height: 350px;
        min-height: 350px;
    }
}

/* ========== MOBILE RESPONSIVE (below 768px) ========== */
@media (max-width: 768px) {
    .sv-livestream-wrapper {
        border-radius: 8px;
        margin: 0 0 10px;
    }

    .sv-livestream-wrapper .sv-livestream-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
    }

    .sv-livestream-wrapper .sv-video-container {
        width: 100% !important;
        grid-column: unset !important;
        grid-row: unset !important;
    }

    /* Show chat below player on mobile */
    .sv-livestream-wrapper .sv-chat-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        grid-column: unset !important;
        grid-row: unset !important;
        order: 2 !important;
    }

    .sv-livestream-wrapper .sv-chat-content {
        height: 350px;
        min-height: 300px;
    }

    .sv-livestream-wrapper .sv-channel-tabs {
        justify-content: center;
        padding: 6px 8px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .sv-livestream-wrapper .sv-channel-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* ========== SMALL MOBILE (below 480px) ========== */
@media (max-width: 480px) {
    .sv-livestream-wrapper {
        border-radius: 0;
        margin: 0 -10px 8px;
    }

    .sv-livestream-wrapper .sv-channel-tabs {
        padding: 4px 6px;
        gap: 3px;
    }

    .sv-livestream-wrapper .sv-channel-tab {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .sv-livestream-wrapper .sv-chat-content {
        height: 300px;
        min-height: 280px;
    }
}

