/* static/css/orders.css | A.Grachev */
/* ===== ЗАКАЗЫ ===== */

/* Карточка заказа */
.order-card {
    border-left: 4px solid #0d6efd;
    transition: box-shadow 0.2s;
    cursor: pointer;
}

.order-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.order-card .card-header {
    background-color: transparent;
    border-bottom: 1px solid #e9ecef;
}

.order-card .card-body {
    padding: 16px 20px;
}

/* =========================================================
   СТАТУСЫ ЭТАПОВ (расширение)
   ========================================================= */

/* PENDING — ожидает назначения */
.badge-status-order.pending {
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #dee2e6;
}

/* ASSIGNED — назначен */
.badge-status-order.assigned {
    background-color: #cfe2ff;
    color: #0a58ca;
    border: 1px solid #b6d4fe;
}

/* MATERIAL_DEFICIT — дефицит материалов */
.badge-status-order.material_deficit {
    background-color: #dc3545;
    color: #fff;
    animation: pulse-deficit 1.8s infinite;
}

@keyframes pulse-deficit {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.75;
    }
}

/* IN_PROGRESS — в работе (уже есть, но дублируем для явности) */
.badge-status-order.in_progress {
    background-color: #0dcaf0;
    color: #055160;
    border: 1px solid #9eeaf9;
}

/* COMPLETED — выполнен */
.badge-status-order.completed {
    background-color: #198754;
    color: #fff;
    border: 1px solid #146c43;
}

/* DEFECT — брак */
.badge-status-order.defect {
    background-color: #dc3545;
    color: #fff;
    border: 1px solid #b02a37;
}

/* PROBLEM — проблема */
.badge-status-order.problem {
    background-color: #ffc107;
    color: #664d03;
    border: 1px solid #ffca2c;
}

/* ON_HOLD — приостановлен */
.badge-status-order.on_hold {
    background-color: #fd7e14;
    color: #fff;
    border: 1px solid #e8590c;
}

/* CANCELLED — отменён */
.badge-status-order.cancelled {
    background-color: #6c757d;
    color: #fff;
    border: 1px solid #5c636a;
    text-decoration: line-through;
}

/* =========================================================
   Общие доработки
   ========================================================= */

/* Убедимся, что у бейджа статуса всегда есть фон */
.badge-status-order {
    white-space: nowrap;
}

/* Приоритеты */
.badge-priority {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-priority.high {
    background-color: #dc3545;
    color: #fff;
}

.badge-priority.medium {
    background-color: #ffc107;
    color: #212529;
}

.badge-priority.low {
    background-color: #198754;
    color: #fff;
}

/* Этапы в карточке заказа */
.stage-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.stage-list .stage-item {
    display: flex;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f1f3f5;
    gap: 12px;
}

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

.stage-item .stage-number {
    font-weight: 600;
    color: #6c757d;
    min-width: 30px;
}

.stage-item .stage-name {
    flex: 1;
}

.stage-item .stage-status {
    font-size: 0.7rem;
}

/* =========================================================
   ГАНТ-ДИАГРАММА В СПИСКЕ ЗАКАЗОВ
   ========================================================= */
#ordersGanttChart {
    background: #fff;
    border-radius: 8px;
}

#ordersGanttChart .gantt .bar {
    border-radius: 4px;
    opacity: 0.9;
    transition: opacity 0.2s;
    cursor: pointer;
}

#ordersGanttChart .gantt .bar:hover {
    opacity: 1;
    filter: brightness(1.1);
}

#ordersGanttChart .gantt .bar-progress {
    border-radius: 4px;
}

#ordersGanttChart .gantt .bar-label {
    font-size: 10px;
    font-weight: 500;
    fill: #fff;
}

#ordersGanttChart .gantt .grid-header {
    fill: #f8f9fa;
}

#ordersGanttChart .gantt .grid-header text {
    fill: #495057;
    font-weight: 600;
    font-size: 11px;
}

#ordersGanttChart .gantt .today {
    fill: rgba(13, 110, 253, 0.1);
    stroke: #0d6efd;
    stroke-width: 1.5;
}

/* Цвета статусов */
#ordersGanttChart .gantt .bar.pending {
    fill: #6c757d;
}

#ordersGanttChart .gantt .bar.assigned {
    fill: #0d6efd;
}

#ordersGanttChart .gantt .bar.in_progress {
    fill: #0dcaf0;
}

#ordersGanttChart .gantt .bar.completed {
    fill: #198754;
}

#ordersGanttChart .gantt .bar.defect {
    fill: #dc3545;
}

#ordersGanttChart .gantt .bar.problem {
    fill: #ffc107;
}

#ordersGanttChart .gantt .bar.on_hold {
    fill: #fd7e14;
}

/* Статус "На паузе" */
.badge-status-order.paused {
    background-color: #ffc107;
    color: #664d03;
    border: 1px solid #ffca2c;
    animation: pulse-paused 1.8s infinite;
}

@keyframes pulse-paused {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}


/*Мягкая подсветка в заказах с браком */
.order-row.has-defect {
    background-color: rgba(220, 53, 69, 0.06);
}

.order-row.has-defect:hover {
    background-color: rgba(220, 53, 69, 0.12);
}

.order-row.has-defect td:first-child {
    border-left: 4px solid #dc3545;
}

/*Мягкая подсветка в заказах с проблемой */ 
.order-row.has-problem {
    background-color: rgba(220, 53, 69, 0.08);
}

.order-row.has-problem:hover {
    background-color: rgba(220, 53, 69, 0.15);
}

.order-row.has-problem td:first-child {
    border-left: 4px solid #ff9800;
}
/* =========================================================
   ПУЛЬСИРУЮЩИЙ БЕЙДЖ ПРОБЛЕМЫ
   ========================================================= */

.badge-problem-pulse {
    animation: problem-pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
}

@keyframes problem-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(220, 53, 69, 0);
        transform: scale(1.08);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
        transform: scale(1);
    }
}

/* Заказы с открытыми ТПП — мягкая жёлто-оранжевая подсветка */
.order-row.has-tpp {
    background-color: rgba(255, 152, 0, 0.08);
}

.order-row.has-tpp:hover {
    background-color: rgba(255, 152, 0, 0.15);
}


/* Неполный материал — серая подсветка */
.material-row.incomplete td {
    background-color: rgba(108, 117, 125, 0.12) !important;
}

.material-row.incomplete:hover td {
    background-color: rgba(108, 117, 125, 0.2) !important;
}

.material-row.incomplete td:first-child {
    border-left: 4px solid #6c757d;
}

/* =========================================================
   ✅ БЛОКИРОВКА DRAG В FRA PPE GANTT
   ========================================================= */
.gantt .bar-wrapper,
.gantt .bar-wrapper .bar,
.gantt .bar-wrapper .handle {
    cursor: pointer !important;
    pointer-events: auto !important;
}

/* Но отключаем drag-курсор */
.gantt-container .bar-wrapper,
.gantt-container .bar {
    cursor: pointer !important;
}

/* Скрываем ручки для растягивания (если есть) */
.gantt .handle {
    display: none !important;
}