/* RTSP Camera Viewer Styles */

/* Grid Layout */
.rtsp-camera-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 20px 0;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
}

.rtsp-camera-item {
    box-sizing: border-box;
    padding: 7.5px;
    flex: 0 0 auto;
}

.rtsp-camera-wrapper {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rtsp-camera-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Camera Title */
.rtsp-camera-title {
    margin: 0;
    padding: 12px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

/* Camera Player Container */
.rtsp-camera-player {
    position: relative;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Snapshot Image */
/* Video and image elements - must fill container */
.rtsp-snapshot,
.rtsp-video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    background: #000;
}

    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
}

.rtsp-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.rtsp-loading p {
    margin-top: 15px;
    font-size: 14px;
    color: #ccc;
}

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

/* Error State */
.rtsp-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    padding: 20px;
}

.rtsp-error .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #ff6b6b;
}

.rtsp-error p {
    margin: 15px 0;
    font-size: 14px;
    color: #ccc;
}

.rtsp-retry-btn {
    background: #667eea;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.rtsp-retry-btn:hover {
    background: #5568d3;
}

/* Camera Controls */
.rtsp-camera-controls {
    display: flex;
    gap: 10px;
    padding: 12px 15px;
    background: #2a2a2a;
    border-top: 1px solid #333;
}

.rtsp-fullscreen-btn,
.rtsp-refresh-btn {
    flex: 1;
    background: #3a3a3a;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.3s ease;
}

.rtsp-fullscreen-btn:hover,
.rtsp-refresh-btn:hover {
    background: #4a4a4a;
}

.rtsp-fullscreen-btn .dashicons,
.rtsp-refresh-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Single Camera View */
.rtsp-camera-single {
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin: 20px auto;
}

.rtsp-camera-single .rtsp-camera-player {
}

/* Fullscreen Styles */
.rtsp-camera-player:fullscreen {
    background: #000;
}

.rtsp-camera-player:-webkit-full-screen {
    background: #000;
}

.rtsp-camera-player:-moz-full-screen {
    background: #000;
}

.rtsp-camera-player:-ms-fullscreen {
    background: #000;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .rtsp-camera-grid[data-columns="5"] .rtsp-camera-item,
    .rtsp-camera-grid[data-columns="6"] .rtsp-camera-item {
        width: 25% !important;
    }
}

@media (max-width: 768px) {
    .rtsp-camera-grid[data-columns="4"] .rtsp-camera-item,
    .rtsp-camera-grid[data-columns="5"] .rtsp-camera-item,
    .rtsp-camera-grid[data-columns="6"] .rtsp-camera-item {
        width: 50% !important;
    }
    
    .rtsp-camera-title {
        font-size: 14px;
        padding: 10px;
    }
    
    .rtsp-camera-controls {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .rtsp-camera-grid .rtsp-camera-item {
        width: 100% !important;
    }
    
    .rtsp-fullscreen-btn .dashicons,
    .rtsp-refresh-btn .dashicons {
        margin-right: 0;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .rtsp-camera-wrapper {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
    
    .rtsp-camera-wrapper:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    }
}

/* Animation for camera appearing */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rtsp-camera-item {
    animation: fadeIn 0.4s ease forwards;
}

.rtsp-camera-item:nth-child(1) { animation-delay: 0.05s; }
.rtsp-camera-item:nth-child(2) { animation-delay: 0.1s; }
.rtsp-camera-item:nth-child(3) { animation-delay: 0.15s; }
.rtsp-camera-item:nth-child(4) { animation-delay: 0.2s; }
.rtsp-camera-item:nth-child(5) { animation-delay: 0.25s; }
.rtsp-camera-item:nth-child(6) { animation-delay: 0.3s; }
.rtsp-camera-item:nth-child(7) { animation-delay: 0.35s; }
.rtsp-camera-item:nth-child(8) { animation-delay: 0.4s; }

/* 4x2 Landscape Layout */
body.page .site-content,body.page .content-area,body.page article,body.page .entry-content{padding:0!important;margin:0!important;max-width:100%!important}
.page .entry-header{display:none!important}
.rtsp-camera-grid[data-columns="4"] .rtsp-camera-item{width:25%!important}
.rtsp-camera-title{font-size:20px!important;padding:12px!important}
.rtsp-camera-player{position:relative!important;width:100%!important;padding-bottom:56.25%!important;height:0!important;overflow:hidden!important}
.rtsp-camera-player video,.rtsp-camera-player img{position:absolute!important;top:0!important;left:0!important;width:100%!important;height:100%!important;object-fit:cover!important}

/* Force full-width layout */
.rtsp-camera-grid{width:100vw!important;margin-left:calc(-50vw + 50%)!important;margin-right:calc(-50vw + 50%)!important;max-width:100vw!important}
body.page .entry-content,body.page article,body.page .site-main,body.page .content-area{padding-left:0!important;padding-right:0!important;margin-left:0!important;margin-right:0!important;max-width:100%!important}
.page .entry-title,.page .page-header{display:none!important}

/* Ensure video is visible and on top */
.rtsp-video,
.rtsp-snapshot {
    z-index: 10 !important;
    display: block !important;
    visibility: visible !important;
}

/* Loading spinner below video */
.rtsp-loading {
    z-index: 5 !important;
}
