/* ========================================
   TV Live Stream - Modern App Layout
   ======================================== */

/* Hide page title when shortcode is present */
.tv-live-app ~ .entry-head,
.tv-live-app ~ .entry-title,
.tv-live-app ~ .page-title,
.tv-live-app ~ header .entry-title,
.tv-live-app ~ header h1,
.tv-live-app ~ h1.entry-title,
.tv-live-app ~ article .entry-head,
.tv-live-app ~ article .entry-title,
.tv-live-app ~ .page-header,
.tv-live-app ~ .page-header h1 {
    display: none !important;
}

/* Also hide if parent contains the app */
body:has(.tv-live-app) .entry-head,
body:has(.tv-live-app) .entry-title,
body:has(.tv-live-app) .page-title,
body:has(.tv-live-app) header h1.entry-title,
body:has(.tv-live-app) article .entry-head,
body:has(.tv-live-app) .page-header,
body:has(.tv-live-app) .page-header h1 {
    display: none !important;
}

/* CSS Variables */
.tv-live-app {
    --tv-primary: #3B82F6;
    --tv-primary-light: #60A5FA;
    --tv-primary-dark: #2563EB;
    --tv-secondary: #EFF6FF;
    --tv-success: #10B981;
    --tv-danger: #EF4444;
    --tv-warning: #F59E0B;
    --tv-text: #1E293B;
    --tv-text-light: #64748B;
    --tv-text-muted: #94A3B8;
    --tv-bg: #F8FAFC;
    --tv-white: #FFFFFF;
    --tv-border: #E2E8F0;
    --tv-border-light: #F1F5F9;
    --tv-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --tv-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --tv-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --tv-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --tv-radius-sm: 6px;
    --tv-radius: 12px;
    --tv-radius-lg: 16px;
    --tv-radius-xl: 20px;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    color: var(--tv-text);
    background: var(--tv-bg);
    border-radius: var(--tv-radius-xl);
    overflow: hidden;
    box-shadow: var(--tv-shadow-lg);
    border: 1px solid var(--tv-border);
}

.tv-live-app * {
    box-sizing: border-box;
}

/* ========================================
   App Header
   ======================================== */

.tv-live-app-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 24px;
    background: var(--tv-white);
    border-bottom: 1px solid var(--tv-border);
    flex-wrap: wrap;
}

.tv-live-app-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.tv-live-app-title .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    color: var(--tv-primary);
}

.tv-live-app-title h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--tv-text);
}

.tv-live-app-search {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    position: relative;
}

.tv-live-app-search .dashicons-search {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tv-text-muted);
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.tv-live-app-search input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-full);
    font-size: 14px;
    color: var(--tv-text);
    background: var(--tv-bg);
    transition: all 0.2s ease;
}

.tv-live-app-search input:focus {
    outline: none;
    border-color: var(--tv-primary-light);
    background: var(--tv-white);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.tv-live-app-search input::placeholder {
    color: var(--tv-text-muted);
}

.tv-live-app-stats {
    display: flex;
    gap: 16px;
    margin-left: auto;
}

.tv-live-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.tv-live-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--tv-text);
}

.tv-live-stat-online .tv-live-stat-value {
    color: var(--tv-success);
}

.tv-live-stat-label {
    font-size: 12px;
    color: var(--tv-text-light);
    font-weight: 500;
}

/* ========================================
   Main Layout
   ======================================== */

.tv-live-app-main {
    display: flex;
    height: 700px;
    min-height: 500px;
}

@media (max-width: 900px) {
    .tv-live-app-main {
        flex-direction: column;
        height: auto;
    }
}

/* ========================================
   Sidebar - Channel List
   ======================================== */

.tv-live-sidebar {
    width: 320px;
    min-width: 280px;
    background: var(--tv-white);
    border-right: 1px solid var(--tv-border);
    display: flex;
    flex-direction: column;
}

@media (max-width: 900px) {
    .tv-live-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--tv-border);
        max-height: 300px;
    }
}

.tv-live-sidebar-filter {
    padding: 16px;
    border-bottom: 1px solid var(--tv-border);
}

.tv-live-sidebar-filter select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    font-size: 14px;
    color: var(--tv-text);
    background: var(--tv-white);
    cursor: pointer;
}

.tv-live-sidebar-filter select:focus {
    outline: none;
    border-color: var(--tv-primary-light);
}

.tv-live-channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.tv-live-channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--tv-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.tv-live-channel-item:hover {
    background: var(--tv-secondary);
}

.tv-live-channel-item.active {
    background: var(--tv-secondary);
    border-left: 3px solid var(--tv-primary);
    margin-left: -3px;
}

.tv-live-channel-item.hidden {
    display: none;
}

.tv-live-channel-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: var(--tv-radius-sm);
    overflow: hidden;
    background: var(--tv-bg);
}

.tv-live-thumb-img {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.tv-live-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tv-secondary);
}

.tv-live-thumb-placeholder .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: var(--tv-primary);
}

.tv-live-channel-status {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid var(--tv-white);
}

.tv-live-channel-status.tv-live-status-online {
    background: var(--tv-success);
}

.tv-live-channel-status.tv-live-status-offline {
    background: var(--tv-danger);
}

.tv-live-channel-status.tv-live-status-unknown {
    background: var(--tv-warning);
}

.tv-live-channel-meta {
    flex: 1;
    min-width: 0;
}

.tv-live-channel-meta .tv-live-channel-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tv-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tv-live-channel-cat {
    font-size: 12px;
    color: var(--tv-text-light);
    font-weight: 500;
}

.tv-live-channel-sources {
    padding: 3px 8px;
    background: var(--tv-bg);
    color: var(--tv-text-muted);
    border-radius: var(--tv-radius-full);
    font-size: 11px;
    font-weight: 600;
}

/* ========================================
   Player Area
   ======================================== */

.tv-live-player-area {
    flex: 1;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tv-live-player-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tv-live-player-video {
    flex: 1;
    position: relative;
    background: #0f172a;
    min-height: 0;
}

.tv-live-player-video video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tv-live-player-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    z-index: 10;
}

.tv-live-player-loading.hidden {
    display: none !important;
}

.tv-live-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--tv-primary-light);
    border-radius: 50%;
    animation: tv-spin 1s linear infinite;
}

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

.tv-live-player-loading p {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
}

.tv-live-player-info {
    background: var(--tv-white);
    padding: 16px 20px;
    border-top: 1px solid var(--tv-border);
}

.tv-live-player-channel {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.tv-live-player-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--tv-radius);
    object-fit: cover;
    background: var(--tv-bg);
}

.tv-live-player-details {
    flex: 1;
}

.tv-live-player-details h3 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--tv-text);
}

.tv-live-player-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--tv-radius-full);
    font-size: 12px;
    font-weight: 600;
}

.tv-live-player-status.tv-live-status-online {
    background: #ECFDF5;
    color: #065F46;
}

.tv-live-player-status.tv-live-status-offline {
    background: #FEF2F2;
    color: #991B1B;
}

.tv-live-player-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.tv-live-player-status.tv-live-status-online::before {
    animation: tv-pulse 2s ease-in-out infinite;
}

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

.tv-live-player-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tv-live-source-btn {
    padding: 8px 16px;
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    background: var(--tv-white);
    color: var(--tv-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tv-live-source-btn:hover {
    border-color: var(--tv-primary-light);
    background: var(--tv-secondary);
}

.tv-live-source-btn.active {
    background: var(--tv-primary);
    border-color: var(--tv-primary);
    color: var(--tv-white);
}

.tv-live-source-btn .tv-live-status-dot {
    width: 6px;
    height: 6px;
}

/* Empty State */
.tv-live-player-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--tv-bg);
    color: var(--tv-text-light);
}

.tv-live-player-empty .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.tv-live-player-empty p {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}
