@import url("./style-tables.css");
@import url("./style-dropdowns.css");

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f8f9fc;
    padding: 20px;
}

/* Стили для tooltip графика - жирное название столбца */
.chartjs-tooltip-title {
    font-weight: bold !important;
    font-size: 14px !important;
    margin-bottom: 4px !important;
}

/* Стили для блоков дашбордов */
.dashboard-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 30px;
}

.section-title {
    color: #2c3e50;
    font-size: 1.75rem;
    font-weight: 600;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* Оранжевое подчеркивание для заголовков подрядчиков */
.contractor-title {
    border-bottom-color: #ff9800 !important;
}

/* Оранжевое подчеркивание для заголовка СубПодрядчики */
.subcontractors-title {
    border-bottom-color: #ff9800 !important;
}

/* Красное подчеркивание для заголовка претензий СИП */
.claims-title {
    border-bottom-color: #dc3545 !important;
}

/* Стили для модального окна */
.modal-header {
    padding: 15px 20px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.modal-header .modal-title {
    flex: 1;
    margin: 0;
}

.modal-header .d-flex {
    gap: 10px;
}

#btnExportExcel {
    margin: 0;
    padding: 6px 12px;
    font-size: 0.875rem;
    border-radius: 4px;
}

.btn-close {
    margin: 0 !important;
    padding: 0.5rem !important;
    opacity: 1;
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 10px;
}

.update {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 20px;
}

.chart-wrapper {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    height: 300px;
}

/* Контейнер для главной диаграммы */
.main-chart-wrapper {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    min-height: 300px;
}

/* Контейнер для кольцевых диаграмм */
.d-flex.gap-4 {
    display: flex;
    gap: 1.5rem;
}

/* Адаптивные стили для кнопок переключения режима подсчета */
.dashboard-header {
    width: 100%;
}

.count-mode-toggle {
    width: 100%;
    display: flex;
}

.count-mode-toggle .btn {
    flex: 1;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

@media (min-width: 768px) {
    .count-mode-toggle {
        width: auto;
        display: inline-flex;
    }
    
    .count-mode-toggle .btn {
        flex: none;
        font-size: 1rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (max-width: 768px) {
    .d-flex.gap-4 {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    body {
        padding: 10px;
    }
    
    .dashboard-section {
        padding: 15px;
    }
    
    .section-title {
        font-size: 1.4rem;
    }
    
    .count-mode-toggle {
        width: 100%;
    }
    
    .count-mode-toggle .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }
    
    .dashboard-header .d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .dashboard-header .section-title {
        margin-bottom: 15px !important;
    }
    
    .chart-wrapper {
        height: 220px;
        padding: 12px;
    }
    
    /* Столбцы в строках диаграмм/блоков растягиваем на всю ширину */
    .dashboard-section .d-flex > div {
        min-width: 100% !important;
        width: 100%;
    }
    
    #btnAllContainer, #buttonsContainer {
        gap: 8px;
    }
    
    #btnAllContainer button, #buttonsContainer button {
        width: 100%;
    }
    
    .modal-body {
        height: calc(100vh - 80px);
    }
    
    .modal-body table {
        font-size: 0.78rem;
        min-width: 720px;
    }
    
    .table-wrapper {
        max-height: 60vh;
        overflow-x: auto;
    }
    
    .modal-body table th {
        padding: 8px 6px;
    }
    
    .modal-body table td {
        padding: 6px 6px;
    }
    
    .total-item {
        font-size: 0.95rem;
    }
}

#btnAllContainer, #buttonsContainer {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.btn-primary, .btn-outline-primary {
    transition: 0.3s;
}

.btn-primary:hover {
    filter: brightness(110%);
}


/* Стили для блока субподрядчиков */
.subcontractor-controls {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

#subcontractorSelect {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

#subcontractorSelect option {
    padding: 8px;
    cursor: pointer;
}

#subcontractorSelect option:hover {
    background-color: #e9ecef;
}

#subcontractorSearch {
    position: relative;
    z-index: 10;
}

#subcontractorSelect {
    position: relative;
    z-index: 9;
    margin-top: 5px;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Стили для блока справки */
.subcontractor-report {
    margin-top: 20px;
}

.report-content {
    padding: 20px;
}

.report-item {
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 1.1rem;
}

.report-item:last-child {
    border-bottom: none;
}

.report-item strong {
    color: #2c3e50;
    margin-right: 10px;
}

/* Стили для блока "Важно" */
.report-important {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
}

.report-important h5 {
    color: #856404;
    font-weight: 600;
}

.report-important-item {
    padding: 8px 0;
    color: #856404;
    font-weight: 500;
}

/* Стили для блока с суммами */
.total-item {
    padding: 10px;
    background: white;
    border-radius: 6px;
    border-left: 3px solid #3498db;
    font-size: 1rem;
}

.total-item strong {
    color: #2c3e50;
    margin-right: 8px;
}

.total-item span {
    color: #2c3e50;
    font-weight: 600;
}

/* Оранжевые полоски для элементов подрядчиков (текст остается черным) */
#subcontractorTotals .total-item,
#subcontractorTotalsMain .total-item {
    border-left-color: #ff9800;
}

/* Красные полоски для элементов претензий СИП (текст остается черным) */
#claimsTotals .total-item {
    border-left-color: #dc3545;
}

#totalExecuted,
#totalExecutedSubcontractors,
#totalExecutedSubcontractorsMain {
    color: #27ae60 !important;
}

/* Зеленый цвет для суммы выполнения по договорам с СубПодрядчиками */
#totalExecutedSubcontractors {
    color: #27ae60 !important;
}

/* Кнопки/элементы только для разработчиков */
.dev-only {
    display: none !important;
}

body.show-dev .dev-only {
    display: inline-flex !important;
}

body.show-dev .dev-only.nav-btn {
    display: inline-block !important;
}

/* Глобальное модальное окно загрузки */
#globalLoading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#globalLoading.show {
    display: flex;
}

.global-loading-content {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px 30px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 90%;
}

.global-loading-spinner {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: 0.35rem solid rgba(0, 0, 0, 0.1);
    border-top-color: #0d6efd;
    animation: global-loading-spin 0.8s linear infinite;
}

.global-loading-text {
    color: #2c3e50;
    font-size: 0.95rem;
    text-align: center;
}

@keyframes global-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Стили для кнопок видов работ */
#workTypesButtonsContainer {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow-y: auto;
    overflow-x: hidden; /* Убираем горизонтальную прокрутку */
    word-wrap: break-word;
    max-height: 600px; /* Лимит высоты блока */
    display: flex;
    flex-direction: column;
}

#workTypesButtonsContainer h5 {
    flex-shrink: 0; /* Заголовок не сжимается */
    margin-bottom: 15px;
}

#workTypesButtons {
    overflow-y: auto;
    overflow-x: hidden; /* Убираем горизонтальную прокрутку */
    word-wrap: break-word;
    flex: 1; /* Занимает оставшееся пространство */
    min-height: 0; /* Позволяет flex-элементу сжиматься */
}

.work-type-btn {
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
    transition: all 0.2s;
}

.work-type-btn:hover {
    transform: translateX(2px);
}

.work-type-group {
    margin-bottom: 8px;
}

.work-type-sub-buttons {
    margin-top: 4px;
    margin-left: 12px;
    border-left: 2px solid #dee2e6;
    padding-left: 8px;
}

.work-type-z-group {
    margin-bottom: 4px;
}

/* Стили для блока видов работ в исполнении (субподрядчики) — как в дашборде по заказчикам */
#subcontractorWorkTypesButtonsContainer {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    word-wrap: break-word;
    height: 350px; /* Фиксированная высота как у main-chart-wrapper исполнения */
    display: flex;
    flex-direction: column;
}

#subcontractorWorkTypesButtonsContainer h5 {
    flex-shrink: 0;
    margin-bottom: 15px;
}

#subcontractorWorkTypesButtons {
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    flex: 1;
    min-height: 0;
}

/* Адаптивность для кнопок навигации */
@media (max-width: 768px) {
    .nav-btn {
        padding: 8px 12px !important;
        margin: 5px 3px !important;
        font-size: 0.875rem !important;
        white-space: nowrap;
    }
    
    .d-flex.justify-content-between.align-items-center.flex-wrap > div:first-child {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .d-flex.justify-content-between.align-items-center.flex-wrap > div:last-child {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .nav-btn {
        flex: 1 1 calc(50% - 6px);
        min-width: calc(50% - 6px);
        padding: 10px 8px !important;
        font-size: 0.8rem !important;
    }
}

/* Адаптивность для кнопок видов работ */
@media (max-width: 768px) {
    #workTypesButtonsContainer {
        flex: 1 0 100% !important;
        max-width: 100% !important;
        margin-top: 20px;
    }

    #subcontractorWorkTypesButtonsContainer {
        flex: 1 0 100% !important;
        max-width: 100% !important;
        margin-top: 20px;
        height: auto !important;
        max-height: 300px;
    }
    
    /* Расположение кнопок режима таблицы под кнопкой Excel на мобильных */
    .modal-header {
        position: relative;
    }
    
    .modal-header .d-flex.flex-wrap {
        flex-direction: column;
        align-items: flex-end !important;
        width: 100%;
        padding-right: 0.25rem; /* Уменьшенный отступ от правого края экрана */
        margin-right: 0;
    }
    
    /* Кнопка закрытия в углу */
    .modal-header .btn-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        margin: 0;
        z-index: 10;
        order: -1;
    }
    
    /* Кнопка Excel под кнопкой закрытия */
    .modal-header .excel-button-container {
        width: 100%;
        max-width: 200px; /* Ограничение максимальной ширины, чтобы соответствовать table-mode-mobile */
        margin-bottom: 8px;
        margin-top: 1.5rem; /* Увеличенный отступ сверху, чтобы кнопки были ниже */
        order: 1;
        display: flex;
        justify-content: flex-end;
    }
    
    .modal-header .excel-button-container .btn {
        width: 100%;
        padding: 0.5rem 1rem; /* Увеличенный padding для больших кнопок */
        font-size: 1rem; /* Увеличенный размер шрифта */
    }
    
    .modal-header .excel-button-container .btn svg {
        width: 18px; /* Увеличенный размер иконки */
        height: 18px;
    }
    
    /* Кнопки режима таблицы под кнопкой Excel */
    .modal-header .table-mode-container {
        width: 100%;
        max-width: 200px; /* Ограничение максимальной ширины, чтобы соответствовать excel-button-container */
        order: 2;
        display: flex;
        justify-content: flex-end;
    }
    
    .modal-header .table-mode-mobile {
        width: 100%;
        max-width: 200px; /* Ограничение максимальной ширины, чтобы соответствовать excel-button-container */
        flex-direction: row !important;
        justify-content: space-between;
        margin-top: 0;
    }
    
    .modal-header .table-mode-mobile .btn {
        flex: 1 1 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none !important;
        box-shadow: none !important;
        padding: 0.35rem 1rem; /* Уменьшенный padding по вертикали */
        font-size: 1rem; /* Увеличенный размер шрифта */
        min-height: auto; /* Убрана фиксированная минимальная высота */
    }
    
    .modal-header .table-mode-mobile .btn svg {
        margin-right: 0 !important;
        width: 18px; /* Увеличенный размер иконки */
        height: 18px;
    }
    
    /* Отступ между заголовком и кнопками на мобильных */
    .modal-header .modal-title {
        width: 100%;
        margin-bottom: 0.5rem;
        padding-right: 4rem; /* Уменьшенный отступ справа между текстом заголовка и блоком кнопок */
    }
}

/* Ограничение ширины кнопок на планшетах */
@media (min-width: 769px) and (max-width: 1024px) {
    .modal-header .excel-button-container {
        max-width: 200px;
    }
    
    .modal-header .excel-button-container .btn {
        max-width: 200px;
    }
    
    .modal-header .table-mode-container {
        max-width: 200px;
    }
    
    .modal-header .table-mode-mobile {
        max-width: 200px;
    }
}

/* Стили для группированных строк в таблице договоров */
.group-header {
    background-color: #e9ecef !important;
}

.group-header:hover {
    background-color: #dee2e6 !important;
}

.group-header td {
    background-color: inherit !important;
}

/* Отключаем чередование Bootstrap для заголовков групп */
.table-striped > tbody > tr.group-header {
    background-color: #e9ecef !important;
}

.table-striped > tbody > tr.group-header:nth-of-type(odd),
.table-striped > tbody > tr.group-header:nth-of-type(even) {
    background-color: #e9ecef !important;
}

/* Убираем заливку для детальных строк в таблице договоров - все белые */
.table-striped > tbody > tr.group-detail,
.table-striped > tbody > tr.group-detail:nth-of-type(odd),
.table-striped > tbody > tr.group-detail:nth-of-type(even),
.table-striped > tbody > tr.group-detail:nth-child(odd),
.table-striped > tbody > tr.group-detail:nth-child(even) {
    background-color: #ffffff !important;
}

.table-striped > tbody > tr.group-detail td,
.table-striped > tbody > tr.group-detail:nth-of-type(odd) td,
.table-striped > tbody > tr.group-detail:nth-of-type(even) td,
.table-striped > tbody > tr.group-detail:nth-child(odd) td,
.table-striped > tbody > tr.group-detail:nth-child(even) td {
    background-color: #ffffff !important;
}

/* Убираем заливку для таблицы претензий - все строки белые */
#claimsTableContent .table-striped > tbody > tr,
#claimsTableContent .table-striped > tbody > tr:nth-of-type(odd),
#claimsTableContent .table-striped > tbody > tr:nth-of-type(even),
#claimsTableContent .table-striped > tbody > tr:nth-child(odd),
#claimsTableContent .table-striped > tbody > tr:nth-child(even),
#claimsTableContent .table-striped tbody tr,
#claimsTableContent .table-striped tbody tr:nth-of-type(odd),
#claimsTableContent .table-striped tbody tr:nth-of-type(even) {
    background-color: #ffffff !important;
}

#claimsTableContent .table-striped > tbody > tr td,
#claimsTableContent .table-striped > tbody > tr:nth-of-type(odd) td,
#claimsTableContent .table-striped > tbody > tr:nth-of-type(even) td,
#claimsTableContent .table-striped > tbody > tr:nth-child(odd) td,
#claimsTableContent .table-striped > tbody > tr:nth-child(even) td,
#claimsTableContent .table-striped tbody tr td {
    background-color: #ffffff !important;
}

/* Убираем заливку для всех строк в таблице detailModal (договоры) */
#detailModal .table-striped > tbody > tr:not(.group-header),
#detailModal .table-striped > tbody > tr:not(.group-header):nth-of-type(odd),
#detailModal .table-striped > tbody > tr:not(.group-header):nth-of-type(even),
#detailModal .table-striped > tbody > tr:not(.group-header):nth-child(odd),
#detailModal .table-striped > tbody > tr:not(.group-header):nth-child(even) {
    background-color: #ffffff !important;
}

#detailModal .table-striped > tbody > tr:not(.group-header) td,
#detailModal .table-striped > tbody > tr:not(.group-header):nth-of-type(odd) td,
#detailModal .table-striped > tbody > tr:not(.group-header):nth-of-type(even) td {
    background-color: #ffffff !important;
}

/* В комбинированной вкладке убираем лишний отступ сверху у блока "диаграммы по видам работ" */
.combined-dynamics-host .mt-4 {
    margin-top: 0 !important;
}

#sectionCombined .mt-4 {
    margin-top: 0 !important;
}


