/* Стили для KPI-таблицы, перенесённые буква в букву из inline <style> блока
   zzd-php/_kpi_table.php (строки 200-662). Кастомные правила, отсутствующие
   в bootstrap/theme/iconkit. */

.week-header {
    background-color: #f8f9fa;
    font-weight: bold;
    border-left: 2px solid rgb(151, 151, 151) !important;
    border-right: 2px solid rgb(151, 151, 151) !important;
}

.border-right {
    border-right: 2px solid rgb(151, 151, 151) !important;
}

.border-left {
    border-left: 2px solid rgb(151, 151, 151) !important;
}

.day-cell {
    min-width: 100px;
    max-width: 100px;
}

.day-cell input {
    width: 100%;
    padding: 2px 4px;
    font-size: 12px;
    text-align: center;
    border: 1px solid #ddd;
}

/* Стили для input с символом внутри */
.input-with-symbol {
    position: relative;
    width: 100%;
}

/* Отступ справа для input с символом - используем более специфичный селектор */
.day-cell .input-with-symbol input.input-with-padding,
.month-plan-ascending .input-with-symbol input.input-with-padding,
.month-plan .input-with-symbol input.input-with-padding {
    padding: 2px 4px !important;
    padding-right: 17px !important;
}

.input-with-symbol .value-symbol {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 12px;
    color: #6c757d;
    user-select: none;
    line-height: 1;
}

/* Стили для ячеек значений - запрет переноса текста */
.month-fact,
.week-fact,
.week-plan,
.formula-value {
    white-space: nowrap;
}

.day-header {
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    padding: 4px 2px;
    background-color: #e9ecef;
}

.weekend {
    /* background-color:rgb(255, 250, 254); */
}

.other-month {
    background-color: #f8f9fa;
    opacity: 0.6;
}

.other-month input {
    background-color: #e9ecef;
    color: #6c757d;
}

/* Стили для стрелок перемещения */
.move-arrows {
    display: none;
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.move-arrows .btn {
    padding: 2px 6px;
    font-size: 10px;
    line-height: 1;
    margin: 1px;
    border-radius: 3px;
}

.table-row-wrapper {
    position: relative;
}

.table-row-wrapper:hover .move-arrows {
    display: block;
}

/* Стрелки в ячейке — flex, чтобы ореолы не налезали друг на друга */
.move-arrows-inline {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    min-height: 20px;
    border: none !important;
    background: transparent !important;
    width: 30px;
    min-width: 30px;
    max-width: 30px;
}

.move-arrows-inline a {
    flex: 0 0 auto;
    color: #007bff;
    text-decoration: none;
    font-size: 20px;
    display: none;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.2s;
    z-index: 10;
}

.move-arrows-inline .move-up {
    order: 1;
    transition: all 0.2s ease;
}

.move-arrows-inline .move-down {
    order: 2;
    transition: all 0.2s ease;
}

.move-arrows-inline .move-up:hover {
    color: #0056b3;
    text-decoration: none;
    transform: scale(1.2);
    background-color: rgba(0, 123, 255, 0.1);
    border-radius: 3px;
}

.move-arrows-inline .move-down:hover {
    color: #0056b3;
    text-decoration: none;
    transform: scale(1.2);
    background-color: rgba(0, 123, 255, 0.1);
    border-radius: 3px;
}

.move-arrows-inline a:hover {
    color: #0056b3;
    text-decoration: none;
}

.table-row-wrapper:hover {
    background-color: #e5edf5 !important;
}

.table-row-wrapper:hover td {
    background-color: #e5edf5 !important;
}

/* Hover эффект для sticky столбцов тоже должен работать */
.table-row-wrapper:hover .sticky-column {
    background-color: #e5edf5 !important;
}

.table-row-wrapper:hover .move-arrows-inline a {
    display: block;
}



/* Стиль для текущего дня (только заголовок) */
.kpi-table thead th.day-header.today-current,
.kpi-table thead .day-header.today-current {
    background-color: #b8d4f0 !important;
    font-weight: bold !important;
}

/* Цвет подсветки заголовка даты при наведении на ячейку дня */
.kpi-table thead th.day-header.header-highlighted,
.kpi-table thead .day-header.header-highlighted {
    background-color:rgb(207, 219, 231) !important;
}

/* Подсветка строки после перемещения */
.row-highlighted {
    background-color: #fff3cd !important;
    transition: background-color 0.5s ease;
}

.month-plan-ascending, .month-plan, .month-fact, .month-percent {
    font-weight: bold;
    text-align: center;
}

.month-plan-ascending input {
    width: 100%;
    min-width: 100px;
    text-align: center;
}

.month-plan input {
    width: 100%;
    min-width: 100px;
    text-align: center;
}

.week-plan, .week-fact, .week-percent {
    text-align: center;
    opacity: 0.5;
}

/* Стили для значений формул */
.formula-value {
    display: block;
    padding: 2px 4px;
    font-size: 12px;
    text-align: center;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    color: #495057;
    font-weight: 500;
}

/* Стили для границ каналов */
.channel-top-border {
    border-top: 3px solid #000000 !important;
}

.channel-bottom-border {
    border-bottom: 3px solid #000000 !important;
}

/* Компактные строки таблицы */
.kpi-table td,
.kpi-table th {
    padding: 4px 4px !important;
    vertical-align: middle;
    line-height: 1.3;
}

.kpi-table thead th {
    padding: 6px 8px !important;
}

/* Компактные input поля */
.kpi-table input.form-control,
.kpi-table input.form-control-sm {
    padding: 2px 4px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
    height: auto !important;
    min-height: 24px;
}

.kpi-table .month-plan-ascending input,
.kpi-table .month-plan input {
    min-width: 100px !important;
    padding: 2px 4px !important;
}

/* Компактные значения формул */
.kpi-table .formula-value {
    padding: 1px 3px !important;
    font-size: 11px !important;
    line-height: 1.2;
}

/* Компактные процентные значения */
.kpi-table .month-percent,
.kpi-table .week-percent {
    font-size: 12px;
    padding: 2px 4px;
}

/* Уменьшаем размер шрифта в ячейках */
.kpi-table td strong {
    font-size: 13px;
    font-weight: 600;
}

/* Компактные ячейки дней */
.kpi-table .day-cell input {
    padding: 1px 2px !important;
    font-size: 12px !important;
    min-height: 22px;
}

/* Фиксирование заголовков и столбцов через sticky */
.card-body {
    overflow: visible !important;
}

.table-responsive {
    position: relative;
    overflow: auto;
    max-height: calc(100vh - 300px);
    isolation: isolate;
}

/* Классы для фиксированных элементов (будут применяться через JS) */
.kpi-table .sticky-header-row-1 {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 11;
    background-color: #e9ecef !important;
    will-change: transform;
}

.kpi-table .sticky-header-row-2 {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f8f9fa !important;
    will-change: transform;
}

.kpi-table .sticky-column {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    z-index: 5;
    background-color: white !important;
    will-change: transform;
}

/* Комбинация: заголовок + столбец */
.kpi-table .sticky-header-row-1.sticky-column {
    z-index: 13;
    background-color: #e9ecef !important;
}

.kpi-table .sticky-header-row-2.sticky-column {
    z-index: 12;
    background-color: #f8f9fa !important;
}

.kpi-table tbody .sticky-column {
    background-color: white !important;
}

/* Тень для разделения фиксированных элементов */
.kpi-table .sticky-column.last-fixed-col {
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.kpi-table .sticky-header-row-2:not(.sticky-column) {
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Внутренние границы через inset box-shadow */
.kpi-table .sticky-column {
    box-shadow: inset -1px 0 0 #dee2e6;
}

.kpi-table .sticky-column.last-fixed-col {
    box-shadow: inset -2px 0 0 #adb5bd, 2px 0 5px rgba(0,0,0,0.1);
}

.kpi-table .sticky-header-row-1,
.kpi-table .sticky-header-row-2 {
    box-shadow: inset 0 -1px 0 #dee2e6;
}

.kpi-table .sticky-header-row-2:not(.sticky-column) {
    box-shadow: inset 0 -2px 0 #adb5bd, 0 2px 5px rgba(0,0,0,0.1);
}

/* Комбинация заголовок + столбец - объединяем тени */
.kpi-table .sticky-header-row-1.sticky-column {
    box-shadow: inset -1px 0 0 #dee2e6, inset 0 -1px 0 #dee2e6;
}

.kpi-table .sticky-header-row-1.sticky-column.last-fixed-col {
    box-shadow: inset -2px 0 0 #adb5bd, inset 0 -1px 0 #dee2e6, 2px 0 5px rgba(0,0,0,0.1);
}

.kpi-table .sticky-header-row-2.sticky-column {
    box-shadow: inset -1px 0 0 #dee2e6, inset 0 -1px 0 #dee2e6;
}

.kpi-table .sticky-header-row-2.sticky-column.last-fixed-col {
    box-shadow: inset -2px 0 0 #adb5bd, inset 0 -1px 0 #dee2e6, 2px 0 5px rgba(0,0,0,0.1);
}

/* Для ячеек с colspan важно: left устанавливается вручную через inline стиль */
.kpi-table .sticky-column {
    box-sizing: border-box;
}

/* Стили для иконок решений по неделям */
.week-solution-icon {
    cursor: pointer;
    color: #6c757d;
    font-size: 14px;
    padding: 2px 4px;
    position: relative;
    transition: color 0.2s;
    display: inline-block;
}

.week-solution-icon:hover {
    color: #007bff;
}

.week-solution-icon.has-solution::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background-color: #28a745;
    border-radius: 50%;
    border: 1px solid white;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

.week-solution-cell {
    min-width: 30px;
    max-width: 30px;
    padding: 4px 2px;
    vertical-align: middle;
}
