/* Kanban column */
.kanban-col {
    min-width: 300px;
    max-width: 340px;
    flex-shrink: 0;
}
.kanban-col-body {
    min-height: 80px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    border-radius: 12px;
    padding: 4px;
}
.kanban-col-body.drag-over {
    background-color: #f0f5ff;
    box-shadow: inset 0 0 0 2px #c2d5ff;
}

/* Card drag */
.kanban-card {
    cursor: grab;
    transition: box-shadow 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    will-change: transform, opacity;
    /* iOS Safari: запрет выделения текста и контекстного меню при long-press */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.kanban-card:active {
    cursor: grabbing;
}
.kanban-card.dragging {
    opacity: 0.4;
    transform: scale(0.95) rotate(1deg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    pointer-events: none;
}

/* Drop indicator */
.drop-indicator {
    height: 3px;
    background: linear-gradient(90deg, #4f6ef7, #6b8afd);
    border-radius: 2px;
    margin: 4px 0;
    animation: pulse-indicator 0.8s ease infinite;
}
@keyframes pulse-indicator {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Card move animation */
.kanban-card.card-moving {
    animation: card-fly 0.3s ease;
}
@keyframes card-fly {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.9); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* Active nav */
a.\!text-gray-800 { color: #1f2937 !important; }

/* No underline */
a.no-underline { text-decoration: none; }

/* CP card selected state */
.cp-card:has(input:checked) {
    border-color: #c2d5ff;
    background-color: #f8faff;
}

/* Smooth list transitions */
.cp-card {
    transition: all 0.15s ease;
}

/* Column drag & drop (SortableJS) */
.kanban-col-header { cursor: grab; user-select: none; }
.kanban-col-header:active { cursor: grabbing; }
.col-drag-ghost { opacity: 0.4; }

/* Overdue card highlight */
.kanban-card.card-overdue {
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.3);
    background: linear-gradient(135deg, #fff 85%, #fef2f2 100%);
}

/* Viewed card highlight */
.card-viewed {
    background-color: #f3f4f6;
    opacity: 0.85;
}

/* ===== Mobile / Touch adaptation ===== */

/* Smooth iOS momentum scroll for kanban */
#kanban {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

/* Columns snap on mobile */
.kanban-col {
    scroll-snap-align: start;
}

/* Compact column width on very small screens */
@media (max-width: 480px) {
    .kanban-col {
        min-width: 272px;
        max-width: 288px;
    }
}

/* Hide scrollbar on board/city tab rows */
.kanban-tabs-row {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.kanban-tabs-row::-webkit-scrollbar {
    display: none;
}

/* Touch drag ghost element (follows finger) */
.touch-drag-ghost {
    position: fixed !important;
    pointer-events: none !important;
    z-index: 9999;
    opacity: 0.88;
    transform: rotate(2deg) scale(1.03);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    border-radius: 12px;
    background: white;
    will-change: left, top;
    transition: none !important;
    /* Клон карты не должен показывать скроллбары или переполнение */
    overflow: hidden;
}

/* Long-press visual feedback before drag starts */
.kanban-card.touch-press {
    transform: scale(0.97) translateY(-1px);
    box-shadow: 0 0 0 2px #4f6ef7, 0 4px 16px rgba(79, 110, 247, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* ===== Mobile overflow fix (≤640px) ===== */

/* Prevent any element from pushing body wider than viewport */
body {
    overflow-x: hidden;
}

@media (max-width: 640px) {
    /* Navbar: shrink horizontal padding, allow wrapping on very small screens */
    nav {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }
    nav > div {
        gap: 0.75rem;
    }

    /* Common page container: reduce horizontal padding */
    .max-w-7xl {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* ===== City filter modal ===== */

.city-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.city-modal-overlay.city-modal-open {
    display: flex;
}
.city-modal-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 90vh;
}
.city-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.city-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}
.city-modal-close-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #9ca3af;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s, color 0.15s;
}
.city-modal-close-btn:hover { background: #f3f4f6; color: #374151; }

.city-modal-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.city-modal-search {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.city-modal-search:focus { border-color: #6b8afd; }

.city-sort-btns { display: flex; gap: 4px; }
.city-sort-btn {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.city-sort-btn:hover { background: #f9fafb; }
.city-sort-btn.city-sort-active {
    background: #4f6ef7;
    color: #fff;
    border-color: #4f6ef7;
}

.city-modal-bulk-row {
    display: flex;
    gap: 16px;
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.city-modal-link-btn {
    font-size: 12px;
    color: #4f6ef7;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.city-modal-link-btn:hover { color: #3755d8; }

.city-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    max-height: 60vh;
}
.city-modal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}
.city-modal-item:hover { background: #f9fafb; }
.city-modal-item-checked { background: #f0f4ff; }
.city-modal-item-checked:hover { background: #e8eeff; }

.city-modal-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #4f6ef7;
    cursor: pointer;
    flex-shrink: 0;
}
.city-modal-item-name {
    flex: 1;
    font-size: 13px;
    color: #374151;
}
.city-modal-item-count {
    font-size: 11px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

.city-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
}
.city-modal-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}
.city-modal-btn-cancel { background: #f3f4f6; color: #374151; }
.city-modal-btn-cancel:hover { background: #e5e7eb; }
.city-modal-btn-apply { background: #4f6ef7; color: #fff; }
.city-modal-btn-apply:hover { background: #3755d8; }

/* City chip button in toolbar */
.city-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 13px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.city-chip-btn:hover { background: #dbeafe; border-color: #93c5fd; }
.city-chip-btn.city-chip-active {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}
.city-chip-btn.city-chip-active:hover { background: #1e40af; border-color: #1e40af; }

.city-chip-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    border: none;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.city-chip-clear:hover { background: #fee2e2; color: #ef4444; }

/* Mobile: full-screen sheet on small screens */
@media (max-width: 480px) {
    .city-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .city-modal-box {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
    }
    .city-modal-search {
        font-size: 16px; /* prevent iOS auto-zoom */
    }
}
