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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #000000;
    min-height: 100vh;
    padding: 20px;
    transition: transform 0.3s ease;
}

/* Fullscreen auto-rotate styles */
body:fullscreen {
    width: 100vw;
    height: 100vh;
    padding: 0;
    background: #000;
}

body:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    padding: 0;
    background: #000;
}

body:-moz-full-screen {
    width: 100vw;
    height: 100vh;
    padding: 0;
    background: #000;
}

body:fullscreen .container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body:fullscreen .header,
body:fullscreen .footer,
body:fullscreen .network-status,
body:fullscreen .stream-info,
body:fullscreen .stats,
body:fullscreen .refresh-btn,
body:fullscreen .channel-header,
body:fullscreen .archives-section {
    display: none !important;
}

body:fullscreen .channels-grid {
    display: block;
    margin: 0;
    height: 100vh;
}

body:fullscreen .channel-card {
    height: 100vh;
    border-radius: 0;
    margin: 0;
}

body:fullscreen .video-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

body:fullscreen video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.logo {
    max-width: 250px;
    height: auto;
    display: inline-block;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.logo-text {
    text-align: center;
}

.logo-text h1 {
    color: #22c55e;
    font-size: 3rem;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

.logo-text .tagline {
    color: #86efac;
    font-size: 1rem;
    letter-spacing: 3px;
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.channel-card {
    background: #0a0a0a;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #2a2a2a;
}

.channel-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 48px rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
}

.channel-header {
    background: linear-gradient(135deg, #2d2d2d 0%, #404040 100%);
    padding: 18px 20px;
    color: #e0e0e0;
    border-bottom: 2px solid #22c55e;
}

.channel-name {
    font-size: 1.3rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.channel-status {
    font-size: 0.85rem;
    background: rgba(0,0,0,0.5);
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.status-live {
    color: #4ade80;
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

.status-offline {
    color: #f97316;
    font-weight: bold;
}

.status-reconnecting {
    color: #fbbf24;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.status-waiting {
    color: #60a5fa;
    font-weight: bold;
    animation: pulse 2s infinite;
}

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

.video-container {
    background: #000000;
    position: relative;
    min-height: 300px;
}

video {
    width: 100%;
    height: auto;
    display: block;
}

.waiting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0a0a0a, #1a1a1a);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.5s ease;
}

.waiting-overlay.hide {
    opacity: 0;
    pointer-events: none;
}

.waiting-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #2d2d2d;
    border-top: 4px solid #22c55e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.waiting-text {
    color: #86efac;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.waiting-subtext {
    color: #6b7280;
    font-size: 0.85rem;
}

.waiting-progress {
    width: 200px;
    height: 2px;
    background: #2d2d2d;
    border-radius: 2px;
    margin-top: 20px;
    overflow: hidden;
}

.waiting-progress-bar {
    height: 100%;
    background: #22c55e;
    width: 0%;
    animation: progress 3s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 100%; }
    100% { width: 0%; }
}

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

.stream-info {
    padding: 15px 20px;
    background: #0a0a0a;
    border-top: 1px solid #2a2a2a;
    font-size: 0.9rem;
    color: #86efac;
}

.stream-info strong {
    color: #22c55e;
}

.stream-info div {
    margin-bottom: 5px;
}

.stream-info div:last-child {
    margin-bottom: 0;
}

.network-status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #2d2d2d;
    padding: 8px 16px;
    border-radius: 25px;
    color: #e0e0e0;
    font-size: 0.85rem;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    font-weight: 600;
    border: 1px solid #22c55e;
    backdrop-filter: blur(10px);
}

.network-offline {
    background: #ea580c;
    animation: pulse 1s infinite;
}

.network-online {
    background: rgba(45, 45, 45, 0.95);
}

.footer {
    text-align: center;
    color: #86efac;
    margin-top: 40px;
    padding: 20px;
    border-top: 1px solid #2a2a2a;
}

.refresh-btn {
    background: linear-gradient(135deg, #2d2d2d 0%, #404040 100%);
    color: #22c55e;
    border: 1px solid #22c55e;
    padding: 12px 28px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-top: 10px;
    transition: all 0.3s;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.refresh-btn:hover {
    background: linear-gradient(135deg, #404040 0%, #505050 100%);
    color: #4ade80;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
    border-color: #4ade80;
}

.refresh-btn:active {
    transform: translateY(0);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.stat-item {
    background: #0a0a0a;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #2a2a2a;
    color: #86efac;
    transition: all 0.3s ease;
}

.stat-item:hover {
    border-color: #22c55e;
    color: #22c55e;
    transform: translateY(-2px);
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #2d2d2d;
    border-top: 2px solid #22c55e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.fullscreen-hint {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: #22c55e;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 1001;
    pointer-events: none;
    animation: fadeOut 3s forwards;
    white-space: nowrap;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

.vod-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: #fbbf24;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    z-index: 15;
    font-weight: bold;
    backdrop-filter: blur(5px);
}

.archives-section {
    margin-top: 0;
    border-top: 1px solid #2a2a2a;
    background: #0a0a0a;
}

.archives-header {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f0f0f;
    transition: background 0.2s;
}

.archives-header:hover {
    background: #1a1a1a;
}

.archives-title {
    color: #22c55e;
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.archives-count {
    background: #22c55e20;
    color: #4ade80;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
}

.archive-toggle {
    color: #86efac;
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.archives-list {
    max-height: 0;
    overflow-y: auto;
    transition: max-height 0.3s ease-out;
}

.archives-list.open {
    max-height: 400px;
}

.archive-item {
    padding: 10px 20px;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.archive-item:hover {
    background: #1a1a1a;
}

.archive-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.archive-date {
    color: #22c55e;
    font-size: 0.85rem;
    font-weight: 500;
}

.archive-duration {
    color: #6b7280;
    font-size: 0.7rem;
}

.archive-play-btn {
    background: #22c55e20;
    color: #22c55e;
    border: 1px solid #22c55e;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.archive-play-btn:hover {
    background: #22c55e;
    color: #000;
}

.loading-archives {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 0.85rem;
}

.no-archives {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 0.85rem;
}

.archive-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.archive-modal.active {
    display: flex;
}

.archive-modal video {
    max-width: 90%;
    max-height: 80%;
    border-radius: 8px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
}

.modal-title {
    color: #22c55e;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    body { padding: 10px; }
    .channels-grid { grid-template-columns: 1fr; gap: 20px; }
    .channel-name { font-size: 1rem; flex-direction: column; align-items: flex-start; }
    .network-status { top: 10px; right: 10px; font-size: 0.7rem; padding: 5px 12px; }
    .logo-text h1 { font-size: 2rem; }
    .stats { gap: 10px; }
    .stat-item { font-size: 0.75rem; padding: 4px 10px; }
    .refresh-btn { padding: 10px 20px; font-size: 0.85rem; }
    .stream-info { padding: 12px 15px; font-size: 0.85rem; }
    .fullscreen-hint { font-size: 0.7rem; bottom: 10px; }
}

@media (max-width: 480px) {
    .channel-header { padding: 12px 15px; }
    .stream-info { font-size: 0.8rem; }
}

@media (max-width: 768px) and (orientation: landscape) {
    body { padding: 5px; }
    .channel-header { padding: 8px 12px; }
    .channel-name { font-size: 0.9rem; }
    .stream-info { padding: 8px 12px; font-size: 0.75rem; }
    .stats { margin-top: 10px; }
    .footer { margin-top: 20px; }
}

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
    background: #2d2d2d;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #22c55e;
}

/* ==================== MOBILE FIXES - REMOVE SPACING ==================== */

/* Fix for mobile - remove extra space between video and description */
@media (max-width: 768px) {
    /* Main container fixes */
    .container {
        padding: 0;
        margin: 0;
    }
    
    /* Remove body padding on mobile */
    body {
        padding: 0 !important;
        margin: 0;
    }
    
    /* Fix video container - remove margins and padding */
    .player-container {
        margin-bottom: 0 !important;
        border-radius: 0 !important;
    }
    
    .video-container {
        min-height: auto;
    }
    
    /* Fix video info section spacing */
    .video-info {
        padding: 0 12px;
        margin-top: 8px;
    }
    
    /* Reduce video title margin */
    .video-title {
        font-size: 1rem;
        margin-bottom: 6px;
        line-height: 1.3;
    }
    
    /* Tighten video stats section */
    .video-stats {
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    
    /* Reduce description panel margin */
    .description-panel {
        margin: 8px 0 0 0;
        padding: 10px 12px;
    }
    
    /* Fix channel cards grid */
    .channels-grid {
        gap: 12px;
        margin-bottom: 12px;
        padding: 0 8px;
    }
    
    /* Fix channel card spacing */
    .channel-card {
        margin-bottom: 0;
    }
    
    /* Fix channel header padding */
    .channel-header {
        padding: 12px 15px;
    }
    
    /* Fix stream info section */
    .stream-info {
        padding: 10px 15px;
    }
    
    /* Fix archives section */
    .archives-section {
        margin-top: 0;
    }
    
    .archives-header {
        padding: 10px 15px;
    }
    
    /* Remove footer extra space */
    .footer {
        margin-top: 20px;
        padding: 15px;
    }
    
    /* Fix stats section */
    .stats {
        margin-top: 12px;
        gap: 8px;
    }
    
    .stat-item {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    
    /* Fix refresh button */
    .refresh-btn {
        margin-top: 5px;
        padding: 8px 20px;
        font-size: 0.8rem;
    }
}

/* Extra small devices (phones under 480px) */
@media (max-width: 480px) {
    .video-title {
        font-size: 0.95rem;
    }
    
    .stats-left {
        font-size: 0.75rem;
    }
    
    .action-btn {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
    
    .description-text {
        font-size: 0.8rem;
    }
    
    .channel-name {
        font-size: 0.9rem;
    }
    
    .stream-info {
        font-size: 0.75rem;
        padding: 8px 12px;
    }
    
    .stream-info div {
        margin-bottom: 3px;
    }
}

/* Fix for landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .video-title {
        font-size: 0.9rem;
        margin-bottom: 4px;
    }
    
    .video-stats {
        padding-bottom: 4px;
        margin-bottom: 4px;
    }
    
    .description-panel {
        margin: 4px 0 0 0;
        padding: 6px 10px;
    }
    
    .channel-header {
        padding: 6px 12px;
    }
    
    .channel-name {
        font-size: 0.85rem;
    }
    
    .stream-info {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
    
    .footer {
        margin-top: 10px;
        padding: 10px;
    }
}

/* Ensure no unwanted margins on video element */
video {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
}

/* Fix waiting overlay on mobile */
.waiting-overlay .waiting-text {
    font-size: 0.9rem;
}

.waiting-overlay .waiting-subtext {
    font-size: 0.7rem;
}

.waiting-spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
}

/* Live stream mute indicator */
.live-mute-indicator {
    animation: fadeInOut 3s ease forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(10px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); visibility: hidden; }
}
