/* ============================================
   Базовые стили (из adminlk)
   ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', 'Roboto', system-ui, sans-serif;
    background: #1e3a5f;
    padding: 24px;
    color: #1e293b;
}

a { color: #60a5fa; }
h1 { color: #f1f5f9; font-weight: 400; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e3a5f; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ============================================
   Контейнеры
   ============================================ */
.container, .dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    background: #2a4b78;
    border-radius: 24px;
    border: 1px solid #334155;
    padding: 30px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 12px;
}
.header h1 { color: #f1f5f9; font-weight: 400; margin: 0; }
.header a { color: #60a5fa; text-decoration: none; }

/* ============================================
   Форма логина
   ============================================ */
.login-box {
    background: #2a4b78;
    padding: 40px;
    border-radius: 20px;
    border: 1px solid #334155;
    width: 360px;
}
.login-box h2 {
    color: #f1f5f9;
    text-align: center;
    margin-bottom: 30px;
    font-weight: 400;
}
.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
}
.login-box button {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    border: none;
    border-radius: 40px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
}
.login-box button:hover { background: #2563eb; }
.error { color: #f87171; margin-top: 10px; text-align: center; }

/* ============================================
   Кнопки (общие)
   ============================================ */
button, .btn {
    cursor: pointer;
    font-family: inherit;
}
.btn-primary {
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 13px;
    transition: 0.2s;
}
.btn-primary:hover { background: #2563eb; }

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
    border: none;
    padding: 8px 18px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 13px;
    transition: 0.2s;
}
.btn-secondary:hover { background: #475569; }

/* ============================================
   Панель управления (toolbar)
   ============================================ */
.toolbar {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.toolbar-label {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    min-width: 100px;
}
.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #334155;
    margin: 0 4px;
}

/* Чекбоксы и радио в фильтрах */
.filters-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}
.filters-checks label {
    color: #cbd5e1;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.filters-checks input[type="checkbox"],
.filters-checks input[type="radio"] {
    accent-color: #3b82f6;
    cursor: pointer;
}

/* ============================================
   Формы (общие — тёмная тема)
   ============================================ */
select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
textarea {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    width: 100%;
}
select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: #60a5fa;
}
textarea {
    resize: vertical;
    min-height: 60px;
}
input[type="checkbox"] { accent-color: #3b82f6; }

/* Точечные размеры */
input.input-short { width: 90px; }
select.select-inline { width: auto; min-width: 140px; }

/* ============================================
   Дерево
   ============================================ */
.tree {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 12px;
    min-height: 200px;
}
.tree-empty {
    color: #64748b;
    text-align: center;
    padding: 40px 0;
    font-style: italic;
}

.node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s;
    font-size: 14px;
    color: #e2e8f0;
    position: relative;
}
.node:hover { background: #1e293b; }

.node-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

/* Отступ для дочерних нод */
.node-children {
    margin-left: 22px;
    border-left: 1px dashed #334155;
    padding-left: 8px;
}

/* Треугольник разворота */
.node-toggle {
    width: 18px;
    text-align: center;
    cursor: pointer;
    color: #94a3b8;
    font-size: 11px;
    user-select: none;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.node-toggle:hover { color: #f1f5f9; }
.node-toggle.empty { cursor: default; opacity: 0.2; }
.node-toggle.collapsed { transform: rotate(-90deg); }

/* Маркеры приоритета */
.node-priority {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.15);
}
.prio-high   { background: #ef4444; }
.prio-medium { background: #eab308; }
.prio-low    { background: #22c55e; }
.prio-none   { background: #64748b; }

/* Маркер типа */
.node-type {
    font-size: 12px;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
    color: #94a3b8;
}
.node-type.doit { color: #22c55e; }
.node-type.try  { color: #eab308; }

/* Заголовок */
.node-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.node-title:hover { color: #60a5fa; }

/* Индикаторы (тревога / энергия) */
.node-indicator {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #1e293b;
    border: 1px solid #334155;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}
.node-indicator:hover { border-color: #60a5fa; }
.node-indicator.anx-low  { color: #4ade80; }
.node-indicator.anx-mid  { color: #facc15; }
.node-indicator.anx-high { color: #f87171; }
.node-indicator.energy   { color: #a78bfa; }

/* Бейдж срока */
.node-due {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    flex-shrink: 0;
    white-space: nowrap;
}
.node-due.overdue { color: #f87171; border-color: #7f1d1d; }
.node-due.today   { color: #facc15; border-color: #78350f; }

/* Кнопки действий ноды */
.node-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.node:hover .node-actions { opacity: 1; }
.node-actions button {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px 6px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
}
.node-actions button:hover { background: #334155; color: #f1f5f9; }
.node-actions button.btn-done:hover   { color: #22c55e; }
.node-actions button.btn-undo:hover   { color: #eab308; }
.node-actions button.btn-delete:hover { color: #f87171; }

/* Состояния нод */
.node.status-done .node-title {
    text-decoration: line-through;
    color: #64748b;
}
.node.status-postponed { opacity: 0.55; }
.node.status-postponed .node-title { color: #94a3b8; }
.node.status-deleted { opacity: 0.35; }

.node-postponed-mark {
    font-size: 12px;
    color: #94a3b8;
    flex-shrink: 0;
}

/* Системный узел «Без цели» */
.node.system .node-title {
    color: #94a3b8;
    font-style: italic;
    cursor: default;
}
.node.system .node-title:hover { color: #94a3b8; }

/* ============================================
   Модальные окна
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background: rgba(0, 0, 0, 0.55);
}
.modal.open { display: block; }
.modal-content {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 20px;
    margin: 5% auto;
    padding: 24px;
    width: 90%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    color: #e2e8f0;
}
.modal-content.modal-small { max-width: 420px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #334155;
}
.modal-header h3 {
    color: #f1f5f9;
    font-weight: 400;
    font-size: 18px;
}
.modal-close {
    color: #94a3b8;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    background: transparent;
    border: none;
    line-height: 1;
}
.modal-close:hover { color: #f1f5f9; }

.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    color: #94a3b8;
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: 500;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-hint {
    color: #64748b;
    font-size: 11px;
    margin-top: 4px;
}

/* Обязательное поле */
.form-group label.required::after {
    content: ' *';
    color: #f87171;
}

/* Кнопка разворота расширенной формы */
.expand-toggle {
    background: transparent;
    border: 1px dashed #475569;
    color: #94a3b8;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    margin: 8px 0;
    transition: 0.15s;
}
.expand-toggle:hover {
    border-color: #60a5fa;
    color: #60a5fa;
}

/* Свёрнутый блок расширенной формы */
.expanded-section {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.expanded-section.open {
    max-height: 3000px;
}

.section-divider {
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 8px;
    border-bottom: 1px solid #334155;
    padding-bottom: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #334155;
}

/* ============================================
   Тосты (уведомления)
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.2s ease;
    max-width: 360px;
}
.toast.ok    { border-color: #166534; }
.toast.error { border-color: #7f1d1d; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Утилиты
   ============================================ */
.muted { color: #64748b; }
.hidden { display: none !important; }
.flex-spacer { flex: 1; }

/* ============================================
   v2: типы целей, регулярные дела, виртуалы
   ============================================ */

/* Radio-row (тип цели) */
.radio-row {
    display: flex;
    gap: 20px;
    margin-top: 4px;
}
.radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    transition: 0.15s;
}
.radio-item:hover { border-color: #60a5fa; }
.radio-item input[type="radio"] {
    accent-color: #3b82f6;
    cursor: pointer;
}
.radio-item input[type="radio"]:checked + span,
.radio-item:has(input[type="radio"]:checked) {
    color: #f1f5f9;
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* Checkbox-item (регулярное дело) */
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f1f5f9;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
}
.checkbox-item input[type="checkbox"] {
    accent-color: #3b82f6;
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* Блок регулярности */
.recurring-box {
    margin-top: 12px;
    padding: 14px 16px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
}

/* Input с суффиксом (1 дн., 2 нед.) */
.input-with-suffix {
    display: flex;
    align-items: center;
    gap: 8px;
}
.input-with-suffix input[type="number"] {
    width: 90px;
}
.input-with-suffix .suffix {
    color: #94a3b8;
    font-size: 13px;
    white-space: nowrap;
}

/* Дни недели */
.weekdays-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}
.weekdays-row label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #cbd5e1;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #334155;
    transition: 0.15s;
}
.weekdays-row label:hover { border-color: #60a5fa; }
.weekdays-row label:has(input:checked) {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    color: #f1f5f9;
}
.weekdays-row input[type="checkbox"] {
    accent-color: #3b82f6;
    cursor: pointer;
}

/* Иконки в дереве */
.node-goal-kind {
    font-size: 14px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.node-recurring {
    font-size: 12px;
    flex-shrink: 0;
    color: #60a5fa;
    width: 16px;
    text-align: center;
    line-height: 1;
}

/* Виртуальные ноды */
.virtual-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed #334155;
}
.virtual-header {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-left: 8px;
}
.node.virtual {
    border: 1px dashed #475569;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    margin-bottom: 4px;
    cursor: default;
}
.node.virtual:hover { background: rgba(15, 23, 42, 0.7); }
.node.virtual .node-title {
    color: #94a3b8;
    font-style: italic;
    cursor: default;
}
.node.virtual .node-title:hover { color: #94a3b8; }
.node.virtual .virtual-icon { color: #a78bfa; }

/* ============================================
   v2.1: кликабельные индикаторы + свёрнутое описание + модалка приоритета
   ============================================ */

/* Приоритет — кликабельный */
.node-priority.clickable {
    cursor: pointer;
    transition: transform 0.12s;
}
.node-priority.clickable:hover {
    transform: scale(1.4);
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.4);
}

/* Срок — кликабельный */
.node-due.clickable {
    cursor: pointer;
    transition: 0.15s;
}
.node-due.clickable:hover {
    border-color: #60a5fa;
    color: #60a5fa;
}
.node-due.empty-due {
    opacity: 0.35;
}
.node-due.empty-due:hover {
    opacity: 0.9;
}

/* Облегчение после (зелёный) — индикатор */
.node-indicator.relief {
    color: #cbd5e1;
}
.node-indicator.relief.rel-low  { color: #f87171; }   /* низкое облегчение — плохо */
.node-indicator.relief.rel-mid  { color: #facc15; }
.node-indicator.relief.rel-high { color: #4ade80; }   /* высокое — хорошо */

/* Индикатор «Облегчение» — зелёный кружок */
.node-indicator.relief::first-letter {
    /* уже часть строки, отдельно не нужно */
}

/* ============================================
   Свёрнутое описание (collapsible)
   ============================================ */
.form-collapsible {
    margin-bottom: 14px;
}
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: transparent;
    border: 1px dashed #475569;
    color: #94a3b8;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: 0.15s;
}
.collapsible-header::after {
    content: '▼';
    font-size: 10px;
    color: #64748b;
    transition: transform 0.2s;
}
.form-collapsible.open .collapsible-header::after {
    transform: rotate(180deg);
}
.collapsible-header:hover {
    border-color: #60a5fa;
    color: #60a5fa;
}
.form-collapsible.open .collapsible-header {
    border-style: solid;
    border-color: #334155;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.collapsible-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.form-collapsible.open .collapsible-body {
    max-height: 400px;
}
.collapsible-body textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
}

/* ============================================
   Строка со сроком в модалке
   ============================================ */
.due-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.due-row input {
    flex: 1;
}
.due-row .btn-clear {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1;
}

/* ============================================
   Модалка приоритета — 4 варианта
   ============================================ */
.priority-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.prio-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid #334155;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: 0.15s;
    color: #cbd5e1;
    font-size: 14px;
}
.prio-choice:hover {
    border-color: #60a5fa;
    background: rgba(59, 130, 246, 0.05);
}
.prio-choice:has(input:checked) {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    color: #f1f5f9;
}
.prio-choice input[type="radio"] {
    accent-color: #3b82f6;
    cursor: pointer;
    margin: 0;
}
.prio-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Flatpickr — тёмная тема под наш стиль */
.flatpickr-calendar {
    background: #1e293b;
    border: 1px solid #475569;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
}
.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after {
    border-bottom-color: #475569;
}
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after {
    border-top-color: #475569;
}
.flatpickr-months .flatpickr-month,
.flatpickr-weekdays,
span.flatpickr-weekday,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.numInputWrapper {
    background: transparent !important;
    color: #e2e8f0 !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
    color: #f1f5f9 !important;
}
.flatpickr-day {
    color: #cbd5e1 !important;
    border-radius: 6px !important;
}
.flatpickr-day:hover,
.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
    background: #334155 !important;
    border-color: #334155 !important;
}
.flatpickr-day.today {
    border-color: #60a5fa !important;
}
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #fff !important;
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #475569 !important;
}
.flatpickr-time,
.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
    background: transparent !important;
    color: #e2e8f0 !important;
}
.flatpickr-time input:hover,
.flatpickr-time .flatpickr-am-pm:hover {
    background: #334155 !important;
}
.flatpickr-prev-month svg,
.flatpickr-next-month svg {
    fill: #94a3b8 !important;
}
.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg {
    fill: #60a5fa !important;
}
.flatpickr-input {
    background: #0f172a !important;
}
