:root {
    --color-bg-main: #1a2233;
    --color-sidebar-bg: rgba(30, 36, 56, 0.97);
    --color-sidebar-header-bg: #25304a;
    --color-sidebar-text: #ffffff;
    --color-sidebar-hover: #ffb347;
    --color-group-title-bg: rgba(37, 48, 74, 0.98);
    --color-group-title-hover: #2d3a5a;
    --color-group-title-text: #ffb347;
    --color-group-title-shadow: rgba(30,36,56,0.13);
    --color-device-bg: rgba(37, 48, 74, 0.90);
    --color-device-hover: #3e5c76;
    --color-device-movd-0: #7b8794;
    --color-device-movd-1: #ff7043;
    --color-device-movd-2: #43e97b;
    --color-device-movd-3: #ffd166;
    --color-device-movd-4: #6c63ff;
    --color-device-movd-5: #ff4e54;
    --color-map-bg: #25304a;
    --color-info-panel-bg: rgba(67, 233, 123, 0.97);
    --color-info-panel-text: #ffffff;
    --color-close-hover: #ffd166;
    --color-znak-bg: #25304a;
    --color-znak-text: #ffffff;
    --color-znak-border: #ffb347;
    --color-znak-shadow: rgba(30,36,56,0.12);
    --color-show-way-btn-bg: #43e97b;
    --color-show-way-btn-hover: #2fa866;
    --color-show-way-btn-text: #ffffff;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--color-bg-main);
}
/* Custom thin scrollbar styles */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-group-title-bg) var(--color-sidebar-bg);
}

*::-webkit-scrollbar {
    width: 6px;
    background: var(--color-sidebar-bg);
}

*::-webkit-scrollbar-thumb {
    background: var(--color-group-title-bg);;
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--color-group-title-bg);
}
#container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}
#sidebar {
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    width: 320px;
    min-width: 80px;
    max-width: 400px;
    transition: width 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}
#sidebar.collapsed {
    width: 80px;
}
#sidebar-header {
    display: flex;
    align-items: center;
    padding: 20px 16px 10px 16px;
}
#logo {
    width: 40px;
    height: 40px;
    background: var(--color-sidebar-header-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.5em;
    margin-right: 12px;
    img{
        max-width: 80%;
    }
}
#toggle-sidebar {
    background: none;
    border: none;
    color: var(--color-sidebar-text);
    font-size: 1.3em;
    cursor: pointer;
    margin-left: auto;
    transition: color 0.2s;
}
#toggle-sidebar:hover {
    color: var(--color-sidebar-hover);
}
#device-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px 8px;
}
.group-title {
    background: var(--color-group-title-bg);
    margin-bottom: 10px;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    font-weight: bold;
    color: var(--color-group-title-text);
    transition: background 0.2s;
    box-shadow: 0 2px 6px var(--color-group-title-shadow);
}
.group-title:hover {
    background: var(--color-group-title-hover);
}

.device-item {
    background: var(--color-device-bg);
    margin-bottom: 8px;
    border-radius: 8px;
    padding: 0 0 0 36px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    min-height: 32px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    white-space: nowrap;
    overflow: visible;

    span{
        display: flex;
        align-items: center;
        min-height: 32px;
        o{
            position: absolute;
            font-size: 0.5em;
            bottom: 0;
            left: 0;
            opacity: 0;
        }
    }

    &:hover,
    &.active {
        background: var(--color-device-hover);
    }
    &.active .device-item-params{
        display: flex;
        flex-direction: column;
    }
    &.movd-0::before,
    &.movd-1::before,
    &.movd-2::before,
    &.movd-3::before,
    &.movd-4::before,
    &.movd-5::before,
    &.movd-6::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        transform: none;
        margin: 0;
        width: 32px;
        max-height: 32px;
        height: 100%;
        border-radius: 8px 0 0 8px;
        /* display: flex; */
        align-items: center;
        justify-content: center;
    }

    &.movd-2::before { /* Движение */
        background: linear-gradient(to right,  var(--color-device-movd-2) 20%, rgba(0,0,0,0) 100%);
    }
    &.movd-1::before { /* Стоянка */
        background: linear-gradient(to right,  var(--color-device-movd-1) 20%, rgba(0,0,0,0) 100%);
    }
    &.movd-3::before { /* Нет GPS */
        background: linear-gradient(to right,  var(--color-device-movd-3) 20%, rgba(0,0,0,0) 100%);
    }
    &.movd-4::before { /* Нет GSM */
        background: linear-gradient(to right,  var(--color-device-movd-4) 20%, rgba(0,0,0,0) 100%);
    }
    &.movd-0::before { /* Выключен */
        background: linear-gradient(to right,  var(--color-device-movd-0) 20%, rgba(0,0,0,0) 100%);
    }
    &.movd-5::before { /* Заблокирован */
        background: linear-gradient(to right,  var(--color-device-movd-5) 20%, rgba(0,0,0,0) 100%);
    }

}

    .device-params{
        display: none;
        padding: 1em 0.2em;
        font-size: 90%;
        background: var(--color-device-bg);
        border-radius: 8px;
        padding: 0.5em;
        margin-bottom: 8px;
        .date-range-picker{
            margin: 0px;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 6px;
            input {
                text-align: center;
                width: 100%;
                padding: 0.5em;
                border: 0px solid #b0bec5;
                border-radius: 6px;
                background: #fff;
                color: #222;
                font-size: 1em;
                outline: none;
                transition: border-color 0.2s;
            }
            input:focus {
                border-color: var(--color-show-way-btn-bg);
            }
        }
        .report-select{
                text-align: center;
                width: 100%;
                padding: 0.5em;
                border: 0px solid #b0bec5;
                border-radius: 6px;
                background: #fff;
                color: #222;
                font-size: 1em;
                outline: none;
                transition: border-color 0.2s;
                margin-bottom: 6px;
                &:focus {
                    border-color: var(--color-show-way-btn-bg);
                }
        }
        .date-range-button{
            display: grid;
            grid-template-columns: 1fr 1fr;
            align-items: center;
            gap: 6px;
            margin-top: 8px;
            justify-content: space-between;
            width: 100%;
            button {
                padding: 4px 12px;
                margin: 0;
                background: var(--color-sidebar-bg);
                color: var(--color-show-way-btn-text);
                border: none;
                border-radius: 6px;
                cursor: pointer;
                font-size: 1em;
                transition: background 0.2s;
                width: 100%;
                box-sizing: border-box;
                &.show-btn{
                    padding: 0.7em;
                    grid-column: span 2;
                }
            }
            button:hover {
                background: var(--color-device-hover);
            }
        }
        .date-range-sensors{
            display: grid;
            grid-template-columns: 1fr 1fr;
            align-items: center;
            gap: 6px;
            margin-bottom: 8px;
            justify-content: space-between;
            width: 100%;
            div{
                margin: 0;
                border-radius: 6px;
                background: rgba(255,255,255,0.02);
                width: 100%;
                height: 100%;
                text-align: center;
                label{
                    opacity: 0.3;
                }
                &.last_data{
                    grid-column: span 2;
                }
            }
        }
        .device-actions {
            display: grid;
            grid-template-columns: 1fr 1fr;
            align-items: center;
            gap: 6px;
            margin-bottom: 8px;
            justify-content: space-between;
            width: 100%;
            button {
                padding: 4px 12px;
                background: var(--color-sidebar-bg);
                color: var(--color-show-way-btn-text);
                border: none;
                border-radius: 6px;
                cursor: pointer;
                font-size: 1em;
                transition: background 0.2s;
                width: 100%;
                box-sizing: border-box;
                &:hover {
                    background: var(--color-device-hover);
                }
            }
        }
        &.active{
            display: flex;
            flex-direction: column;
        }
    }

#map {
    flex: 1;
    height: 100vh;
    z-index: 1;
    background: var(--color-map-bg);
}
#info-panel {
    display: none;
    position: absolute;
    left: 320px;
    right: 0;
    bottom: 0;
    background: var(--color-sidebar-bg);
    color: var(--color-info-panel-text);
    padding: 18px 32px 18px 32px;

    align-items: center;
    justify-content: space-between;
    transition: left 0.3s, opacity 0.3s;
    z-index: 3;
}
#info-panel.active {
    display: flex;
}
#info-panel.collapsed {
    opacity: 0;
    pointer-events: none;
}
#info-content{
    width: 100%;
}
#close-info {
    background: none;
    border: none;
    color: var(--color-info-panel-text);
    font-size: 1.5em;
    cursor: pointer;
    margin-left: 24px;
    transition: color 0.2s;
}
#close-info:hover {
    color: var(--color-close-hover);
}

.znak {
    display: inline-block;
    padding: 4px 16px;
    background: var(--color-znak-bg);
    color: var(--color-znak-text);
    border: 2px solid var(--color-znak-border);
    border-radius: 6px;
    font-family: 'Arial Black', Arial, sans-serif;
    font-size: 1.1em;
    letter-spacing: 2px;
    box-shadow: 0 2px 8px var(--color-znak-shadow);
    text-align: center;
    min-width: 80px;
    user-select: none;
}

@media (max-width: 600px) {
    #sidebar {
        width: 100%;
        max-width: 100%;
        min-width: 60px;
        max-height: 60vh;
        position: absolute;
        bottom: 0;
    }
    #map{
        height: 40vh;
    }
    #toggle-sidebar {display: none;}
    #sidebar.collapsed { width: 60px; }
    #info-panel { left: 0; padding: 12px 10px; }
}

.device-date-range-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.device-date-range-form label {
    font-size: 90%;
}
.device-date-range-form input[type="datetime-local"] {
    width: 100%;
    box-sizing: border-box;
}
.show-way-btn {
    margin-top: 6px;
    padding: 4px 8px;
    background: var(--color-show-way-btn-bg);
    color: var(--color-show-way-btn-text);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 90%;
}
.show-way-btn:hover {
    background: var(--color-show-way-btn-hover);
}
