/* Mobile responsive styles for objects table */

/* Приховуємо контейнер до завантаження таблиці для уникнення FOUC */
#objectsContainer:empty {
    min-height: 200px;
}

#objectsContainer:not(:empty) {
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Медіа-запит для вузьких вікон (мобільні та зменшені вікна на ПК) */
@media screen and (max-width: 1152px) {
    /* Загальні налаштування для мобільних */
    body {
        overflow-x: hidden;
    }
    
    .main-contained {
        padding: 10px 5px;
    }
    
    .year-selector {
        margin: 10px 0;
        padding: 8px;
        font-size: 14px;
    }
    
    .year-selector select {
        font-size: 14px;
        padding: 5px;
    }
    
    /* Контейнер для горизонтального скролінгу таблиці */
    .objects-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Налаштування таблиці для вузьких вікон */
    table.obj-table {
        font-size: 13px;
        table-layout: fixed;
        width: 100%;
        margin-bottom: 20px;
    }
    
    table.obj-table th,
    table.obj-table td {
        padding: 6px 3px;
        font-size: 12px;
        word-wrap: break-word;
        vertical-align: top;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Липкі заголовки для мобільних */
    table.obj-table th {
        position: sticky;
        top: 0;
        background: #f5f5f5;
        z-index: 10;
        border-bottom: 2px solid #ddd;
    }
    
    /* Приховуємо зайві стовпці на мобільних */
    /* Залишаємо тільки: №, Об'єктовий №, Назва, Статус, та 3 місяці */
    /* Структура: №(1), Об'єктовий №(2), Назва(3), Юр. назва(4), Адреса(5), Тип обслуговування(6), Тип системи(7), Тип ППКП(8), Підрозділ(9), Статус(10), місяці(11+) */
    
    /* Приховуємо: Юр. назва, Адреса, Тип обслуговування, Тип системи, Тип ППКП */
    /* Підрозділ приховується через JavaScript для правильної обробки режиму "Вибір" */
    /* Без режиму виділення: №(1), Об'єктовий №(2), Назва(3), Юр. назва(4), Адреса(5), ... */
    table.obj-table:not(.with-selection) th:nth-child(4), /* Юр. назва */
    table.obj-table:not(.with-selection) td:nth-child(4),
    table.obj-table:not(.with-selection) th:nth-child(5), /* Адреса */
    table.obj-table:not(.with-selection) td:nth-child(5),
    table.obj-table:not(.with-selection) th:nth-child(6), /* Тип обслуговування */
    table.obj-table:not(.with-selection) td:nth-child(6),
    table.obj-table:not(.with-selection) th:nth-child(7), /* Тип системи */
    table.obj-table:not(.with-selection) td:nth-child(7),
    table.obj-table:not(.with-selection) th:nth-child(8), /* Тип ППКП */
    table.obj-table:not(.with-selection) td:nth-child(8) {
        display: none;
    }
    
    /* З режимом виділення: Вибір(1), №(2), Об'єктовий №(3), Назва(4), Юр. назва(5), Адреса(6), ... */
    /* Приховуємо: Юр. назва(5), Адреса(6), Тип обслуговування(7), Тип системи(8), Тип ППКП(9) */
    table.obj-table.with-selection th:nth-child(5), /* Юр. назва */
    table.obj-table.with-selection td:nth-child(5),
    table.obj-table.with-selection th:nth-child(6), /* Адреса */
    table.obj-table.with-selection td:nth-child(6),
    table.obj-table.with-selection th:nth-child(7), /* Тип обслуговування */
    table.obj-table.with-selection td:nth-child(7),
    table.obj-table.with-selection th:nth-child(8), /* Тип системи */
    table.obj-table.with-selection td:nth-child(8),
    table.obj-table.with-selection th:nth-child(9), /* Тип ППКП */
    table.obj-table.with-selection td:nth-child(9) {
        display: none;
    }
    
    /* Приховуємо всі місяці крім поточного та сусідніх */
    /* Залишаємо тільки 3 місяці: попередній, поточний, наступний */
    /* Без режиму виділення: місяці починаються з 11-го стовпця */
    table.obj-table:not(.with-selection) th:nth-child(n+11),
    table.obj-table:not(.with-selection) td:nth-child(n+11) {
        display: none;
    }
    
    /* З режимом виділення: місяці починаються з 12-го стовпця */
    table.obj-table.with-selection th:nth-child(n+12),
    table.obj-table.with-selection td:nth-child(n+12) {
        display: none;
    }
    
    /* Показуємо тільки 3 місяці (будемо використовувати JavaScript для визначення поточного місяця) */
    /* Це буде налаштовано динамічно через JavaScript */
    
    /* Налаштування ширини стовпців для мобільних (без режиму виділення) */
    table.obj-table:not(.with-selection) th:nth-child(1), /* № */
    table.obj-table:not(.with-selection) td:nth-child(1) { 
        width: 30px;
        min-width: 30px;
        max-width: 30px;
    }
    
    table.obj-table:not(.with-selection) th:nth-child(2), /* Об'єктовий № */
    table.obj-table:not(.with-selection) td:nth-child(2) { 
        width: 60px;
        min-width: 60px;
        max-width: 60px;
    }
    
    table.obj-table:not(.with-selection) th:nth-child(3), /* Назва */
    table.obj-table:not(.with-selection) td:nth-child(3) { 
        width: auto;
        min-width: 80px;
        max-width: 120px;
        white-space: normal; /* Дозволяємо перенос для назв */
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    table.obj-table:not(.with-selection) th:nth-child(10), /* Статус */
    table.obj-table:not(.with-selection) td:nth-child(10) { 
        width: 70px;
        min-width: 70px;
        max-width: 70px;
        font-size: 10px;
    }
    
    /* Налаштування ширини стовпців для мобільних (з режимом виділення) */
    table.obj-table.with-selection th:nth-child(1), /* Вибір */
    table.obj-table.with-selection td:nth-child(1) { 
        width: 35px;
        min-width: 35px;
        max-width: 35px;
    }
    
    table.obj-table.with-selection th:nth-child(2), /* № */
    table.obj-table.with-selection td:nth-child(2) { 
        width: 30px;
        min-width: 30px;
        max-width: 30px;
    }
    
    table.obj-table.with-selection th:nth-child(3), /* Об'єктовий № */
    table.obj-table.with-selection td:nth-child(3) { 
        width: 60px;
        min-width: 60px;
        max-width: 60px;
    }
    
    table.obj-table.with-selection th:nth-child(4), /* Назва */
    table.obj-table.with-selection td:nth-child(4) { 
        width: auto;
        min-width: 80px;
        max-width: 120px;
        white-space: normal; /* Дозволяємо перенос для назв */
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    table.obj-table.with-selection th:nth-child(11), /* Статус */
    table.obj-table.with-selection td:nth-child(11) { 
        width: 70px;
        min-width: 70px;
        max-width: 70px;
        font-size: 10px;
    }
    
    /* Місяці на мобільних */
    table.obj-table th.mobile-month-visible,
    table.obj-table td.mobile-month-visible { 
        width: 45px;
        min-width: 45px;
        max-width: 45px;
        font-size: 9px;
        padding: 4px 2px;
    }
    
    /* Виділення поточного місяця */
    table.obj-table th.current-month,
    table.obj-table td.current-month {
        font-weight: bold;
    }
    
    /* Стилі для заголовків секцій */
    .objects-section h3 {
        font-size: 16px;
        margin: 15px 0 10px 0;
        padding: 8px;
        background-color: #f0f0f0;
        border-radius: 4px;
    }
    
    /* Налаштування пошуку для мобільних */
    .search-wrapper {
        margin: 10px 0;
        padding: 0 5px;
    }
    
    .search-wrapper input {
        font-size: 14px;
        padding: 8px;
        width: calc(100% - 50px);
    }
    
    .search-wrapper button {
        font-size: 14px;
        padding: 8px 10px;
    }
    
    /* Налаштування фільтрів для мобільних - не перезаписуємо основне позиціонування */
    #filterGroup .filter-handle-btn {
        width: 40px;
        height: 40px;
        padding: 8px;
    }
    
    #modalFilter {
        width: 280px;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    /* Налаштування панелі об'єкта для вузьких вікон */
    #panelObject.slide-panel {
        right: 0 !important;
        overflow-x: hidden !important;
    }
    
    /* Переконуємось що панель повністю прихована коли закрита */
    #panelObject.slide-panel:not(.open) {
        transform: translateX(calc(100% + 10px)) !important;
        visibility: hidden;
        pointer-events: none;
    }
    
    /* Коли панель відкрита */
    #panelObject.slide-panel.open {
        transform: translateX(0) !important;
        visibility: visible;
        pointer-events: auto;
    }
    
    #panelObject h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    #panelObject p {
        font-size: 13px;
        margin-bottom: 8px;
        line-height: 1.4;
    }
}

/* Додаткові налаштування для справжніх мобільних пристроїв */
@media screen and (max-width: 480px) {
    /* Спеціальні налаштування тільки для мобільних */
    table.obj-table {
        font-size: 12px;
        min-width: 350px;
    }
    
    table.obj-table th,
    table.obj-table td {
        font-size: 11px;
    }
    
    #panelObject.slide-panel {
        width: 90vw !important;
        max-width: 90vw !important;
    }
    
    #toast {
        font-size: 13px;
        padding: 8px 12px;
        max-width: 90%;
        left: 5% !important;
    }
}

/* Додаткові налаштування для дуже маленьких екранів */
@media screen and (max-width: 360px) {
    table.obj-table {
        font-size: 10px;
    }
    
    table.obj-table th,
    table.obj-table td {
        padding: 4px 2px;
        font-size: 9px;
    }
    
    /* Без режиму виділення */
    table.obj-table:not(.with-selection) th:nth-child(1),
    table.obj-table:not(.with-selection) td:nth-child(1) { 
        width: 25px;
        min-width: 25px;
    }
    
    table.obj-table:not(.with-selection) th:nth-child(2),
    table.obj-table:not(.with-selection) td:nth-child(2) { 
        width: 50px;
        min-width: 50px;
    }
    
    table.obj-table:not(.with-selection) th:nth-child(10),
    table.obj-table:not(.with-selection) td:nth-child(10) { 
        width: 60px;
        min-width: 60px;
        font-size: 8px;
    }
    
    /* З режимом виділення */
    table.obj-table.with-selection th:nth-child(1),
    table.obj-table.with-selection td:nth-child(1) { 
        width: 30px;
        min-width: 30px;
    }
    
    table.obj-table.with-selection th:nth-child(2),
    table.obj-table.with-selection td:nth-child(2) { 
        width: 25px;
        min-width: 25px;
    }
    
    table.obj-table.with-selection th:nth-child(3),
    table.obj-table.with-selection td:nth-child(3) { 
        width: 50px;
        min-width: 50px;
    }
    
    table.obj-table.with-selection th:nth-child(11),
    table.obj-table.with-selection td:nth-child(11) { 
        width: 60px;
        min-width: 60px;
        font-size: 8px;
    }
    
    .objects-section h3 {
        font-size: 14px;
        padding: 6px;
    }
}

/* Клас для показу тільки потрібних місяців */
.mobile-month-visible {
    display: table-cell !important;
}

/* Клас для приховування місяців на мобільних */
.mobile-month-hidden {
    display: none !important;
}

/* Виділення поточного місяця */
.current-month {
    background-color: rgba(79,156,255,0.2) !important;
    color: #4f9cff !important;
    font-weight: bold !important;
}


/* Контейнер для розташування пошуку та панелі управління в один ряд по центру */
.search-control-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px 20px;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
}

/* Стилі для селектора року в фільтрах */
.year-selector-filter {
    padding: 8px 0;
}

.year-selector-filter select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: var(--text, #e7edf6);
    font-size: 14px;
}

.year-selector-filter select:focus {
    outline: none;
    border-color: rgba(79,156,255,0.5);
    box-shadow: 0 0 0 2px rgba(79,156,255,0.2);
}

.obj-table {
    background: rgba(255,255,255,0.08) !important;
}

.obj-table th {
    background: rgba(255,255,255,0.12) !important;
    color: var(--text, #e7edf6) !important;
}

.obj-table td {
    background: transparent !important;
    color: var(--text, #e7edf6) !important;
}

.obj-table tr:nth-child(even) {
    background: rgba(255,255,255,0.04) !important;
}

/* Стилі для заголовків з іменами техніків */
.objects-section h3 {
    background: rgba(255,255,255,0.08) !important;
    color: var(--text, #e7edf6) !important;
    padding: 12px 16px !important;
    margin: 8px 0 !important;
}

/* Адаптивність для мобільних */
@media (max-width: 768px) {
    .search-control-container {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }
}
