/* ============================================================
   Единый файл стилей для колонок и досок: Канбан, Мой план, Сроки
   Загружается в <head> для устранения FOUC и предотвращения сжатия колонок
   ============================================================ */

/* 1. ОБЩИЙ КОНТЕЙНЕР ОСНОВНОГО КОНТЕНТА */
@media (min-width: 769px) {
    .main-content {
        margin-right: 70px !important; /* Фиксированный отступ под правый Bitrix сайдбар */
    }
}

/* 2. РАЗДЕЛ «МОЙ ПЛАН» (Персональный канбан с настраиваемыми колонками) */
.my-plan-board-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.my-plan-board {
    min-width: 100%;
    display: flex !important;
    align-items: flex-start;
    gap: 16px !important;
    margin: 0 !important;
}

/* Колонка раздела «Мой план» — строго фиксированная ширина для устранения FOUC и гармонизации */
.my-plan-column {
    min-width: 300px !important;
    max-width: 315px !important;
    width: 305px !important;
    flex: 0 0 305px !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 145px);
}

[data-theme="dark"] .my-plan-column {
    background: #141d2b !important;
    border: 1px solid #1f2d42 !important;
}

.my-plan-column.dragging {
    opacity: 0.45;
    transform: scale(0.98);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.my-plan-column.column-drag-over {
    box-shadow: 0 0 0 2px #3b82f6 !important;
}

.my-plan-stage-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.my-plan-column-drag-handle {
    cursor: grab;
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.my-plan-column-drag-handle:hover {
    opacity: 1;
}

.my-plan-robot-btn {
    position: relative;
    color: #94a3b8;
    background: transparent;
    border: none;
    padding: 4px 8px;
}

.my-plan-robot-btn:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.my-plan-robot-btn.has-robots {
    color: #3b82f6;
}

.my-plan-robot-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #3b82f6;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.my-plan-dropzone {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex-grow: 1;
    min-height: 140px;
    max-height: calc(100vh - 180px) !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    display: block !important;
    padding: 8px 6px !important;
}

.my-plan-dropzone.dropzone-over {
    background-color: rgba(59, 130, 246, 0.06) !important;
    outline: 2px dashed rgba(59, 130, 246, 0.4) !important;
    border-radius: 12px;
}

.my-plan-dropzone .dt-task-card {
    width: 100% !important;
    margin-bottom: 10px !important;
    flex-shrink: 0 !important;
}

.my-plan-dropzone .dt-task-card.task-hidden {
    display: none !important;
}

.my-plan-add-stage-card {
    min-width: 280px;
    max-width: 280px;
    width: 280px;
    min-height: 220px;
    flex-shrink: 0;
    cursor: pointer;
    background: transparent !important;
    border: 2px dashed #cbd5e1 !important;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    font-family: inherit;
    text-decoration: none;
    outline: none;
}

.my-plan-add-stage-card:hover {
    border-color: #3b82f6 !important;
    background: rgba(59, 130, 246, 0.03);
    transform: translateY(-2px);
}

.my-plan-add-stage-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.my-plan-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.my-plan-color-swatch:hover,
.my-plan-color-swatch.active {
    transform: scale(1.18);
    border-color: #0f172a;
}

/* 3. РАЗДЕЛ «СРОКИ» */
.deadline-container {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.deadline-columns {
    display: flex !important;
    align-items: flex-start;
    gap: 16px !important;
    min-width: 100%;
    margin: 0 !important;
}

.deadline-column {
    min-width: 300px !important;
    max-width: 315px !important;
    width: 305px !important;
    flex: 0 0 305px !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.deadline-column .card {
    max-height: calc(100vh - 145px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header.bg-teal {
    background-color: #20c997 !important;
}

.card-header.bg-purple {
    background-color: #6f42c1 !important;
}

.deadline-dropzone {
    min-height: 140px;
    max-height: calc(100vh - 180px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 8px 6px !important;
}

.deadline-dropzone .dt-task-card {
    width: 100% !important;
}

@media (max-width: 768px) {
    .deadline-columns {
        flex-direction: column;
    }
    .deadline-column {
        width: 100% !important;
        min-width: 100% !important;
        flex: 1 1 100% !important;
        margin-bottom: 16px;
    }
}

/* 4. РАЗДЕЛ «КАНБАН» (5 колонок) */
.kanban-board-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.kanban-board-wrapper > .row {
    display: flex !important;
    flex-wrap: nowrap !important;
    min-width: min-content;
    gap: 16px !important;
    margin: 0 !important;
}

.col-md-2-4 {
    min-width: 300px !important;
    max-width: 315px !important;
    width: 305px !important;
    flex: 0 0 305px !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.kanban-board-wrapper .card {
    max-height: calc(100vh - 145px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dropzone {
    min-height: 140px;
    max-height: calc(100vh - 180px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 8px 6px !important;
    border-radius: 8px;
}

/* Slim scrollbars for dropzones */
.dropzone::-webkit-scrollbar,
.my-plan-dropzone::-webkit-scrollbar,
.deadline-dropzone::-webkit-scrollbar {
    width: 5px;
}

.dropzone::-webkit-scrollbar-thumb,
.my-plan-dropzone::-webkit-scrollbar-thumb,
.deadline-dropzone::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 4px;
}

.dropzone::-webkit-scrollbar-thumb:hover,
.my-plan-dropzone::-webkit-scrollbar-thumb:hover,
.deadline-dropzone::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

.dropzone-over {
    outline: 2px dashed rgba(25, 135, 84, 0.35);
    background: rgba(25, 135, 84, 0.04);
}

.drag-preview {
    opacity: 1;
    background: white;
    border-radius: 12px;
}

/* 5. СТАБИЛИЗАЦИЯ ВЛОЖЕНИЙ И КАРТИНОК В КАРТОЧКАХ (Предотвращение вертикального дергания и CLS) */
.dt-card__media {
    margin: 8px 0 10px 0;
    border-radius: 8px;
    overflow: hidden;
    contain: layout paint;
    min-height: 80px;
    background-color: rgba(148, 163, 184, 0.05);
}

.dt-card__media img.task-thumbnail {
    display: block;
    max-width: 100%;
    width: 100%;
    border-radius: 8px;
    background-color: rgba(148, 163, 184, 0.1);
    transition: transform 0.2s ease;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.dt-card__media img.task-thumbnail:hover {
    transform: scale(1.02);
}

/* Плавный пульс-эффект при обновлении карточки по WebSocket в реальном времени */
@keyframes realtimeCardPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.25);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.dt-task-card--realtime-updated {
    animation: realtimeCardPulse 1.2s ease-out;
}

@keyframes realtimeCardSlideIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dt-task-card--realtime-new {
    animation: realtimeCardSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-xs {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
}

.task-thumbnail, .form-check-label {
    cursor: pointer;
}

