/* Video page styles */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --dark-color: #212529;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

.card {
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    border: none;
    transition: transform 0.3s ease;
    background: white;
}

.card:hover {
    transform: translateY(-5px);
}

.header-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header-card h1 {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.navbar-custom {
    background: white;
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.navbar-custom .nav-link {
    color: #495057;
    font-weight: 600;
    padding: 8px 15px;
    margin: 0 5px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.navbar-custom .nav-link:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.navbar-custom .nav-link.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-test {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-test:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-outline-light {
    border-radius: 25px;
    font-weight: 600;
    border: 2px solid #667eea;
    color: #667eea;
    transition: all 0.3s ease;
}

.btn-outline-light:hover {
    transform: scale(1.05);
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.status-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    padding: 15px 20px;
    border: none;
}

.card-header h5 {
    margin: 0;
    font-size: 1.2rem;
}

.card-body {
    padding: 20px;
}

/* Video list styles */
.video-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.video-list li {
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background 0.2s ease;
}

.video-list li:last-child {
    border-bottom: none;
}

.video-list li:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.video-list li.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    font-weight: 600;
}

.video-list li i {
    margin-right: 10px;
    color: #667eea;
}

/* Video player styles */
#video-player {
    background: #1e1e1e;
    border-radius: 10px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

#video-player video,
#video-player img {
    width: 100%;
    height: auto;
    border-radius: 10px;
}

/* Thermal section styles */
.thermal-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

/* Thermal video container */
.thermal-video-container {
    position: relative;
    width: 100%;
    min-height: 200px;
    background: #1a1a2e;
    border-radius: 10px;
    overflow: hidden;
}

#thermalVideoPlayer {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

#thermalWebRTCPlayer {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    background: #1a1a2e;
}

/* Stream type selector */
#streamTypeSelect {
    max-width: 350px;
}

#streamTypeStatus {
    font-size: 0.85em;
    min-height: 1.2em;
}

.thermal-controls-section {
    margin-top: 15px;
}

.thermal-controls {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-top: 10px;
}

button.stop {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 8px 20px;
    font-weight: 600;
    transition: all 0.3s ease;
}

button.stop:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4);
}

#zoomSlider {
    width: 100%;
    margin: 10px 0;
}

/* Drag and Drop styles */
.drag-handle {
    cursor: grab;
    opacity: 0.6;
    margin-right: 8px;
    transition: opacity 0.2s ease;
}

.card-header:hover .drag-handle {
    opacity: 1;
}

.status-card.sortable-ghost {
    opacity: 0.4;
    background: #e9ecef;
}

.status-card.sortable-chosen {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    transform: rotate(2deg);
}

.status-card.sortable-drag {
    opacity: 1;
}

#sortable-cards-container {
    min-height: 100px;
}

.sortable-placeholder {
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed #667eea;
    border-radius: 15px;
    margin-bottom: 20px;
    min-height: 80px;
}

/* ==================== Dynamic Thermal Camera Cards ==================== */

#thermal-cameras-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.thermal-camera-card {
    animation: fadeInUp 0.4s ease-out;
}

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

.thermal-camera-card .card-header {
    padding: 12px 20px;
}

.thermal-camera-card .card-header h5 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.thermal-camera-card .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
}

/* Thermal stream container with 16:9 aspect ratio */
.thermal-stream-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #1a1a2e;
    border-radius: 0;
    overflow: hidden;
}

.thermal-stream-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #1a1a2e;
}

.thermal-stream-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Stream error overlay */
.stream-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ff6b6b;
    font-size: 1.1rem;
    gap: 10px;
    z-index: 10;
}

.stream-error-overlay i {
    font-size: 2rem;
}

/* Thermal controls compact style */
.thermal-camera-card .thermal-controls {
    background: #f8f9fa;
    padding: 12px 20px;
    margin: 0;
    border-radius: 0;
    border-top: 1px solid #e9ecef;
}

.thermal-camera-card .thermal-controls .form-range {
    height: 8px;
}

.thermal-camera-card .thermal-controls .form-label {
    font-weight: 500;
    color: #495057;
}

/* Zoom slider custom styles */
.thermal-zoom-slider {
    cursor: pointer;
}

.thermal-zoom-slider::-webkit-slider-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.thermal-zoom-slider::-moz-range-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Live indicator pulse animation */
.thermal-camera-card .badge.bg-primary {
    animation: pulse 2s infinite;
}

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

/* ========================================
   MOBILE RESPONSIVE (< 576px)
   ======================================== */
@media (max-width: 575px) {
    .thermal-stream-container {
        aspect-ratio: 16 / 9;
        min-height: auto;
    }

    #thermalVideoPlayer {
        max-height: 300px;
        width: 100%;
    }

    .thermal-controls .d-flex {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }

    .video-list li {
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .thermal-camera-card .card-header h5 {
        font-size: 0.95rem;
        flex-wrap: wrap;
        gap: 5px;
    }

    .thermal-camera-card .thermal-controls {
        padding: 10px 12px;
    }

    .thermal-camera-card .thermal-controls .form-label {
        margin-bottom: 5px;
        font-size: 0.9rem;
    }

    .thermal-controls input[type="range"] {
        width: 100%;
    }
}

/* ========================================
   TABLET (576px - 767px)
   ======================================== */
@media (min-width: 576px) and (max-width: 767px) {
    .thermal-stream-container {
        aspect-ratio: 16 / 9;
    }

    #thermalVideoPlayer {
        max-height: 400px;
    }

    .thermal-controls .d-flex {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* ========================================
   LANDSCAPE MOBILE (height < 500px)
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .thermal-stream-container {
        max-height: 250px;
    }

    #thermalVideoPlayer {
        max-height: 250px;
    }

    .thermal-controls {
        padding: 8px 12px;
    }
}
