/* General Styles */
:root {
    --primary-color: #5c6bc0;
    --primary-hover: #3949ab;
    --secondary-color: #7986cb;
    --success-color: #66bb6a;
    --danger-color: #ef5350;
    --warning-color: #ffca28;
    --info-color: #29b6f6;
    --text-color: #e0e0e0;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --input-bg: #2d2d2d;
    --border-color: #424242;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Wrapper */
.wrapper {
    display: flex;
    width: 100%;
}

/* Sidebar */
#sidebar {
    min-width: 250px;
    max-width: 250px;
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: all 0.3s;
    height: 100vh;
    position: fixed;
    overflow-y: auto;
}

#sidebar.active {
    margin-left: -250px;
}

#sidebar .sidebar-header {
    padding: 20px;
    background-color: var(--primary-color);
}

#sidebar ul.components {
    padding: 20px 0;
}

#sidebar ul li a {
    padding: 10px 20px;
    font-size: 1.1em;
    display: block;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s;
}

#sidebar ul li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#sidebar ul li.active > a {
    background-color: var(--primary-color);
}

/* Page Content */
#content {
    width: calc(100% - 250px);
    min-height: 100vh;
    transition: all 0.3s;
    position: absolute;
    top: 0;
    right: 0;
    padding: 20px;
}

#content.active {
    width: 100%;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.card-header {
    background-color: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
}

.login-card {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Dashboard Stats */
.stat-card .icon-box {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-card .card-title {
    color: #aaa;
    margin-bottom: 5px;
    font-size: 16px;
}

.stat-card .card-text {
    font-size: 26px;
    font-weight: bold;
    margin-bottom: 0;
}

/* Tables */
.table {
    color: var(--text-color);
}

.table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Form Controls */
.form-control, .form-select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.form-control:focus, .form-select:focus {
    background-color: var(--input-bg);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(92, 107, 192, 0.25);
    color: var(--text-color);
}

/* Status Indicators */
.status-online {
    color: var(--success-color);
}

.status-offline {
    color: var(--danger-color);
}

.status-unknown {
    color: var(--warning-color);
}

/* VOD Cards */
.vod-card {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.vod-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.vod-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.vod-card .vod-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
    padding: 15px;
    color: white;
}

.vod-card .vod-title {
    font-weight: 600;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vod-card .vod-info {
    font-size: 14px;
    color: #ddd;
}

.vod-card .vod-status {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
}

.vod-card .vod-actions {
    position: absolute;
    top: 10px;
    left: 10px;
    display: none;
}

.vod-card:hover .vod-actions {
    display: block;
}

/* Video Player */
.video-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
}

.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #sidebar {
        margin-left: -250px;
    }
    #sidebar.active {
        margin-left: 0;
    }
    #content {
        width: 100%;
    }
    #content.active {
        width: calc(100% - 250px);
    }
    .navbar-toggler {
        display: block;
    }
}

/* VOD Cards - Fixed structure with proper image filling */
.vod-card {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    min-height: 350px;
    max-height: 350px;
    background-color: #333;
    display: flex;
    flex-direction: column;
}

/* Image container with fixed dimensions */
.vod-card .vod-image-container {
    position: relative;
    width: 100%;
    height: 250px; /* Fixed height */
    background-color: #333;
    overflow: hidden;
    flex-shrink: 0;
}

/* Improved image styling to fill container properly */
.vod-card img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* This fills the container while maintaining aspect ratio */
    object-position: center; /* Center the image */
    display: block;
    background-color: #333;
}

/* Alternative: If you want images to stretch to fill exactly (may distort) */
.vod-card img.fill-stretch {
    width: 100%;
    height: 100%;
    object-fit: fill; /* Stretches to fill exactly - may distort */
    display: block;
    <img src="${poster}" alt="${vod.name}" class="img-fluid fill-stretch" 
       onload="this.classList.add('loaded')"
       onerror="this.style.display='none'; this.nextElementSibling.classList.add('active');">
}

/* Fallback for broken images */
.vod-card img[src=""],
.vod-card img:not([src]) {
    background-color: #333;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='250' viewBox='0 0 300 250'%3E%3Crect width='300' height='250' fill='%23333'/%3E%3Ctext y='130' font-size='18' fill='%23999' text-anchor='middle' x='150'%3ENo Poster Available%3C/text%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* Enhanced fallback div for when image completely fails */
.vod-fallback-poster {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #444, #222);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #999;
    font-size: 16px;
    border: 2px dashed #555;
    box-sizing: border-box;
}

.vod-fallback-poster.active {
    display: flex;
}

.vod-fallback-poster i {
    font-size: 48px;
    margin-bottom: 10px;
    color: #666;
}

/* Loading state for images */
.vod-card img[src]:not([src=""]) {
    background: linear-gradient(45deg, #333 25%, transparent 25%), 
                linear-gradient(-45deg, #333 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #333 75%), 
                linear-gradient(-45deg, transparent 75%, #333 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    animation: loading 0.5s infinite;
}

@keyframes loading {
    0% { background-position: 0 0, 0 10px, 10px -10px, -10px 0px; }
    100% { background-position: 20px 20px, 20px 30px, 30px 10px, 10px 20px; }
}

/* Remove loading animation when image loads */
.vod-card img.loaded {
    background: none;
    animation: none;
}

/* Top-left horizontal action buttons */
.vod-card .vod-actions.always-visible {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex !important;
    opacity: 0.95;
    transition: opacity 0.3s ease;
    z-index: 20;
    pointer-events: auto;
}

.vod-card .vod-actions.always-visible:hover {
    opacity: 1;
}

.vod-card .vod-actions .btn-group-horizontal {
    display: flex;
    flex-direction: row;
    gap: 3px;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.vod-card .vod-actions .btn-group-horizontal .btn {
    border-radius: 6px;
    width: 36px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.2);
    margin: 0;
    min-width: 36px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.vod-card .vod-actions .btn-group-horizontal .btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Button colors */
.vod-card .vod-actions .btn-group-horizontal .btn-primary {
    background-color: #4285f4;
    color: white;
}

.vod-card .vod-actions .btn-group-horizontal .btn-info {
    background-color: #17a2b8;
    color: white;
}

.vod-card .vod-actions .btn-group-horizontal .btn-warning {
    background-color: #ffc107;
    color: #333;
}

/* Status indicator */
.vod-card .vod-status {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    z-index: 15;
    border: 2px solid rgba(255,255,255,0.9);
}

/* Bottom overlay */
.vod-card .vod-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
    padding: 15px;
    color: white;
    min-height: 100px;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.vod-card .vod-title {
    font-weight: 600;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 16px;
}

.vod-card .vod-info {
    font-size: 14px;
    color: #ddd;
}

/* Hover effect */
.vod-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .vod-card {
        min-height: 320px;
        max-height: 320px;
    }
    
    .vod-card .vod-image-container {
        height: 220px;
    }
    
    .vod-card .vod-actions .btn-group-horizontal .btn {
        width: 38px;
        height: 34px;
        font-size: 15px;
    }
}

/* Add these styles to the end of your existing style.css file */

/* Optimized TMDB search performance */
#editTmdbResults, #tmdbResults {
    contain: layout style paint;
    transform: translateZ(0);
    will-change: contents;
}

.tmdb-movie-card {
    contain: layout style paint;
    transform: translateZ(0);
    transition: transform 0.2s ease;
}

.tmdb-movie-card:hover {
    transform: translateY(-2px);
}

/* Optimized spinner styles */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.1em;
}

/* Smooth loading states */
.select-movie:disabled,
.select-edit-movie:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* Faster form focus transitions */
.form-control:focus {
    transition: border-color 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
}

/* Optimize modal rendering */
.modal-body {
    transition: none !important;
}

#editTmdbResults, #tmdbResults {
    contain: layout style paint;
    transform: translateZ(0);
    will-change: contents;
}

.tmdb-movie-card {
    contain: layout style paint;
    transform: translateZ(0);
}

/* Smooth transitions for better UX */
.modal-body {
    transition: none !important;
}

.form-control:focus {
    transition: border-color 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
}