/* =================== 1. ПЕРЕМЕННЫЕ И ОСНОВА =================== */
:root {
    --bg-body: #f3f4f6;
    /* Glassmorphism Colors - Light Mode */
    --bg-column: rgba(255, 255, 255, 0.45);
    --text-main: #1f2937;
    --text-secondary: #4b5563;
    --card-bg: rgba(255, 255, 255, 0.65);
    --card-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --border-color: rgba(255, 255, 255, 0.4);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --modal-bg: rgba(0, 0, 0, 0.6);

    --liquid-color-1: 100, 150, 255;
    --liquid-color-2: 150, 200, 255;
    --liquid-color-3: 200, 150, 255;

    --priority-low: #059669;
    --priority-medium: #d97706;
    --priority-high: #dc2626;

    --animation-duration: 0.4s;
    --animation-ease: cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="dark"] {
    --bg-body: #111827;
    /* Glassmorphism Colors - Dark Mode */
    --bg-column: rgba(31, 41, 55, 0.45);
    --text-main: #f9fafb;
    --text-secondary: #d1d5db;
    --card-bg: rgba(55, 65, 81, 0.65);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --modal-bg: rgba(0, 0, 0, 0.8);

    --liquid-color-1: 100, 100, 200;
    --liquid-color-2: 120, 120, 220;
    --liquid-color-3: 140, 140, 240;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color var(--animation-duration), color var(--animation-duration);
    overflow-x: hidden;
    min-height: 100vh;
}

/* СТИЛИЗАЦИЯ СКРОЛЛБАРА */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }

/* =================== 2. ХЕДЕР И КНОПКИ =================== */
header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 30px; 
    background-color: var(--bg-column);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--glass-border);
    box-shadow: var(--card-shadow); margin-bottom: 20px;
    position: sticky; top: 0; z-index: 100; flex-wrap: wrap; gap: 15px;
}

header h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); text-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.action-header-btn, .theme-toggle {
    padding: 10px 15px; border: none; border-radius: 8px; cursor: pointer;
    font-weight: 500; transition: all var(--animation-duration) var(--animation-ease);
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.action-header-btn { background-color: var(--accent); color: white; }
.action-header-btn:hover { background-color: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }

.theme-toggle { background-color: rgba(255,255,255,0.1); border: var(--glass-border); color: var(--text-main); font-size: 1.2rem; padding: 8px 12px; backdrop-filter: blur(5px); }
.theme-toggle:hover { background-color: rgba(255,255,255,0.2); }

.action-select {
    padding: 10px 15px; border-radius: 8px; border: var(--glass-border);
    background-color: var(--bg-column); color: var(--text-main); font-weight: 500;
    transition: border-color var(--animation-duration);
    backdrop-filter: blur(5px);
}
.action-select:focus { border-color: var(--accent); outline: none; }

/* =================== 3. ДОСКА И КОЛОНКИ (ОПТИМИЗАЦИЯ) =================== */
.board {
    display: flex; gap: 20px; padding: 0 20px 20px 20px;
    overflow-x: auto; align-items: flex-start; min-height: calc(100vh - 100px);
    width: 100%;
}

.column {
    background-color: var(--bg-column);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--glass-border);
    min-width: 300px;
    flex-basis: 300px;
    flex-grow: 1;
    max-width: 800px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
    max-height: calc(100vh - 100px);
    transition: transform var(--animation-duration) var(--animation-ease), box-shadow var(--animation-duration);
}

.column.dragging-column {
    opacity: 0.6;
    transform: scale(0.98) rotate(1deg);
    cursor: grabbing;
}

/* Дополнительное центрирование для очень широких экранов */
@media (min-width: 1400px) {
    .board {
        justify-content: center;
    }
}

.column-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    flex-direction: column; padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color); position: relative;
    cursor: grab; /* Cursor for dragging the column */
}
.column-header:active { cursor: grabbing; }

.column-title-wrapper {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%; flex-shrink: 0; margin-bottom: 8px;
}

.column-title-group {
    font-size: 1.1rem; font-weight: 600; display: flex;
    align-items: center; gap: 8px; cursor: pointer;
    color: var(--text-main); flex-shrink: 1;
}

.column-title-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.count-badge {
    background-color: var(--accent); color: white; padding: 2px 8px;
    border-radius: 9999px; font-size: 0.8rem; font-weight: 500; flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.delete-column-btn {
    background: none; border: none; cursor: pointer; font-size: 1.4rem;
    padding: 0 5px; color: var(--text-secondary);
    transition: color 0.2s, opacity 0.2s; line-height: 1; opacity: 0.7;
    flex-shrink: 0;
}
.delete-column-btn:hover { color: var(--priority-high); opacity: 1; }

.sort-select {
    padding: 5px; border-radius: 6px; border: var(--glass-border);
    background-color: rgba(255,255,255,0.1); color: var(--text-secondary);
    font-size: 0.85rem; width: 100%; transition: border-color var(--animation-duration);
}

.task-list {
    display: flex; flex-direction: column; gap: 10px;
    overflow-y: auto; max-height: 100%; padding-right: 5px;
}

.task-list:empty {
    min-height: 50px; border: 2px dashed var(--border-color);
    border-radius: 8px; opacity: 0.5; transition: all 0.3s;
}
.task-list.drag-over {
    border-color: var(--accent) !important; background-color: rgba(99, 102, 241, 0.1);
    opacity: 1 !important;
}


/* =================== 4. КАРТОЧКИ ЗАДАЧИ =================== */
.task {
    background-color: var(--card-bg); 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: var(--glass-border);
    border-left: 5px solid var(--border-color);
    padding: 12px; border-radius: 12px; 
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    cursor: grab; transition: all var(--animation-duration) var(--animation-ease);
    position: relative;
}

.task:hover { 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); 
    transform: translateY(-3px); 
    background-color: rgba(255,255,255,0.75);
}
[data-theme="dark"] .task:hover { background-color: rgba(60, 70, 90, 0.75); }

.task.dragging { opacity: 0.5; transform: scale(0.98); }

.task-title { font-weight: 600; font-size: 1rem; margin-bottom: 5px; color: var(--text-main); }
.task-description { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 10px; white-space: pre-wrap; }
.task-meta { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; color: var(--text-secondary); }
.task-meta-row { display: flex; justify-content: space-between; align-items: center; }

.task-deadline {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
}
[data-theme="dark"] .task-deadline { background: rgba(255,255,255,0.1); }

.task-deadline.overdue {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    font-weight: 600;
}

.priority-badge { padding: 2px 8px; border-radius: 6px; font-weight: 500; color: white; font-size: 0.75rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.priority-1 { background-color: var(--priority-low); }
.priority-2 { background-color: var(--priority-medium); }
.priority-3 { background-color: var(--priority-high); }

.task-actions { position: absolute; top: 5px; right: 5px; display: flex; gap: 5px; }

.icon-btn { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-secondary); padding: 3px; transition: color var(--animation-duration); }
.edit-btn:hover { color: var(--accent); }
.delete-btn:hover { color: var(--priority-high); }

.open-modal-btn {
    width: 100%; padding: 10px; 
    background-color: rgba(255,255,255,0.1);
    border: 1px dashed var(--text-secondary);
    color: var(--text-secondary); border-radius: 8px;
    cursor: pointer; font-weight: 500; transition: all var(--animation-duration);
}
.open-modal-btn:hover { background-color: var(--accent); color: white; border-color: var(--accent); }

/* =================== 5. МОДАЛЬНЫЕ ОКНА И УПРАВЛЕНИЕ ДОСКАМИ =================== */
.modal {
    display: flex; position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%; background-color: var(--modal-bg);
    backdrop-filter: blur(5px);
    justify-content: center; align-items: center; opacity: 0;
    pointer-events: none; transition: opacity var(--animation-duration) var(--animation-ease);
}
.modal.active { opacity: 1; pointer-events: auto; }

.modal-content {
    background-color: var(--bg-column); 
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--glass-border);
    padding: 25px;
    border-radius: 16px; width: 90%; max-width: 500px;
    box-shadow: var(--card-shadow); transform: translateY(-20px);
    transition: transform var(--animation-duration) var(--animation-ease);
}
.modal.active .modal-content { transform: translateY(0); }

.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.modal-footer button {
    padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer;
    font-weight: 600; transition: background-color 0.2s, opacity 0.2s;
}

.cancel-btn { background-color: rgba(156, 163, 175, 0.2); color: var(--text-main); }
.cancel-btn:hover { background-color: rgba(156, 163, 175, 0.3); }

.action-btn { background-color: var(--accent); color: white; box-shadow: 0 4px 6px rgba(99, 102, 241, 0.3); }
.action-btn:hover { background-color: var(--accent-hover); transform: translateY(-1px); }

.boards-list-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; margin-bottom: 8px; background-color: rgba(255,255,255,0.1);
    border-radius: 8px; cursor: pointer; transition: background-color 0.2s;
}

.boards-list-item:hover { background-color: rgba(255,255,255,0.2); }
.boards-list-item.active { border: 2px solid var(--accent); font-weight: 600; }

.rename-board-btn {
    background: none; color: var(--text-secondary); border: none;
    cursor: pointer; font-size: 1.1rem; padding: 0 5px;
    margin-right: 5px; transition: color 0.2s;
}
.rename-board-btn:hover { color: var(--accent); }

.delete-board-btn {
    background: var(--priority-high); color: white; border: none;
    border-radius: 50%; width: 24px; height: 24px; cursor: pointer;
    transition: opacity 0.2s; font-size: 1.2rem; line-height: 1;
    padding: 0; margin-left: 5px;
}
.delete-board-btn:hover { opacity: 0.8; }

.modal-content input[type="text"],
.modal-content textarea,
.modal-content input[type="range"],
.modal-content input[type="color"],
.modal-content input[type="date"] {
    width: 100%; padding: 10px; margin-bottom: 15px;
    border: 1px solid var(--border-color); border-radius: 8px;
    background-color: rgba(255,255,255,0.1); color: var(--text-main);
    transition: border-color var(--animation-duration);
}
.modal-content input:focus, .modal-content textarea:focus {
    border-color: var(--accent); outline: none; background-color: rgba(255,255,255,0.2);
}

.color-picker-group { display: flex; align-items: center; gap: 10px; }
.color-picker-group input[type="color"] { width: 40px; padding: 3px; height: 40px; }

/* =================== 6. КАНВАСЫ И АНИМАЦИИ =================== */
#background-canvas, #confetti-canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: -1; filter: blur(80px);
}
#confetti-canvas { z-index: 1001; filter: none; }

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .header-actions { width: 100%; justify-content: space-around; flex-wrap: wrap; }
    .header-actions .action-header-btn,
    .header-actions .action-select { flex-grow: 1; min-width: unset; }
    .board { padding: 0 10px 10px 10px; gap: 15px; justify-content: flex-start; }
    .column { min-width: 250px; width: 90%; flex-grow: 0; }
}
