/* TV Guide Styles */
.tv-guide-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 73px); /* Ensure full viewport height minus header */
    position: relative;
    background-color: #1a1a1a;
    color: #fff;
    overflow: hidden;
    width: 100%; /* Ensure full width */
}

/* Date selector - updated to be inside time-header-placeholder */
.date-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    background-color: #2a2a2a;
    z-index: 10;
}

.current-date {
    font-size: 1rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    text-align: center;
}

.day-nav-btn {
    background: none;
    border: none;
    color: #fff;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.day-nav-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Guide layout - improved to ensure full viewport usage */
.guide-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%; /* Ensure full width */
    height: 100%; /* Ensure full height */
}

.channels-column {
    width: 220px;
    min-width: 220px;
    background-color: #2a2a2a;
    border-right: 1px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    z-index: 5;
    height: 100%; /* Ensure full height */
}

.time-header-placeholder {
    height: 50px;
    min-height: 50px;
    border-bottom: 1px solid #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.channels-list {
    overflow-y: scroll; /* Changed from hidden to scroll */
    flex: 1;
    scrollbar-width: thin; /* For Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent; /* For Firefox */
    /* Modern browsers */
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
    overscroll-behavior: none;
}

.channel-item-guide {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #3a3a3a;
    cursor: pointer;
    transition: background-color 0.2s;
}

.channel-item-guide:hover {
    background-color: #3a3a3a;
}

.channel-item-guide.active {
    background-color: rgba(239, 68, 68, 0.2);
}

.channel-logo-guide {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-right: 1rem;
}

.channel-name-guide {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.programs-grid-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%; /* Ensure full height */
    width: calc(100% - 220px); /* Ensure it takes remaining width */
}

.time-header {
    height: 50px;
    min-height: 50px;
    display: flex;
    background-color: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
    overflow-x: scroll; /* Changed from hidden to scroll */
    position: relative;
    scrollbar-width: none; /* Hide scrollbar in Firefox */
    -ms-overflow-style: none; /* Hide scrollbar in IE and Edge */
}

/* Hide scrollbar but keep functionality */
.time-header::-webkit-scrollbar {
    display: none;
}

.time-slot {
    width: 200px;
    min-width: 200px;
    height: 100%;
    border-right: 1px solid #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: #9ca3af;
    flex-shrink: 0; /* Prevent compression */
}

.time-slot.current {
    color: #ef4444;
}

.programs-grid {
    flex: 1;
    overflow-x: scroll; /* Change from hidden to scroll for proper horizontal scrolling */
    overflow-y: scroll; /* Change from auto to scroll for consistent behavior */
    position: relative;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
    overscroll-behavior: none;
    width: 100%; /* Ensure full width */
}

.program-row {
    height: 70px;
    min-height: 70px;
    position: relative;
    border-bottom: 1px solid #3a3a3a;
    width: max-content; /* Ensure row spans the full width of content */
    min-width: 100%; /* At minimum, take up the full visible width */
}

.program-item {
    position: absolute;
    height: calc(100% - 6px);
    margin: 3px 0;
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    overflow: hidden;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box; /* Ensure padding is included in width/height */
}

.program-item:hover {
    background-color: #3a3a3a;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.program-item.now-playing {
    border-color: #ef4444;
    /* Background color is set inline with gradient */
}

/* Add time-based styling for programs */
.program-item.past {
    background-color: #252525;
    border-color: #333333;
    color: rgba(255, 255, 255, 0.75);
}

.program-item.past:hover {
    background-color: #303030;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.program-item.future {
    background-color: #2a2a2a;
    border-color: #3d3d3d;
}

.program-item.future:hover {
    background-color: #353535;
}

/* Make current programs stand out more */
.program-item.now-playing {
    border-color: #ef4444;
    border-width: 2px;
    z-index: 1;
}

/* Add a subtle indicator for past programs */
.program-item.past::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.program-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.program-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Current time indicator - improved visibility */
.current-time-indicator {
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 3px !important;
    background-color: #ef4444 !important;
    z-index: 1000 !important;
    pointer-events: none !important;
    height: 100% !important;
    display: block !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8) !important;
}

.current-time-indicator::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: -6px !important;
    width: 12px !important;
    height: 12px !important;
    background-color: #ef4444 !important;
    border-radius: 50% !important;
    display: block !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8) !important;
    z-index: 101 !important;
}

/* Loading */
.guide-loading {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(4px);
    z-index: 20;
    color: white;
}

/* Error message styling */
.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    padding: 2rem;
    background-color: rgba(42, 42, 42, 0.8);
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 80%;
}

.error-message i {
    font-size: 3rem;
    color: #ef4444;
    margin-bottom: 1rem;
    display: block;
}

.error-message p {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

/* Program details */
.program-details {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #2a2a2a;
    border-top: 1px solid #3a3a3a;
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 30;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    max-height: 70%;
    display: flex;
    flex-direction: column;
}

.program-details.show {
    transform: translateY(0);
}

.program-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.program-details-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.program-details-content {
    overflow-y: auto;
    flex: 1;
}

.details-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
}

.details-meta > div {
    display: flex;
    align-items: center;
}

.details-meta i {
    margin-right: 0.5rem;
    color: #ef4444;
}

.details-subtitle {
    font-style: italic;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
}

.details-series {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    border-left: 3px solid #ef4444;
}

.details-series i,
.details-rating i,
.details-categories i,
.details-credits i {
    color: #ef4444;
    margin-right: 0.5rem;
    width: 1.2rem;
    text-align: center;
}

.series-name, .episode-info {
    margin-bottom: 0.5rem;
}

.details-rating, 
.details-categories {
    margin-bottom: 0.5rem;
}

.details-credits {
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
}

.credits-item {
    margin-bottom: 0.5rem;
}

.credits-item:last-child {
    margin-bottom: 0;
}

.details-description {
    line-height: 1.6;
    margin: 1.5rem 0;
    color: rgba(255, 255, 255, 0.9);
}

.details-thumbnail-container {
    float: right;
    margin: 0 0 -4rem 1rem;
    max-width: 35%;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

.details-thumbnail {
    width: 100%;
    height: auto;
    display: block;
}

.details-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.watch-btn, .catchup-btn, .archive-btn {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.watch-btn {
    background-color: #ef4444;
    color: white;
}

.watch-btn:hover {
    background-color: #dc2626;
}

.catchup-btn {
    background-color: #3b82f6;
    color: white;
}

.catchup-btn:hover {
    background-color: #2563eb;
}

.archive-btn {
    background-color: #8b5cf6;
    color: white;
}

.archive-btn:hover {
    background-color: #7c3aed;
}

.watch-btn i, .catchup-btn i, .archive-btn i {
    margin-right: 0.5rem;
}

/* Add styling for channel logo in details */
.channel-logo-small {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-right: 0.5rem;
}

.details-channel {
    display: flex;
    align-items: center;
}

/* Add styles for the floating navigation buttons - improved positioning */
.floating-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background-color: rgba(42, 42, 42, 0.9);
    border: 1px solid rgba(58, 58, 58, 0.8);
    border-radius: 50%;
    color: white;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 15;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.floating-nav-btn:hover {
    background-color: rgba(239, 68, 68, 0.8);
    transform: translateY(-50%) scale(1.05);
}

.left-nav-btn {
    left: 235px; /* Aligns with end of channels column */
}

.right-nav-btn {
    right: 15px;
}

/* Floating "NU" button - improved visibility */
.floating-now-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: #ef4444;
    color: white;
    font-weight: bold;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.875rem;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    animation: fadeInFromBottom 0.3s forwards;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.floating-now-btn:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

@keyframes fadeInFromBottom {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Catchup indicator styling */
.catchup-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background-color: rgba(42, 42, 42, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    font-size: 11px;
    color: #ef4444;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.program-item:hover .catchup-icon {
    transform: scale(1.2);
    background-color: rgba(61, 61, 61, 0.9);
}

.program-item.past .catchup-icon {
    color: rgba(239, 68, 68, 0.7);
}

/* Catchup unavailable message styling */
.catchup-unavailable-message {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
    padding: 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.catchup-unavailable-message i {
    flex-shrink: 0;
}

/* Responsive adjustments with improved spacing */
@media (max-width: 1280px) {
    .time-slot {
        width: 180px;
        min-width: 180px;
    }
}

@media (max-width: 1024px) {
    .time-slot {
        width: 160px;
        min-width: 160px;
    }
}

@media (max-width: 768px) {
    .channels-column {
        width: 100px;
        min-width: 100px;
    }

    .channel-name-guide {
        display: none;
    }

    .channel-logo-guide {
        margin-right: 0;
    }
    
    .time-slot {
        width: 150px;
        min-width: 150px;
        font-size: 0.75rem;
    }
    
    .left-nav-btn {
        left: 115px; /* Adjusted for smaller channels column */
    }
    
    .programs-grid-wrapper {
        width: calc(100% - 100px); /* Adjusted for smaller channels column */
    }
}

/* Custom scrollbar styling - improved visibility */
.programs-grid::-webkit-scrollbar,
.channels-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    background-color: transparent;
}

.programs-grid::-webkit-scrollbar-thumb,
.channels-list::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.programs-grid::-webkit-scrollbar-thumb:hover,
.channels-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(239, 68, 68, 0.5);
}

/* Optimized scrollbar corner */
.programs-grid::-webkit-scrollbar-corner {
    background-color: transparent;
}

/* Fix for program grid to ensure no gaps */
.programs-grid::-webkit-scrollbar-track,
.channels-list::-webkit-scrollbar-track {
    background-color: rgba(26, 26, 26, 0.5);
    border-radius: 4px;
}