/* ===== Базовая таблица ===== */
.workload-table {
    min-width: 100%;
    width: auto;
    border-collapse: separate;
    border-spacing: 0;
}

.workload-table thead{
    position: sticky;
    z-index: 7;
    top:0;
}

.workload-table th,
.workload-table td {
    border: 1px solid var(--main-delimiter);
    padding: 0;
    text-align: center;
    font-size: 11px;
    height: 20px;
    min-width: 14px;
}

.workload-table th {
    background: var(--main-background);
    font-weight: bold;
    font-size: 10px;
    padding: 3px;
    text-align: center !important;
    max-width: 14px;
}

.workload-table tbody td.object-name {
    position: sticky;
    left: 0;
    z-index: 5;
    background-color: var(--main-background);
    box-shadow: 2px 0 3px rgba(0,0,0,0.1);
}

.workload-table tr:hover {
    background-color: var(--main-hover-interact);
}

.workload-table th.location-title,
.workload-table td.object-name {
    position: sticky;
    left: 0;
    z-index: 99999;
    background: var(--main-background);
    min-width: 240px;
}

/* ===== контейнер и заголовок ===== */
.workload-table-desc {
    background: var(--main-background);
    margin: 0;
    padding: 5px;
    border: 1px solid var(--main-delimiter);
    border-bottom: 0;
}

.workload-table-container {
    position: relative;
    overflow: auto;
    width: 100%;
    max-height: calc(100vh - 225px);
    background: var(--main-background);
}

/* ===== заголовок и название объектов ===== */
.workload-table .object-name-title {
    text-align: center;
    font-weight: bold;
    min-width: 170px;
    position: sticky;
    left: 0;
    padding: 5px;
    background: var(--main-background);
    z-index: 2;
    color: var(--main-text-color);
}

.workload-table .object-name {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-content: center;
    border: 1px solid var(--main-delimiter);
    text-align: left;
    font-weight: bold;
    padding: 5px;
    background-color: var(--main-background);
    z-index: 1;
    color: var(--main-text-color);
}

.workload-table .month-header {
    position: relative;
    background: var(--main-background);
    font-weight: bold;
    text-align: center !important;
    padding: 5px;
    color: var(--main-text-color);
    z-index: 5;
}

.workload-table .month-nav-prev {
    position: absolute;
    color: var(--color-blue);
    left: 10px;
}

.workload-table .month-nav-next {
    position: absolute;
    color: var(--color-blue);
    right: 10px;
}

.workload-table .month-nav-prev:hover, .workload-table .month-nav-next:hover{
    text-decoration: underline;
    opacity: 0.7;
}

/* ===== ячейки дней ===== */
.workload-table .day-cell {
    max-width: 14px;
    text-align: center;
    cursor: default;
    color: var(--main-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
}

/* ===== Цветовые ячейки ===== */
.wl-main-text-color-beauty,
.wl-green,
.wl-fade-green,
.wl-light-yellow,
.wl-orange,
.wl-light-orange,
.wl-light-blue {
    border: unset !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
}

.wl-main-text-color-beauty { background-color: var(--main-background-invert);color: var(--main-text-invert-color)!important; }
.wl-green { background-color: var(--green); }
.wl-fade-green { background-color: var(--fade-green); }
.wl-light-yellow { background-color: var(--light-yellow); }
.wl-orange { background-color: var(--orange); }
.wl-light-orange { background-color: var(--light-orange); }
.wl-light-blue { background-color: var(--light-blue); }

/* ===== выделение ячеек ===== */
.day-cell.selected {
    max-width: 14px;
    position: relative;
    background-color: rgba(102, 177, 252, 0.3) !important;
    border: unset;
}

.day-cell.selected-left {
    position: relative;

}

.day-cell.selected-right {
    position: relative;

}

.day-cell.selected-month {
    position: relative;
}

/* ===== контекстное меню ===== */
.workload-context-menu {
    display: none;
    position: absolute;
    z-index: 1000;
    background: var(--main-background);
    border: 1px solid var(--main-delimiter);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    color: var(--main-text-color);
}

.workload-context-menu-item {
    padding: 5px 15px;
    cursor: pointer;
    color: var(--main-text-color);
}

.workload-context-menu-item:hover {
    background-color: var(--main-hover-interact);
}

/* ===== перетаскивания ===== */
.drag-ghost {
    position: absolute;
    background: var(--main-background);
    border: 1px solid var(--color-blue);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
}

.drag-ghost > div {
    padding: 5px;
    border-right: 1px solid #eee;
}

.dragging {
    opacity: 0.5;
    color: var(--main-text-color);
}

/* ===== области для перетаскивания ===== */
.drop-row-valid {
    background-color: rgba(100, 255, 100, 0.1);
}

.drop-row-invalid {
    background-color: rgba(255, 100, 100, 0.1);
}

.drop-target-valid {
    box-shadow: 0 0 0 2px #4a90e2 inset;
    background-color: rgba(74, 144, 226, 0.1);
}

.drop-target-invalid {
    box-shadow: 0 0 0 2px #ff6b6b inset;
    background-color: rgba(255, 107, 107, 0.1);
}

/* ===== редактирование ячеек ===== */
.day-cell input {
    background-color: inherit;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    text-align: center;
    outline: none;
    width: 100%;
    height: 100%;
    border: none;
    padding: 0 5px;
    box-sizing: border-box;
}

.day-cell.editing {
    border: 2px solid #0066cc;
    position: relative;
    z-index: 10;
}

/* ===== tooltip ===== */
.day-cell[title] {
    position: relative;
    cursor: help;
}

.day-cell[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: black;
    border-radius: 3px;
    white-space: normal;
    word-wrap: break-word;
    z-index: 100;
    font-size: 12px;
    pointer-events: none;
    margin-bottom: 5px;
}

/* ===== уведомления ===== */
.notify-success,
.notify-error {
    padding: 15px;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    color: var(--main-text-invert-color);
}

.notify-success { background-color: #4CAF50; }
.notify-error { background-color: #f44336; }


/* ===== disabled-section ===== */
.disabled-section {
    opacity: 0.7;
    pointer-events: none;
}

.disabled-section::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
            45deg,
            var(--main-hover-interact),
            var(--main-hover-interact) 1px,
            transparent 1px,
            transparent 5px
    );
}

/* Добавляем стили для стрелочек */
.resize-handle {
    position: absolute;
    top: 10px;
    width: 10px;
    cursor: ew-resize;
    z-index: 1;
}
.resize-handle::after {
    content: "";
    position: absolute;
    top: 40%;
    width: 0;
    height: 0;
    border-style: solid;
}

.resize-handle-left {
    left: -5px;
}

.resize-handle-right {
    right: -1px;
}

.resize-handle-left::after {
    border-width: 5px 5px 5px 0;
    border-color: transparent var(--main-text-invert-color) transparent transparent;
}
.resize-handle-right::after {
    border-width: 5px 0 5px 5px;
    border-color: transparent transparent transparent var(--main-text-invert-color);
}

/* Текст */
.prostoy-text,
.section-text {
    position: absolute;
    top: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    line-height: 1.2;
    padding: 0 5px;
    box-sizing: border-box;
}

/* tooltip */
.workload-tooltip {
    position: absolute;
    background: var(--main-background);
    color: var(--main-text-color);
    padding: 8px 12px;
    border: 1px solid var(--main-delimiter);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    white-space: normal;
    word-wrap: break-word;

    /* Плавное появление */
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.workload-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.drop-target-valid {
    background-color: rgba(0, 255, 0, 0.2) !important;
    box-shadow: inset 0 0 0 2px rgba(0, 255, 0, 0.5);
}

.drop-target-invalid {
    background-color: rgba(255, 0, 0, 0.2) !important;
    box-shadow: inset 0 0 0 2px rgba(255, 0, 0, 0.5);
}

.drop-row-valid {
    background-color: rgba(0, 255, 0, 0.1) !important;
}

.drop-row-invalid {
    background-color: rgba(255, 0, 0, 0.1) !important;
}

.day-cell {
    cursor: pointer;
}

.day-cell.selected {
    cursor: grab;
}

.day-cell.selected:active {
    cursor: grabbing;
}

.resize-handle {
    cursor: ew-resize;
}

.location-header {
    background-color: #f0f0f0;
    font-weight: bold;
}
.location-name {
    position: sticky!important;
    left: 0;
    z-index: 6!important;
    padding: 8px;
    background-color: var(--main-background);
}

#workload-shift-sections {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

#workload-shift-sections + span {
    font-size: 14px;
    user-select: none;
}

/* Стили для кнопок управления кустами */

.workload-table .rig-controls-title {
    flex-wrap: nowrap;
}

.workload-table .rig-controls {
    visibility: hidden;
    display: flex;
    justify-content: space-between;
    color: var(--main-text-color) !important;
    filter: var(--main-color-filter);
}

.workload-table .object-name:hover .rig-controls {
    display: flex;
    justify-content: space-between;
}

.workload-table .rig-control-btn {
    width: 28px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    box-shadow: none;
    filter: var(--main-color-filter);
}

.workload-table .rig-control-btn:hover {
    border-radius: 4px;
    opacity: 0.3;
    background: none !important;
}

.workload-table .rig-control-btn svg {
    width: 16px;
    height: 16px;
}

.workload-table .hoverable-row:hover .rig-controls {
    visibility: visible;
}

.workload-table tbody tr,
.workload-table tbody tr .day-cell {
    transition: background-color 0.2s ease;
}

.workload-table {
    outline: none;
}

.workload-table:focus {
    box-shadow: 0 0 0 2px rgba(0, 119, 204, 0.3);
}

.workload .wl-red {
    background-color: #ff0000; /* Красный цвет */
    color: var(--main-text-color) !important;
}

/* Для отключенных ПРОСТОЕВ */
.workload .disabled-section.wl-red {
    background-color: #ff9999 !important;
    color: var(--main-text-color) !important;
}


/* Добавим в workload.css */
.workload .prostoy-element {
    position: absolute;
    background-color: var(--color-red);
    border: 2px solid var(--red);
    border-radius: 4px;
    z-index: 1000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--main-text-invert-color);
    font-weight: bold;
    box-sizing: border-box;
    user-select: none;
    height: 20px !important;
    transition: opacity 0.2s ease;
    will-change: transform;
}

.workload .prostoy-element.selected {
    opacity: 0.7;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #007bff;
    z-index: 10;
}
.workload .section-resize,
.workload .prostoy-resize {
    position: absolute;
    top: 0;
    height: 100%;
    width: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--main-text-color);
    z-index: 1001;
}

.workload .prostoy-resize-left {
    left: 0;
}

.workload .prostoy-resize-right {
    right: 0;
}
.workload .section-element, .workload .prostoy-element {
    font-size: 8pt;
}

.workload .prostoy-element:hover,
.workload .section-element:hover {
    box-shadow: 0 0 5px 2px var(--main-delimiter-light);
    z-index: 1002;
}

.current-date-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-right: 2px dashed var(--red);
    pointer-events: none;
    z-index: 3;
}

.current-date-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -25px;
    right: -3px;
    height: 100%;
    background: linear-gradient(90deg,rgba(255,255,255,0) 0%, var(--main-hover-interact-outline) 90%, rgba(255,255,255,0) 100%);
}

.day-cell.paste-available {
    background-color: rgba(76, 175, 80, 0.3) !important;
    outline: 1px dashed #4CAF50 !important;
}

.day-cell.paste-unavailable {
    background-color: rgba(244, 67, 54, 0.3) !important;
    outline: 1px dashed #F44336 !important;
}

.section-element.paste-target {
    box-shadow: 0 0 0 3px #2196F3;
}


.section-element.overlap-warning {
    background-color: #ffcccc !important;
    outline: 2px solid #ff6666 !important;
}

.prostoy-partial,
.section-partial {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
}

.prostoy-partial .section-resize,
.section-partial .section-resize {
    display: none !important;
}

/* ===== Панель управления ===== */
.workload-edit-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Расположение кнопок в правом верхнем углу */
.workload {
    position: relative;
}

.workload > div:first-child {
    position: relative;
}

.workload > div:first-child > div:last-child {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}