@media screen and (max-width: 960px) {
     .video-grid.double {
        height: unset !important;
        margin: 20px;
        padding: 12px !important;
        margin-top: unset !important;
    }
    .notification {
        width: 320px;
        text-align: center;
        padding: 5px;
    }

    .header {
        height: 56px;
        padding: 8px 16px;
    }

    .logo {
        margin-left: 0;
        width: 54px;
        height: 20px;
    }

    .header-controls {
        margin-right: 0;
        width: 40px;
        height: 40px;
    }

    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 50%;
        border-left: none;
        border-top: 1px solid #2a2d3a;
        padding-bottom: 100px;
    }

    .chat-input-container {
        width: 100% !important;
    }

 .camera-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        padding: 10px;
        justify-content: center; 
        align-items: center;     
        overflow-y: auto;
        margin: 0 auto;          
        width: fit-content;      
    }

    .camera-item {
        width: 100%;
        margin-bottom: 0;
        flex-basis: auto;
    }

    .camera-preview {
        height: 100px;
    }

    .active-info {
        font-size: 12px;
        margin-top: 10px;
        margin-bottom: unset;
    }

    .video-grid-container {
        padding: unset;
    }

    .video-grid.single .video-item {
        grid-area: 1 / 1 / span 2 / span 2;
        height: auto;
        transform-origin: center;
    }

    .video-controls button {
        width: 32px !important;
        height: 32px !important;
        border-radius: 16px !important;
        font-size: 16px !important;
    }

    .fullscreen-btn {
        width: 100%;
    }
}

@media screen and (max-width: 960px) and (orientation: landscape) {
    .dashboard {
        height: 100vh;
        width: 100vw;
        overflow: hidden;
    }
    .header {
        display: none !important;
    }

    .sidebar-open .header {
        opacity: 0;
        pointer-events: none;
    }

    .main-content {
        display: flex;
        position: relative;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }

    .video-grid-container {
        position: relative;
        flex: 1;
        height: 100%;
        transition: width 0.3s ease, transform 0.3s ease;
        will-change: width, transform;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .video-grid-container:not(.sidebar-open) {
        right: 68px;
        left: 0;
        position: absolute;
        width: calc(100vw - 68px);
        max-width: calc(100vw - 68px);
    }

    .video-grid-container.sidebar-open {
        width: calc(100vw - 307px);
        max-width: calc(100vw - 307px);
        margin-right: 0;
        margin-left: 0;
        left: 0;
        right: 307px;
        position: absolute;
    }

    .video-grid {
        max-height: 100%;
        padding: 12px;
        display: grid;
        gap: 4px;
        overflow: hidden;
        width: 80%;
    }

    .sidebar-open .video-grid {
        max-width: 100% !important;
        gap: 4px;
    }

    .video-grid.single {
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
    }

    .video-grid.single .video-item {
        width: 100%;
        max-width: calc(100% - 24px);
        height: auto;
        max-height: calc(100vh - 24px);
        aspect-ratio: 16 / 9;
        border-radius: 16px;
        overflow: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-open .video-grid.single .video-item {
        width: calc(100% - 24px);
        max-height: calc(100vh - 24px);
        aspect-ratio: 16 / 9;
    }

    .video-item {
        position: relative;
        border-radius: 16px;
        overflow: hidden;
        max-height: 100%;
        aspect-ratio: 16 / 9;
    }

    .video-item video,
    .video-item .video-js {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .sidebar {
        position: fixed;
        left: 100%;
        top: 0;
        width: 254px;
        height: 100%;
        margin: 0;
        padding: 0;
        background-color: rgba(10, 13, 24, 0.95);
        border-radius: 16px 0 0 16px;
        display: none;
        z-index: 1001;
        overflow: hidden;
        transform: translateX(0);
    }

    .sidebar.open {
        transform: translateX(-307px);
        display: block;
    }

    .sidebar .tabs {
        display: none !important;
    }

    .sidebar .tab-content {
        padding-top: 0;
        height: 100vh;
        overflow-y: auto;
    }

    #camerasTab, #chatTab {
        padding-top: 0 !important;
        overflow-x: hidden;
        padding: unset;
    }

    #chatContent {
        overflow-x: hidden;
        padding: 16px;
    }

    .chat-message {
        max-width: 222px;
        word-break: break-word;
    }

    .camera-list {
        display: block!important;
        flex-direction: column;
        padding: 16px;
        gap: 4px;
        height: calc(100vh - 32px);
        align-items: center;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 100px;;
    }

    .camera-list .camera-item,
    .camera-list .camera-preview {
        width: 222px;
        height: 120px;
        border-radius: 8px;
    }

    .camera-list .camera-item.active {
        border-radius: 8px;
        margin: 0;
        background: rgba(255, 255, 255, 0.1);
    }

    .camera-list .camera-preview {
        border-radius: 8px;
        margin-bottom: 0;
    }

    .camera-list .camera-item:hover {
        transform: translateY(-2px);
    }

    .camera-list .camera-item.active {
        background: rgba(255, 255, 255, 0.2);
    }

    .camera-list::-webkit-scrollbar {
        width: 4px;
        height: 0;
    }

    .camera-list::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }

    .camera-list::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }


    #camerasTab {
        height: 100%;
        overflow: hidden;
    }

    #chatTab {
        height: calc(100% - 76px);
        overflow-y: auto;
    }

    .chat-input-container {
        position: fixed;
        bottom: 0;
        width: 254px;
        padding: 16px;
        background: rgba(10, 13, 24, 0.75);
    }

    .chat-input-container input#chatInput {
        flex: 1;
        padding: 8px 8px 8px 12px;
        border: 2px solid #C3C4C6;
        border-radius: 30px;
        background: #0A0D18;
        color: #95969B;
        height: 40px;
        box-sizing: border-box;
        margin: 0;
    }

    .chat-input-container button#sendMessageBtn {
        position: absolute;
        right: 20px;
        background: transparent;
        border: none;
        color: #95969B;
        font-size: 16px;
        cursor: pointer;
        padding: 0;
        width: 24px;
        height: 24px;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 2;
        padding-right: 16px;
    }

    .chat-input-container input#chatInput:focus + button#sendMessageBtn,
    .chat-input-container button#sendMessageBtn:hover {
        color: #ffffff;
    }
    .video-label{
        font-size: 14px !important;
        left: unset;
    }

    .menu-item {
        width: 48px;
        height: 48px;
        background-color: rgba(10, 13, 24, 0.9);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        border: 2px solid transparent;
        margin: 5px 0;
    }

    .menu-item:hover {
        background-color: rgba(10, 13, 24, 1);
        transform: scale(1.05);
    }


    .mobile-landscape-menu {
        display: flex;
        flex-direction: column;
        position: fixed;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1001;
    }

    .mobile-landscape-menu.show-menu {
        position: fixed;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        width: 68px;
        height: 430px;
        background-color: #0a0d18;
        border-radius: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 16px;
        gap: 10px;
        z-index: 1001;
        list-style: none;
        margin: 0;
    }
}

@media screen and (max-width: 768px) and (orientation: portrait) {
    .camera-list .camera-item,
    .camera-list .camera-preview {
        width: 100%;
        height: 110px;
    }
}
@media screen and (max-width: 960px) and (orientation: portrait) {
    .video-label{
        font-size: 10px !important;
        top: 10px;
        left: unset;
    }
}

/* Show .active-info only when .sidebar is open */
.sidebar.open + .main-content .active-info,
.sidebar.open .active-info {
    display: block !important;
}
.hide-fullscreen-btn {
    display: none !important;
}