/* ==========================================================================
   K-Stream Core Stylesheets
   Modern minimalist dark theme with customisable accent options.
   ========================================================================== */

/* Theme Variables Setup */
:root {
    --bg-dark: #0a0a0f;
    --bg-panel: rgba(18, 18, 26, 0.75);
    --bg-card: rgba(30, 30, 46, 0.5);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-color-hover: rgba(255, 255, 255, 0.15);
    
    --text-main: #f1f1f6;
    --text-muted: #9595a8;
    --text-highlight: #ffffff;
    
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --transition-speed: 0.25s;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --glow-strength: 12px;
    
    /* Default Accent (Cyber Purple) */
    --accent: #9d4edd;
    --accent-glow: rgba(157, 78, 221, 0.35);
    --accent-light: #c77dff;
    --accent-muted: rgba(157, 78, 221, 0.15);
}

/* Theme Option overrides */
body.theme-purple {
    --accent: #a855f7;
    --accent-glow: rgba(168, 85, 247, 0.35);
    --accent-light: #d8b4fe;
    --accent-muted: rgba(168, 85, 247, 0.12);
}

body.theme-cyan {
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.35);
    --accent-light: #67e8f9;
    --accent-muted: rgba(6, 182, 212, 0.12);
}

body.theme-green {
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.35);
    --accent-light: #6ee7b7;
    --accent-muted: rgba(16, 185, 129, 0.12);
}

body.theme-orange {
    --accent: #f97316;
    --accent-glow: rgba(249, 115, 22, 0.35);
    --accent-light: #ffedd5;
    --accent-muted: rgba(249, 115, 22, 0.12);
}

body.theme-blue {
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.35);
    --accent-light: #93c5fd;
    --accent-muted: rgba(59, 130, 246, 0.12);
}

/* Base resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    max-width: 1800px;
    margin: 0 auto;
    padding: 16px;
    gap: 16px;
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 12px 24px;
    height: 70px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

.pulse-icon {
    animation: pulse-glow 2s infinite ease-in-out;
}

.header-brand h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 40%, var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Badges */
.badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    transition: all var(--transition-speed);
}

.badge-offline {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.badge-live {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
    animation: pulse-red-border 2s infinite;
}

/* Navigation Tabs */
.header-nav {
    display: flex;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 4px;
}

.nav-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed) ease;
}

.nav-tab i {
    width: 16px;
    height: 16px;
}

.nav-tab:hover {
    color: var(--text-main);
}

.nav-tab.active {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Customizer options in header */
.header-options {
    display: flex;
    align-items: center;
    gap: 20px;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Theme color selector dots */
.theme-picker {
    border-right: 1px solid var(--border-color);
    padding-right: 16px;
}

.theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform var(--transition-speed) ease, border-color var(--transition-speed);
}

.theme-dot:hover {
    transform: scale(1.2);
}

.theme-dot.active {
    border-color: white;
    transform: scale(1.1);
}

.dot-purple { background-color: #a855f7; }
.dot-cyan { background-color: #06b6d4; }
.dot-green { background-color: #10b981; }
.dot-orange { background-color: #f97316; }
.dot-blue { background-color: #3b82f6; }

/* Icon buttons */
.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: var(--border-color-hover);
}

/* ==========================================================================
   Main Layout Panels
   ========================================================================== */
.app-main {
    display: grid;
    height: calc(100vh - 102px); /* Header + gap */
    gap: 16px;
    transition: all var(--transition-speed) ease;
}

.split-layout {
    grid-template-columns: 1fr 320px;
}

.theatre-layout {
    grid-template-columns: 1fr;
}

/* Sidebar panel hiding in Theatre layout */
.theatre-layout .sidebar-panel {
    display: none;
}

.panel {
    background-color: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Player Panel (Left Side)
   ========================================================================== */
.player-panel {
    display: flex;
    flex-direction: column;
}

.video-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
    background-color: #000000;
    overflow: hidden;
}

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

/* Offline state overlay */
.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(16, 16, 26, 0.95) 0%, rgba(5, 5, 8, 0.98) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity var(--transition-speed) ease;
}

.overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 320px;
    padding: 24px;
}

.offline-logo {
    color: var(--text-muted);
    font-size: 2.5rem;
    animation: float 4s infinite ease-in-out;
}

.player-overlay h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-main);
}

.player-overlay p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Dynamic buffering spinner */
.loader-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin-top: 8px;
}

/* Stream Details Box */
.stream-details {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.01);
}

.stream-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-highlight);
    margin-bottom: 2px;
}

.stream-description {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stream-stats-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-item i {
    width: 15px;
    height: 15px;
    color: var(--accent);
}

.stat-item.divider {
    width: 1px;
    height: 16px;
    background-color: var(--border-color);
}

/* ==========================================================================
   Sidebar Panel (Right Side)
   ========================================================================== */
.sidebar-panel {
    transition: all var(--transition-speed) ease;
}

.tab-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tab-content.hidden {
    display: none !important;
}

/* WATCH MODE: Chat Area */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.chat-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.chat-header-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-user-nickname {
    font-size: 0.75rem;
    color: var(--accent-light);
    cursor: pointer;
    font-weight: 500;
    transition: opacity var(--transition-speed);
}

.chat-user-nickname:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.chat-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot-online {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Chat Message Styling */
.message {
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.msg-author {
    font-weight: 600;
    color: var(--accent-light);
    margin-right: 6px;
}

.message-text {
    color: var(--text-main);
}

.message.system-msg {
    color: var(--text-muted);
    font-style: italic;
    background-color: rgba(255, 255, 255, 0.02);
    padding: 8px 12px;
    border-radius: 8px;
    border-left: 2px solid var(--accent);
}

/* Chat Input Bar */
.chat-input-area {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    background-color: rgba(0, 0, 0, 0.1);
}

.chat-input-area input {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 8px 14px;
    font-size: 0.85rem;
    font-family: var(--font-sans);
    transition: all var(--transition-speed);
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--accent);
    background-color: rgba(255, 255, 255, 0.08);
}

.btn-send {
    background-color: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
}

.btn-send:hover {
    background-color: var(--accent-light);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* ==========================================================================
   BROADCAST MODE: Creator Dashboard
   ========================================================================== */
.creator-dashboard {
    padding: 20px;
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-highlight);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.section-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Credentials configuration inputs */
.credential-card {
    background-color: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.credential-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.credential-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.copy-input-group {
    display: flex;
    gap: 6px;
}

.copy-input-group input {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: monospace;
    font-size: 0.8rem;
    padding: 6px 10px;
}

.copy-input-group input:focus {
    outline: none;
}

.btn-copy {
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-speed);
}

.btn-copy:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: var(--border-color-hover);
}

.btn-icon-copy {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 6px;
    width: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
}

.btn-icon-copy:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.08);
}

/* Metrics Cards Section */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform var(--transition-speed), border-color var(--transition-speed);
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-color-hover);
}

.metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-muted);
    color: var(--accent);
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.metric-icon i {
    width: 16px;
    height: 16px;
}

.metric-info {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.text-live {
    color: #ef4444;
}

.copy-link-inline {
    display: flex;
    align-items: center;
    gap: 4px;
}

.url-short {
    font-size: 0.7rem;
    font-family: monospace;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    color: var(--accent-light);
}

.btn-mini-copy {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
}

.btn-mini-copy:hover {
    color: var(--accent);
}

.btn-mini-copy i {
    width: 12px;
    height: 12px;
}

/* Setup List */
.instructions-list {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.instructions-list li strong {
    color: var(--text-main);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
        filter: drop-shadow(0 0 8px var(--accent));
    }
}

@keyframes pulse-red-border {
    0%, 100% {
        border-color: rgba(239, 68, 68, 0.4);
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
    }
    50% {
        border-color: rgba(239, 68, 68, 0.8);
        box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
    }
}

/* ==========================================================================
   Responsive Rules
   ========================================================================== */
@media (max-width: 900px) {
    body {
        display: block !important;
        overflow-y: auto !important;
        height: auto !important;
        width: 100% !important;
    }
    .app-container {
        display: block !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 8px !important;
    }
    .app-header {
        padding: 6px 12px;
        height: 42px;
        margin-bottom: 8px;
    }
    .header-brand {
        gap: 8px;
    }
    .header-brand h1 {
        font-size: 0.9rem;
    }
    .logo-icon i {
        width: 14px;
        height: 14px;
    }
    .app-header .badge {
        font-size: 0.6rem !important;
        padding: 2px 5px !important;
    }
    .app-header .btn-icon {
        width: 28px !important;
        height: 28px !important;
        border-radius: 6px !important;
    }
    .app-header .btn-icon i {
        width: 14px !important;
        height: 14px !important;
    }
    .app-main {
        display: block !important;
        height: auto !important;
    }
    .player-panel {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        margin-bottom: 8px;
    }
    .video-wrapper {
        aspect-ratio: 16/9 !important;
        width: 100% !important;
        position: relative !important;
        height: auto !important;
        flex: none !important;
    }
    .sidebar-panel {
        display: block !important;
        height: 480px !important;
        width: 100% !important;
    }
    .header-options {
        display: none; /* Hide customizer on mobile to save space */
    }
    .video-live-indicator {
        top: 8px !important;
        right: 8px !important;
        bottom: auto !important;
        left: auto !important;
        padding: 2px 5px !important;
        font-size: 0.55rem !important;
        border-radius: 2px !important;
        gap: 3px !important;
        box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3) !important;
    }
    .live-dot {
        width: 4.5px !important;
        height: 4.5px !important;
    }
    .stream-details {
        padding: 8px 12px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }
    .stream-title {
        font-size: 0.85rem !important;
    }
    .stream-description {
        font-size: 0.65rem !important;
    }
    .stream-stats-bar {
        font-size: 0.65rem !important;
        gap: 8px !important;
    }
}

/* Custom modifications to force live playback and add floating Live indicator */
video::-webkit-media-controls-timeline {
    display: none !important;
}
video::-webkit-media-controls-current-time-display {
    display: none !important;
}
video::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

.video-live-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 100;
    pointer-events: none; /* Ignore mouse events so player controls overlay gets clicked */
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    letter-spacing: 0.5px;
    user-select: none;
    transition: opacity 0.3s ease;
}

.live-dot {
    width: 6px;
    height: 6px;
    background-color: #ffffff;
    border-radius: 50%;
    display: inline-block;
    animation: live-blink 1.5s infinite;
}

@keyframes live-blink {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}


