/* Минимальные стили, не конфликтующие с Bootstrap */
body {
    background-color: #fff;
}

body.bg-dark {
    background-color: #2c3e50 !important;
}

body.bg-light {
    background-color: #fff !important;
}

body.bg-dark input,
body.bg-dark textarea,
body.bg-dark select {
    background-color: #2c3e50 !important;
    color: #f8f9fa !important;
    border-color: #444 !important;
}

body.bg-dark input::placeholder,
body.bg-dark textarea::placeholder {
    color: #aaa !important;
}

body.bg-light input,
body.bg-light textarea,
body.bg-light select {
    background-color: #fff !important;
    color: #222 !important;
    border-color: #ced4da !important;
}

body.bg-light input::placeholder,
body.bg-light textarea::placeholder {
    color: #888 !important;
}

body.bg-dark input.form-control,
body.bg-dark textarea.form-control,
body.bg-dark select.form-control {
    background-color: #2c3e50 !important;
    color: #f8f9fa !important;
    border-color: #444 !important;
}

body.bg-dark input.form-control::placeholder,
body.bg-dark textarea.form-control::placeholder {
    color: #aaa !important;
}

body.bg-light input.form-control,
body.bg-light textarea.form-control,
body.bg-light select.form-control {
    background-color: #fff !important;
    color: #222 !important;
    border-color: #ced4da !important;
}

body.bg-light input.form-control::placeholder,
body.bg-light textarea.form-control::placeholder {
    color: #888 !important;
}

body.bg-dark .card,
body.bg-dark .card-body {
    background-color: #34495e !important;
    color: #f8f9fa !important;
    border-radius: 5px;
}

body.bg-light .card,
body.bg-light .card-body {
    color: #222 !important;
    border-color: #ced4da !important;
}

/* Стили для футера todo модуля */
.footer-section {
    background-color: #f8f9fa !important;
    transition: background-color 0.3s, color 0.3s;
}

.footer-text {
    color: #6c757d !important;
    transition: color 0.3s;
}

.footer-divider {
    border-color: #dee2e6 !important;
    transition: border-color 0.3s;
}

.footer-link {
    color: #6c757d !important;
    transition: color 0.3s;
}

.footer-link:hover {
    color: #495057 !important;
}

/* Темная тема для футера todo модуля */
body.bg-dark .footer-section {
    background-color: #2c3e50 !important;
}

body.bg-dark .footer-text {
    color: #bdc3c7 !important;
}

body.bg-dark .footer-divider {
    border-color: #444 !important;
}

body.bg-dark .footer-link {
    color: #bdc3c7 !important;
}

body.bg-dark .footer-link:hover {
    color: #ecf0f1 !important;
}

/* Стили для drag and drop */
.task-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}

.task-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.drag-handle {
    transition: color 0.2s ease;
    font-size: 1.2em;
}

.drag-handle:hover {
    color: #007bff !important;
}

/* Стили для Sortable.js */
.sortable-ghost {
    opacity: 0.4;
    background: #f8f9fa;
    border: 2px dashed #007bff;
}

.sortable-chosen {
    background: #e3f2fd;
    border-color: #2196f3;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.sortable-drag {
    opacity: 0.8;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Темная тема для drag and drop */
body.bg-dark .sortable-ghost {
    background: #34495e;
    border-color: #3498db;
}

body.bg-dark .sortable-chosen {
    background: #2c3e50;
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

body.bg-dark .task-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

body.bg-dark .drag-handle:hover {
    color: #3498db !important;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    /* Исправляем скроллинг для мобильных устройств */
    #tasks-container {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        padding-right: 10px;
    }
    
    .drag-handle {
        font-size: 1.4em;
        padding: 12px 8px;
        min-width: 44px; /* Минимальный размер для touch */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }
    
    .task-item {
        margin-bottom: 1rem !important;
        touch-action: pan-y; /* Разрешаем вертикальный скролл */
        position: relative;
    }
    
    .sortable-drag {
        transform: none; /* Убираем поворот на мобильных */
        z-index: 1000;
        position: relative;
    }
    
    /* Улучшенные стили для мобильного перетаскивания */
    .mobile-dragging {
        transform: scale(1.02);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
        z-index: 1000;
    }
    
    /* Предотвращаем скролл только во время активного перетаскивания */
    body.dragging {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    /* Улучшенная обработка touch событий */
    .task-item:not(.sortable-chosen) {
        touch-action: pan-y pinch-zoom;
    }
    
    .task-item.sortable-chosen {
        touch-action: none;
    }
}

/* Улучшенная визуализация при перетаскивании */
#tasks-container {
    min-height: 50px;
}

#tasks-container:empty::before {
    content: "Перетащите задачи сюда";
    display: block;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 2rem;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    margin: 1rem 0;
}

body.bg-dark #tasks-container:empty::before {
    color: #bdc3c7;
    border-color: #444;
}

/* Дополнительные стили для мобильных устройств */
@media (max-width: 768px) {
    /* Улучшенная визуализация при перетаскивании на мобильных */
    .sortable-ghost {
        opacity: 0.3;
        background: #f8f9fa;
        border: 3px dashed #007bff;
        border-radius: 8px;
    }
    
    .sortable-chosen {
        background: #e3f2fd;
        border-color: #2196f3;
        box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
        border-radius: 8px;
    }
    
    /* Предотвращаем выделение текста во время перетаскивания */
    .task-item.sortable-chosen,
    .task-item.sortable-drag {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Улучшенная область захвата для touch */
    .drag-handle {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Анимация для drag handle при нажатии */
    .drag-handle:active {
        transform: scale(1.1);
        transition: transform 0.1s ease;
    }
}

/* Специальные стили для iOS Safari */
@supports (-webkit-touch-callout: none) {
    .task-item {
        -webkit-transform: translateZ(0); /* Аппаратное ускорение */
        transform: translateZ(0);
    }
    
    .sortable-drag {
        -webkit-transform: translateZ(0) scale(1.02);
        transform: translateZ(0) scale(1.02);
    }
}

/* Улучшенная поддержка для Android Chrome */
@media screen and (-webkit-min-device-pixel-ratio: 2) {
    .sortable-ghost {
        border-width: 2px;
    }
    
    .sortable-chosen {
        box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
    }
}

/* Стили для модальных окон с поддержкой тем */
.modal-content {
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body.bg-dark .modal-content {
    background-color: #2c3e50 !important;
    color: #f8f9fa !important;
    border-color: #444 !important;
}

body.bg-dark .modal-header {
    background-color: #34495e !important;
    border-bottom-color: #444 !important;
    color: #f8f9fa !important;
}

body.bg-dark .modal-footer {
    background-color: #34495e !important;
    border-top-color: #444 !important;
}

body.bg-dark .modal-body {
    background-color: #2c3e50 !important;
    color: #f8f9fa !important;
}

body.bg-dark .modal-title {
    color: #f8f9fa !important;
}

body.bg-dark .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

body.bg-light .modal-content {
    background-color: #fff !important;
    color: #222 !important;
    border-color: #dee2e6 !important;
}

body.bg-light .modal-header {
    background-color: #f8f9fa !important;
    border-bottom-color: #dee2e6 !important;
    color: #222 !important;
}

body.bg-light .modal-footer {
    background-color: #f8f9fa !important;
    border-top-color: #dee2e6 !important;
}

body.bg-light .modal-body {
    background-color: #fff !important;
    color: #222 !important;
}

body.bg-light .modal-title {
    color: #222 !important;
}

/* Стили для уведомлений с поддержкой тем */
body.bg-dark .alert-success {
    background-color: #155724 !important;
    border-color: #c3e6cb !important;
    color: #d4edda !important;
}

body.bg-dark .alert-danger {
    background-color: #721c24 !important;
    border-color: #f5c6cb !important;
    color: #f8d7da !important;
}

body.bg-light .alert-success {
    background-color: #d1e7dd !important;
    border-color: #badbcc !important;
    color: #0f5132 !important;
}

body.bg-light .alert-danger {
    background-color: #f8d7da !important;
    border-color: #f5c2c7 !important;
    color: #842029 !important;
}