/* Main App Styles */
:root {
    --camera-header-height: 40px;
    --camera-border-color: rgba(255, 255, 255, 0.2);
    --camera-bg-color: rgba(0, 0, 0, 0.8);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-row {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.sidebar {
    width: 350px;
    overflow-y: auto;
    border-right: 1px solid var(--bs-gray-700);
    padding: 15px;
    transition: all 0.3s ease;
}

.cameras-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#cameras-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    background-color: var(--bs-dark);
}

/* Camera List Styles */
.list-group-item {
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    background-color: var(--bs-gray-800);
    color: var(--bs-light);
    border-color: var(--bs-gray-700);
}

.list-group-item:hover {
    background-color: var(--bs-gray-700);
    border-left-color: var(--bs-primary);
}

.list-group-item.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

.camera-search-container {
    margin-bottom: 15px;
}

/* Camera Container Styles */
.camera-container {
    position: absolute;
    min-width: 280px;
    min-height: 210px;
    background-color: var(--camera-bg-color);
    border: 1px solid var(--camera-border-color);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    touch-action: none;
    transform: translate(0px, 0px);
}

.camera-header {
    height: var(--camera-header-height);
    background-color: var(--bs-primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    cursor: move;
    user-select: none;
    touch-action: none;
}

.camera-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    font-size: 0.9rem;
}

.camera-controls {
    display: flex;
    gap: 5px;
}

.video-container {
    flex: 1;
    position: relative;
    background-color: black;
}

.camera-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
}

.video-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.85);
    color: var(--bs-danger);
    padding: 15px;
    text-align: center;
}

.video-error i {
    font-size: 2.5rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 3px rgba(255, 0, 0, 0.5));
}

.video-error p {
    font-weight: 500;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.video-error .error-details {
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 5px;
    padding: 10px;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    color: var(--bs-light);
}

.video-error .error-code {
    font-family: monospace;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

.video-error .retry-stream-btn:hover {
    background-color: var(--bs-danger);
    border-color: var(--bs-danger);
    color: white;
}

/* Responsive Layout */
@media (max-width: 992px) {
    .content-row {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--bs-gray-700);
        max-height: 300px;
    }
    
    .cameras-container {
        min-height: 400px;
    }
    
    /* Improved touch targets for mobile */
    .btn {
        padding: 0.5rem 0.75rem;
    }
    
    .camera-container {
        position: relative !important;
        margin-bottom: 20px;
        transform: none !important;
        width: 100% !important;
        height: 350px !important;
    }
    
    /* Help mobile users know they can scroll the sidebar */
    .sidebar:after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 30px;
        background: linear-gradient(to bottom, transparent, var(--bs-dark));
        pointer-events: none;
    }
    
    /* Make alerts more visible on small screens but keep them at the bottom */
    #alert-container {
        left: 20px;
        right: 20px;
        bottom: 20px;
        max-width: none;
    }
    
    /* Improve the visibility of active cameras in the list */
    .list-group-item.active {
        border-left-width: 8px;
    }
}

/* Toggle sidebar button */
.sidebar-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

/* Sidebar styling for desktop */
@media (min-width: 993px) {
    .sidebar {
        min-width: 350px;
        width: 350px;
        display: block;
        transition: all 0.3s ease;
    }
    
    /* Collapsed sidebar behavior */
    .sidebar.collapsed {
        width: 0;
        min-width: 0;
        padding: 0;
        border: none;
        overflow: hidden;
    }
}

/* Loading animations */
.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 10;
}

/* Playful loading animation */
.camera-loader {
    width: 70px;
    height: 70px;
    position: relative;
    perspective: 800px;
}

.camera-loader-inner {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    border: 4px solid transparent;
    animation: camera-loader-spin 3s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
    border-top-color: var(--bs-info);
    border-bottom-color: var(--bs-warning);
}

.camera-loader-inner:nth-child(2) {
    border-top-color: var(--bs-primary);
    border-bottom-color: var(--bs-danger);
    animation-delay: 0.2s;
    animation-direction: reverse;
}

.camera-loader-inner:nth-child(3) {
    border-top-color: var(--bs-success);
    border-bottom-color: var(--bs-info);
    animation-delay: 0.4s;
}

.camera-loader-inner:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 15px;
    height: 15px;
    background-color: var(--bs-light);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 
                0 0 20px rgba(255, 255, 255, 0.6),
                0 0 30px rgba(255, 255, 255, 0.4);
    animation: camera-pulse 1.5s ease-in-out infinite alternate;
}

.loading-text {
    margin-top: 15px;
    color: var(--bs-light);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 1px;
    opacity: 0.9;
    animation: loading-text-fade 1.8s ease-in-out infinite;
}

@keyframes camera-loader-spin {
    0% {
        transform: rotateX(0deg) rotateY(0deg);
    }
    25% {
        transform: rotateX(180deg) rotateY(0deg);
    }
    50% {
        transform: rotateX(180deg) rotateY(180deg);
    }
    75% {
        transform: rotateX(0deg) rotateY(180deg);
    }
    100% {
        transform: rotateX(0deg) rotateY(0deg);
    }
}

@keyframes camera-pulse {
    0% {
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

@keyframes loading-text-fade {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* Global loading indicator */
#loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Alert container */
#alert-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 350px;
    z-index: 1050;
    display: flex;
    flex-direction: column-reverse; /* Stack alerts from bottom to top */
}

/* Resize handles */
.camera-container .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--bs-primary);
    border-radius: 50%;
}

.camera-container .resize-handle-se {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
}

.camera-container .resize-handle-sw {
    bottom: -5px;
    left: -5px;
    cursor: nesw-resize;
}

.camera-container .resize-handle-ne {
    top: -5px;
    right: -5px;
    cursor: nesw-resize;
}

.camera-container .resize-handle-nw {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}
