/**
 * Стили для системы планирования задач
 * Минималистичный дизайн, светлая тема, адаптивный
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --border-color: #dee2e6;
    --bg-color: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-color: #212529;
    --text-muted: #6c757d;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    
    /* Динамические переменные для размера текста и отступов */
    --text-size-multiplier: 1;
    --spacing-multiplier: 1;

    /* Ширина страницы (настраивается пользователем) */
    --page-width: 1200px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-color);
    line-height: calc(1.6 * var(--spacing-multiplier));
    min-height: 100vh;
    font-size: calc(1rem * var(--text-size-multiplier));
}

/* Header */
.main-header {
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-center {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
}

.btn-control {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-color);
    min-width: 32px;
    text-align: center;
}

.btn-control:hover {
    background: var(--border-color);
    border-color: var(--primary-color);
}

.btn-control-small {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}

.control-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    min-width: 45px;
    text-align: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.username {
    color: var(--text-muted);
}

/* Auth page */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-box {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s;
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.auth-tab:hover {
    color: var(--primary-color);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Dashboard */
.dashboard-container {
    max-width: var(--page-width);
    margin: 2rem auto;
    padding: 0 1rem;
}

.dashboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tasks-container {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.tasks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.tasks-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color);
}

.tasks-list {
    min-height: 200px;
}

.task-item {
    margin-bottom: calc(0.5rem * var(--spacing-multiplier));
    border-radius: 4px;
    transition: background-color 0.2s;
    position: relative;
    overflow: visible;
}

.task-item:hover {
    background-color: var(--bg-secondary);
}

.task-item.completed .task-content {
    background-color: #e9ecef;
}

.task-item.completed:hover .task-content {
    background-color: #dee2e6;
}

.task-item.sortable-ghost {
    opacity: 0.4;
}

.task-content {
    display: flex;
    align-items: center;
    padding: calc(0.75rem * var(--spacing-multiplier));
    gap: calc(0.5rem * var(--spacing-multiplier));
}

.task-handle {
    cursor: grab;
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
}

.task-toggle {
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
    display: inline-block;
    transition: transform 0.2s;
    font-size: 0.8rem;
    min-width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.task-toggle:hover {
    color: var(--text-color);
}

.task-toggle-empty {
    display: inline-block;
    min-width: 1rem;
    flex-shrink: 0;
}

.task-item.collapsed .task-toggle {
    transform: rotate(0deg);
}

.task-item:not(.collapsed) .task-toggle {
    transform: rotate(90deg);
}

.task-children {
    overflow: visible;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    max-height: 10000px;
    opacity: 1;
}

.task-item.collapsed .task-children {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

.task-handle:active {
    cursor: grabbing;
}

.task-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.task-number {
    font-weight: 600;
    color: var(--text-muted);
    min-width: 24px;
    flex-shrink: 0;
}

.task-title {
    flex: 1;
    cursor: pointer;
    word-wrap: break-word;
    line-height: calc(1.4 * var(--spacing-multiplier));
}

.task-title-edit {
    flex: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    background: var(--bg-color);
    color: var(--text-color);
    width: 100%;
    min-width: 200px;
}

.task-title-edit:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.task-title.completed {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-status-dropdown {
    position: relative;
    display: inline-block;
    margin-right: 0.5rem;
    z-index: 1;
}

.task-status-dropdown.active {
    z-index: 99999;
}

.task-status-dropdown-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    color: white;
    min-width: 100px;
    text-align: center;
}

.task-status-dropdown-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.task-status-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 99999;
    min-width: 120px;
    margin-top: 0.25rem;
}

.task-status-dropdown.active .task-status-dropdown-menu {
    display: block;
}

.task-status-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: white;
    transition: opacity 0.2s;
    border-radius: 0;
}

.task-status-option:first-child {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.task-status-option:last-child {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.task-status-option:hover {
    opacity: 0.8;
}

/* Task metrics dropdown (complexity / importance) */
.task-metric-dropdown {
    position: relative;
    display: inline-block;
    margin-right: 0.25rem;
    z-index: 1;
}

.task-metric-dropdown.active {
    z-index: 99999;
}

.task-metric-dropdown-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    color: white;
    min-width: 90px;
    text-align: center;
}

.task-metric-dropdown-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.task-metric-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 99999;
    min-width: 180px;
    margin-top: 0.25rem;
}

.task-metric-dropdown.active .task-metric-dropdown-menu {
    display: block;
}

.task-metric-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-color);
    background: var(--bg-secondary);
    transition: background-color 0.2s, color 0.2s;
}

.task-metric-option:first-child {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.task-metric-option:last-child {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.task-metric-option:hover {
    background: var(--primary-color);
    color: white;
}

/* Colors for complexity button */
.task-complexity-dropdown-btn {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

.task-complexity-dropdown-btn[data-value="1"] { background-color: #198754 !important; border-color: #198754 !important; }
.task-complexity-dropdown-btn[data-value="2"] { background-color: #20c997 !important; border-color: #20c997 !important; }
.task-complexity-dropdown-btn[data-value="3"] { background-color: #6c757d !important; border-color: #6c757d !important; }
.task-complexity-dropdown-btn[data-value="4"] { background-color: #fd7e14 !important; border-color: #fd7e14 !important; }
.task-complexity-dropdown-btn[data-value="5"] { background-color: #dc3545 !important; border-color: #dc3545 !important; }

/* Colors for importance button */
.task-importance-dropdown-btn {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

.task-importance-dropdown-btn[data-value="1"] { background-color: #6c757d !important; border-color: #6c757d !important; }
.task-importance-dropdown-btn[data-value="2"] { background-color: #0dcaf0 !important; border-color: #0dcaf0 !important; }
.task-importance-dropdown-btn[data-value="3"] { background-color: #0d6efd !important; border-color: #0d6efd !important; }
.task-importance-dropdown-btn[data-value="4"] { background-color: #fd7e14 !important; border-color: #fd7e14 !important; }
.task-importance-dropdown-btn[data-value="5"] { background-color: #dc3545 !important; border-color: #dc3545 !important; }

.task-actions {
    display: flex;
    gap: 0.25rem;
}

.task-children {
    margin-left: calc(1rem * var(--spacing-multiplier));
    padding-left: calc(1rem * var(--spacing-multiplier));
    border-left: 2px solid var(--border-color);
    min-height: 4px;
}

/* Улучшение UX drag&drop: делаем зоны drop более "попадаемыми" */
body.is-dragging-task .task-children {
    min-height: 24px;
    border-left-style: dashed;
    background: rgba(0, 123, 255, 0.04);
}

body.is-dragging-task .task-category-content-uncategorized {
    min-height: 32px;
    border: 1px dashed rgba(0,0,0,0.15);
    border-radius: 6px;
    padding: 0.25rem;
    margin-bottom: 0.75rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Быстрое добавление задачи */
.quick-add-task {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.quick-add-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quick-add-input-container .form-input {
    width: 100%;
}

.quick-add-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.quick-add-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
    user-select: none;
}

.quick-add-checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.quick-add-controls .btn {
    white-space: nowrap;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-link {
    background: none;
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--bg-secondary);
}

.task-actions-menu {
    position: relative;
    display: inline-block;
    z-index: 1;
}

.btn-task-menu {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    color: var(--text-muted);
}

.btn-task-menu:hover {
    opacity: 1;
}

.task-actions-menu.active {
    z-index: 99999;
}

.task-actions-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 99999;
    min-width: 150px;
    margin-top: 0.25rem;
}

.task-actions-menu.active .task-actions-dropdown {
    display: block;
}

.task-actions-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
    transition: background-color 0.2s;
}

.task-actions-dropdown button:hover {
    background-color: var(--bg-secondary);
}

.btn-task-add-subtask {
    color: var(--success-color);
}

.btn-task-edit {
    color: var(--primary-color);
}

.btn-task-chat {
    color: var(--primary-color);
}

.btn-task-delete {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    color: var(--danger-color);
}

.btn-task-delete:hover {
    opacity: 1;
}

.btn-task-move-to-new-day-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    color: var(--text-muted);
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.btn-task-move-to-new-day-icon:hover {
    opacity: 1;
    color: var(--primary-color);
}

.btn-task-description-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.btn-task-description-icon:hover {
    opacity: 1;
}

.task-description-container {
    padding: 0 calc(0.75rem * var(--spacing-multiplier)) calc(0.5rem * var(--spacing-multiplier)) calc(0.75rem * var(--spacing-multiplier));
    display: none;
}

.task-description-container.active {
    display: block;
}

.task-description-content {
    padding: calc(0.5rem * var(--spacing-multiplier));
    background: var(--bg-secondary);
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

.task-description-text {
    color: var(--text-color);
    font-size: 0.9rem;
    line-height: calc(1.5 * var(--spacing-multiplier));
    white-space: pre-wrap;
    word-wrap: break-word;
    cursor: pointer;
}

.task-description-edit {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
}

.task-description-edit:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Form elements */
.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-input.quick-task-textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

.date-input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-input:focus,
.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Color picker */
.color-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.color-option {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    background: transparent;
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.color-option.active {
    border-color: var(--primary-color);
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.color-checkmark {
    display: none;
    color: #333;
    font-weight: bold;
    font-size: 1.2rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-shadow: 0 0 2px white, 0 0 2px white, 0 0 2px white;
}

.color-option.active .color-checkmark {
    display: block;
}

/* Task category header */
.task-category-header {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-muted);
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}

.task-category-handle {
    display: inline-block;
    margin-right: 0.5rem;
    cursor: grab;
    color: var(--text-muted);
    user-select: none;
}

.task-category-handle:active {
    cursor: grabbing;
}

.task-category-toggle {
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s;
}

.task-category-header.collapsed .task-category-toggle {
    transform: rotate(0deg);
}

.task-category-header:not(.collapsed) .task-category-toggle {
    transform: rotate(90deg);
}

.task-category-content {
    overflow: visible;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    max-height: 10000px;
    opacity: 1;
}

.task-category-content.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.modal-hint {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.info {
    padding: 1rem;
    background: #e7f3ff;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    margin-top: 1rem;
}

.info p {
    margin-bottom: 0.5rem;
}

.info p:last-child {
    margin-bottom: 0;
}

/* Chat */
.chat-panel {
    position: fixed;
    top: 0;
    right: -600px;
    width: 600px;
    height: 100vh;
    background: var(--bg-color);
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.chat-panel.active {
    right: 0;
}

.chat-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
}

.chat-overlay.active {
    display: block;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.chat-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close:hover {
    color: var(--text-color);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.6;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-color);
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.6;
}

/* Markdown стили для сообщений AI */
.chat-message.assistant h1,
.chat-message.assistant h2,
.chat-message.assistant h3,
.chat-message.assistant h4,
.chat-message.assistant h5,
.chat-message.assistant h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.3;
}

.chat-message.assistant h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.3rem;
}

.chat-message.assistant h2 {
    font-size: 1.3rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

.chat-message.assistant h3 {
    font-size: 1.1rem;
}

.chat-message.assistant h4 {
    font-size: 1rem;
}

.chat-message.assistant h5 {
    font-size: 0.95rem;
}

.chat-message.assistant h6 {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.chat-message.assistant p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.chat-message.assistant p:last-child {
    margin-bottom: 0;
}

.chat-message.assistant ul,
.chat-message.assistant ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.chat-message.assistant ul {
    list-style-type: disc;
}

.chat-message.assistant ol {
    list-style-type: decimal;
}

.chat-message.assistant li {
    margin: 0.25rem 0;
    line-height: 1.5;
}

.chat-message.assistant li > ul,
.chat-message.assistant li > ol {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.chat-message.assistant code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.chat-message.assistant pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.75rem 0;
    line-height: 1.5;
}

.chat-message.assistant pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.9em;
}

.chat-message.assistant blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 1rem;
    margin: 0.75rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.chat-message.assistant a {
    color: var(--primary-color);
    text-decoration: underline;
}

.chat-message.assistant a:hover {
    color: var(--primary-hover);
}

.chat-message.assistant strong {
    font-weight: 600;
}

.chat-message.assistant em {
    font-style: italic;
}

.chat-message.assistant hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

.chat-message.assistant table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75rem 0;
}

.chat-message.assistant table th,
.chat-message.assistant table td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

.chat-message.assistant table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.chat-message.assistant table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.chat-templates {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    max-height: 200px;
    overflow-y: auto;
}

.chat-templates-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.chat-templates-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-template-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s;
    white-space: normal;
    word-wrap: break-word;
}

.chat-template-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.chat-input-container {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Incomplete tasks list */
.incomplete-task-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.incomplete-task-item input[type="checkbox"] {
    margin-right: 0.75rem;
}

.incomplete-task-item-label {
    flex: 1;
    cursor: pointer;
}

.incomplete-task-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Day blocks */
.day-block {
    margin-bottom: 2rem;
}

/* Скрытие истории (всех дней кроме текущего) */
#all-days-list.history-hidden .day-block:not(.current-day) {
    display: none;
}

/* Скрытие выполненных задач */
#all-days-list.completed-hidden .task-item.completed {
    display: none;
}

/* Показ только задач "В работе" (и их родителей для контекста) */
#all-days-list.inwork-only .task-item:not(.inwork):not(.inwork-ancestor) {
    display: none;
}

/* Разделение между текущим днем и остальными днями */
.day-block.current-day + .day-block {
    margin-top: 6rem;
    padding-top: 3rem;
    position: relative;
}

.day-block.current-day + .day-block::before {
    content: 'История';
    position: absolute;
    top: -2.5rem;
    left: 0;
    background: var(--bg-color);
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}

.day-block.current-day + .day-block::after {
    content: '';
    position: absolute;
    top: -50px;
    left: 0;
    right: 0;
    height: 50px;
    background: repeating-linear-gradient(
        45deg,
        #28a745,
        #28a745 10px,
        #20c997 10px,
        #20c997 20px
    );
}

.day-block:last-child {
    margin-bottom: 0;
}

.day-divider {
    height: 2px;
    background: var(--border-color);
    margin: 2rem 0;
    border: none;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.day-title {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color);
    font-weight: 600;
}

.btn-move-day,
.btn-move-category,
.btn-task-move-to-new-day {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.btn-move-category {
    margin-left: auto;
    margin-right: 0.5rem;
}

.task-category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-toolbar {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        justify-content: center;
    }

    .tasks-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .tasks-header h2 {
        font-size: 1.25rem;
    }

    .chat-panel {
        width: 100%;
        right: -100%;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .header-right {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .dashboard-container {
        margin: 1rem auto;
        padding: 0 0.5rem;
    }

    .tasks-container {
        padding: 1rem;
    }

    .task-content {
        flex-wrap: wrap;
    }

    .task-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }

    .quick-add-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .quick-add-checkbox-label {
        font-size: 0.85rem;
    }
}
