/* ============================================================
   Единый файл стилей для колонок и досок: Канбан, Мой план, Сроки
   Загружается в <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;
}

/* Парящая карточка при анимированном перелёте между колонками */
.dt-task-card--flying {
    position: fixed !important;
    z-index: 1040 !important;
    pointer-events: none !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    transform-origin: center center !important;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(99, 102, 241, 0.7) !important;
    border-radius: 12px !important;
    will-change: top, left, width, height, transform, box-shadow !important;
}

[data-theme="dark"] .dt-task-card--flying {
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.75), 0 0 0 2px rgba(129, 140, 248, 0.85) !important;
}

/* ==========================================================================
   КОМПЛЕКСНАЯ СИСТЕМА ЖИВЫХ КАРТОЧЕК В РЕАЛЬНОМ ВРЕМЕНИ (MICRO-ANIMATIONS)
   ========================================================================== */

/* 1. ОБЛОЖКА И ФОТОГРАФИИ: Плавное раскрытие с размытием и световым бликом */
.dt-card__media--revealing {
    min-height: 0 !important;
    animation: dtMediaReveal 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: top center;
    overflow: hidden;
}

@keyframes dtMediaReveal {
    0% {
        opacity: 0;
        max-height: 0;
        transform: scale(0.96) translateY(-8px);
        filter: blur(8px);
    }
    50% {
        opacity: 0.85;
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        max-height: 260px;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

.dt-media-item--shimmer {
    position: relative;
    overflow: hidden;
}

.dt-media-item--shimmer::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transform: skewX(-25deg);
    animation: dtShimmerSweep 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none;
}

@keyframes dtShimmerSweep {
    0% { left: -100%; }
    100% { left: 220%; }
}

/* 2. СООБЩЕНИЯ И КОММЕНТАРИИ: Пружинный отскок, круговая волна и всплывающий микро-тост */
.dt-badge--comment.dt-badge--just-updated {
    animation: dtCommentBadgePop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    position: relative;
}

@keyframes dtCommentBadgePop {
    0% {
        transform: scale(0.65);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.38);
        box-shadow: 0 0 16px rgba(59, 130, 246, 0.7);
    }
    100% {
        transform: scale(1);
        box-shadow: none;
        opacity: 1;
    }
}

.dt-comment-ripple {
    position: absolute;
    inset: -4px;
    border-radius: 9999px;
    border: 2px solid rgba(59, 130, 246, 0.75);
    animation: dtRippleRing 1.1s ease-out forwards;
    pointer-events: none;
}

@keyframes dtRippleRing {
    0% {
        transform: scale(0.7);
        opacity: 1;
    }
    100% {
        transform: scale(2.0);
        opacity: 0;
    }
}

/* Всплывающий микро-тост с текстом комментария прямо над карточкой (внутри границ, без обрезания overflow) */
.dt-card-floating-comment {
    position: absolute;
    top: 6px;
    left: 8px;
    right: 8px;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(99, 102, 241, 0.55);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(99, 102, 241, 0.35);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 11.5px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 7px;
    pointer-events: none;
    animation: dtFloatCommentToast 3.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="light"] .dt-card-floating-comment {
    background: rgba(255, 255, 255, 0.96);
    color: #1e293b;
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 0 16px rgba(99, 102, 241, 0.22);
}

@keyframes dtFloatCommentToast {
    0% {
        opacity: 0;
        transform: translateY(-8px) scale(0.94);
    }
    12% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    82% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-6px) scale(0.96);
    }
}

/* 3. УЧАСТНИКИ: 3D-морфинг аватара и стрелка делегирования */
.dt-avatar--morphing {
    animation: dtAvatarMorph 0.7s cubic-bezier(0.34, 1.45, 0.64, 1) forwards;
    transform-origin: center center;
}

@keyframes dtAvatarMorph {
    0% {
        transform: scale(0.3) rotateY(90deg);
        opacity: 0;
        filter: brightness(2.2);
    }
    60% {
        transform: scale(1.24) rotateY(-8deg);
        box-shadow: 0 0 18px rgba(245, 158, 11, 0.75);
    }
    100% {
        transform: scale(1) rotateY(0deg);
        opacity: 1;
        box-shadow: none;
        filter: brightness(1);
    }
}

.dt-delegation-arrow--animate {
    animation: dtArrowDraw 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes dtArrowDraw {
    0% {
        opacity: 0;
        transform: scaleX(0.2) translateX(-4px);
    }
    100% {
        opacity: 1;
        transform: scaleX(1) translateX(0);
    }
}

.dt-collaborators-badge--bounce,
.dt-observers-badge--bounce {
    animation: dtBadgeBounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dtBadgeBounce {
    0% { transform: scale(0.65); }
    50% { transform: scale(1.32); }
    100% { transform: scale(1); }
}

/* 4. КРАЙНИЙ СРОК: Мягкая волна внимания */
.dt-card__deadline--updated {
    animation: dtDeadlinePulse 0.85s ease-out forwards;
}

@keyframes dtDeadlinePulse {
    0% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }
    35% {
        transform: scale(1.1);
        box-shadow: 0 0 0 9px rgba(245, 158, 11, 0.25);
    }
    100% {
        transform: scale(1);
        box-shadow: none;
    }
}

/* 5. ЧЕК-ЛИСТЫ И 100% CELEBRATION */
.dt-progress-bar__fill {
    transition: width 0.65s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.45s ease !important;
}

.dt-badge--checklist.dt-badge--bounce {
    animation: dtBadgeBounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.dt-task-card--celebrate-100 {
    animation: dtCelebrate100 1.5s ease-out forwards !important;
}

@keyframes dtCelebrate100 {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.85), 0 10px 30px rgba(16, 185, 129, 0.35);
        border-color: rgba(16, 185, 129, 1);
    }
    30% {
        box-shadow: 0 0 0 14px rgba(16, 185, 129, 0.35), 0 16px 42px rgba(16, 185, 129, 0.45);
        border-color: rgba(16, 185, 129, 1);
        transform: scale(1.02);
    }
    100% {
        box-shadow: none;
        transform: scale(1);
    }
}

/* 6. ПРОЕКТ: Плавное раскрытие чипа */
.dt-badge--project.dt-badge--reveal {
    animation: dtProjectReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes dtProjectReveal {
    0% {
        opacity: 0;
        max-width: 0;
        transform: translateX(-12px);
    }
    100% {
        opacity: 1;
        max-width: 220px;
        transform: translateX(0);
    }
}

/* 7. ИНДИКАТОР ЖИВОГО ПРИСУТСТВИЯ / НАБОРА ТЕКСТА */
.dt-card__typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 9999px;
    font-size: 10px;
    color: #818cf8;
    animation: dtFadeIn 0.3s ease-out;
}

.dt-card__typing-dot {
    width: 4px;
    height: 4px;
    background: #818cf8;
    border-radius: 50%;
    animation: dtTypingBounce 1.2s infinite ease-in-out;
}
.dt-card__typing-dot:nth-child(1) { animation-delay: 0s; }
.dt-card__typing-dot:nth-child(2) { animation-delay: 0.2s; }
.dt-card__typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dtTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

@keyframes dtFadeIn {
    0% { opacity: 0; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

