/* ============================================================
   NodeOrchestrator — цитрусовая тема (лимон / апельсин / лайм)
   ============================================================ */

:root {
    --lemon: #FFD93D;
    --lemon-light: #FFF4C2;
    --orange: #FF9F45;
    --orange-dark: #F0842C;
    --lime: #9ADE7B;
    --lime-dark: #7BC558;
    --bg: #FDFDF8;
    --text: #2D3436;
    --text-muted: #95A5A6;
    --danger: #E74C3C;
    --danger-light: #FDEDEC;
    --success: #27AE60;
    --success-light: #EAFAF1;
    --warning: #F39C12;
    --warning-light: #FEF5E7;
    --radius: 16px;
    --radius-small: 12px;
    --shadow: 0 4px 16px rgba(45, 52, 54, 0.08);
    --shadow-hover: 0 8px 24px rgba(45, 52, 54, 0.14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    position: relative;
}

/* ------------------------------------------------------------
   Фоновая анимация — под контентом
   ------------------------------------------------------------ */

.bg-animation {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.14;
}

/* ------------------------------------------------------------
   Layout
   ------------------------------------------------------------ */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px;
    position: relative;
    z-index: 1;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.8rem;
}

.logo a {
    color: var(--orange-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

.logo a:hover { color: var(--orange); }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.footer {
    margin-top: 48px;
    text-align: center;
    padding: 16px 0;
}

/* ------------------------------------------------------------
   Карточки
   ------------------------------------------------------------ */

.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card h3 { margin-bottom: 8px; font-size: 1.15rem; }
.card > .muted { display: block; margin-bottom: 16px; }

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.note-card { display: flex; flex-direction: column; }

.note-title { font-size: 1.15rem; margin-bottom: 10px; }

.note-title a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.note-title a:hover { color: var(--orange-dark); }

.note-preview {
    color: #636E72;
    margin: 0 0 14px;
    flex-grow: 1;
    word-wrap: break-word;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    gap: 8px;
}

.badge {
    background: var(--lemon);
    color: var(--text);
    padding: 3px 12px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.note-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.note-full .note-content { margin-top: 16px; }
.note-full .note-content p {
    margin-bottom: 8px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.note-heading { word-wrap: break-word; }

.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* ------------------------------------------------------------
   Кнопки
   ------------------------------------------------------------ */

.btn {
    display: inline-block;
    border: none;
    border-radius: var(--radius-small);
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
    box-shadow: 0 4px 12px rgba(45, 52, 54, 0.18);
}

.btn:active { transform: translateY(0); }

.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }

.btn-secondary { background: var(--lemon); color: var(--text); }

.btn-accent { background: var(--lime); color: var(--text); }
.btn-accent:hover { background: var(--lime-dark); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-small { padding: 6px 14px; font-size: 0.85rem; }

/* ------------------------------------------------------------
   Формы
   ------------------------------------------------------------ */

.form-card h3 { margin-bottom: 18px; }

.form-field { margin-bottom: 18px; }

.form-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.required { color: var(--danger); }

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="number"],
.form-field textarea {
    width: 100%;
    border: 2px solid #eee;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.4;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 159, 69, 0.15);
}

.form-field input:-webkit-autofill,
.form-field input:-webkit-autofill:hover,
.form-field input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    box-shadow: 0 0 0 1000px #fff inset;
    transition: background-color 9999s ease-out 0s;
}

.auth-form { max-width: 520px; }

.form-field input:disabled,
.form-field textarea:disabled {
    background: #f6f6f6;
    color: var(--text-muted);
}

.btn:disabled,
.btn:disabled:hover {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

.form-field input[type="file"] {
    padding: 8px 0;
}

.password-field { position: relative; }

.password-field input { padding-right: 108px; }

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--orange-dark);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}

.password-toggle:hover { color: var(--orange); }

.password-toggle:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.muted-input { color: var(--text-muted); background: #fafafa; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

/* ------------------------------------------------------------
   Вложения (chips)
   ------------------------------------------------------------ */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    background: var(--lime);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    word-break: break-all;
}

.chip-remove {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--text);
    padding: 0;
    transition: color 0.15s ease;
}

.chip-remove:hover { color: var(--danger); }

.attachments-heading { margin: 20px 0 10px; }

.attachments-list { list-style: none; }

.attachments-list li { margin: 8px 0; }

.attachments-list a {
    color: var(--orange-dark);
    text-decoration: none;
    border-bottom: 1px dashed var(--orange);
    transition: color 0.15s ease, border-color 0.15s ease;
    word-break: break-all;
}

.attachment-extra { margin-left: 10px; font-size: 0.85rem; }

.attachments-list a:hover {
    color: var(--lime-dark);
    border-color: var(--lime-dark);
}

.small { font-size: 0.8rem; margin-top: 8px; }

/* ------------------------------------------------------------
   Flash-сообщения
   ------------------------------------------------------------ */

.flash {
    padding: 14px 20px;
    border-radius: var(--radius-small);
    margin-bottom: 16px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.flash-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.flash-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.flash-warning {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.flash-hiding {
    animation: flashOut 0.35s ease forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes flashOut {
    to { opacity: 0; transform: translateY(-8px); }
}

/* ------------------------------------------------------------
   Модальное окно подтверждения удаления
   ------------------------------------------------------------ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px;
    max-width: 420px;
    width: calc(100% - 32px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
    animation: slideIn 0.25s ease;
}

.modal h3 { margin-bottom: 10px; }

.modal p { color: #636E72; word-wrap: break-word; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ------------------------------------------------------------
   Утилиты
   ------------------------------------------------------------ */

.muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* ------------------------------------------------------------
   Адаптивность
   ------------------------------------------------------------ */

/* ------------------------------------------------------------
   Шапка: вкладки и хозяин
   ------------------------------------------------------------ */

.header-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.tab {
    padding: 8px 16px;
    border-radius: var(--radius-small);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    background: white;
    box-shadow: var(--shadow);
    transition: background 0.2s ease, transform 0.2s ease;
}

.tab:hover { background: var(--lemon-light); transform: translateY(-1px); }
.tab-active { background: var(--lemon); }

.owner {
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-small);
    background: var(--lemon-light);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.owner a { color: inherit; text-decoration: none; }

.btn-link {
    border: 0;
    background: transparent;
    color: var(--orange-dark);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.secret-box {
    margin-top: 12px;
    padding: 12px;
    background: var(--warning-light);
    border-radius: var(--radius-small);
}

.secret {
    display: block;
    margin-top: 8px;
    word-break: break-all;
    font-size: 0.95rem;
}

.token-list { list-style: none; margin: 12px 0; }
.token-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid var(--lemon-light);
}

.invite-row { align-items: flex-start; }
.invite-body { min-width: 0; }
.invite-body > p { margin-bottom: 6px; }
.invite-facts {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 4px 12px;
    margin: 0;
    font-size: 0.95rem;
}
.invite-facts div { display: contents; }
.invite-facts dt { color: var(--text-muted); font-weight: 600; }
.invite-facts dd { margin: 0; word-break: break-word; }

.welcome-card { max-width: 520px; margin: 40px auto; }
.welcome-card h2 { margin-bottom: 8px; }
.welcome-card p { margin-bottom: 20px; }

/* ------------------------------------------------------------
   Цели и задачи
   ------------------------------------------------------------ */

.breadcrumbs { margin-bottom: 16px; }
.breadcrumbs a { color: var(--orange-dark); text-decoration: none; }

.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.goals-list { display: flex; flex-direction: column; gap: 20px; margin-bottom: 24px; }

.goal-card, .task-card { margin-bottom: 24px; }
.goals-list .goal-card { margin-bottom: 0; }

.goal-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.goal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.field-label { display: block; font-weight: 600; margin-bottom: 6px; }

.criterion-choice { display: flex; gap: 16px; flex-wrap: wrap; }
.criterion-choice label { font-weight: 500; display: flex; align-items: center; gap: 6px; }

.goal-checklist {
    margin: 12px 0;
    padding: 12px 14px;
    background: var(--lemon-light);
    border-radius: 12px;
}

.check-list { list-style: none; }
.check-list li { margin: 6px 0; }
.check-list label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check-list input[type="checkbox"] { width: auto; }
.criterion-ask { margin-top: 10px; font-weight: 600; }
.criterion-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.criterion-actions form { margin: 0; }

.goal-title a { color: var(--text); text-decoration: none; }
.goal-title a:hover { color: var(--orange-dark); }
.goal-criterion { margin-bottom: 12px; }
.goal-description { margin-bottom: 12px; }

.goal-progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.progress-bar {
    flex: 1 1 200px;
    height: 10px;
    background: var(--lemon-light);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--lime), var(--lime-dark));
    border-radius: 6px;
    transition: width 0.4s ease;
}

.progress-text { font-weight: 600; white-space: nowrap; }

.goal-status {
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.goal-status-active { background: var(--lemon-light); }
.goal-status-reached { background: var(--success-light); color: var(--success); }
.goal-status-overdue { background: var(--danger-light); color: var(--danger); }

.task-list {
    list-style: none;
    margin-top: 12px;
    padding-left: 1.6rem;
}

.task-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
    padding: 10px 0;
    border-top: 1px solid var(--lemon-light);
}

.task-row::before {
    content: "";
    position: absolute;
    left: -1.05rem;
    top: 50%;
    width: 0.4rem;
    height: 0.4rem;
    margin-top: -0.2rem;
    border-radius: 50%;
    background: var(--text);
}

.task-title { font-weight: 700; }

.task-link { flex: 1 1 240px; color: var(--text); text-decoration: none; }
.task-link:hover .task-title { color: var(--orange-dark); }
.id-tag { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); margin-left: 4px; white-space: nowrap; }

.state {
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.state-planned { background: #ECEFF1; color: #546E7A; }
.state-progress { background: var(--lemon); color: var(--text); }
.state-done { background: var(--lime); color: var(--text); }

.task-deadline { white-space: nowrap; }

.overdue {
    background: var(--danger);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.task-heading { font-size: 1.4rem; }

.task-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 16px;
    margin: 16px 0;
}

.task-facts dt { color: var(--text-muted); }
.task-facts dd a { color: var(--orange-dark); text-decoration: none; }

.task-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.task-description { margin-bottom: 16px; }

/* ------------------------------------------------------------
   Итоги
   ------------------------------------------------------------ */

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card { text-align: center; }
.stat-value { display: block; font-size: 2.4rem; font-weight: 700; color: var(--lime-dark); }
.stat-label { color: var(--text-muted); }
.stat-card-overdue .stat-value { color: var(--danger); }

/* ------------------------------------------------------------
   Связи заметок с целями и задачами
   ------------------------------------------------------------ */

.links-card { margin-bottom: 24px; }
.link-list { list-style: none; }

.link-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-top: 1px solid var(--lemon-light);
}

.link-list li:first-child { border-top: none; }
.link-list a { color: var(--text); text-decoration: none; flex: 1 1 240px; }
.link-list a:hover { color: var(--orange-dark); }
.note-number { font-weight: 700; color: var(--orange-dark); }
.inline-form { display: inline; margin-left: auto; }

.link-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.link-form select {
    flex: 1 1 260px;
    padding: 10px 14px;
    border: 1px solid var(--lemon-light);
    border-radius: var(--radius-small);
    font: inherit;
    background: white;
}

@media (max-width: 640px) {
    .container { padding: 20px 14px; }
    .page-header { flex-direction: column; align-items: stretch; }
    .header-actions { justify-content: flex-start; }
    .notes-grid { grid-template-columns: 1fr; }
    .task-facts { grid-template-columns: 1fr; }
}

.estimate-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.chip {
    padding: 6px 14px;
    border: 2px solid var(--lemon);
    border-radius: 16px;
    background: #fff;
    font: inherit;
    cursor: pointer;
}
.chip:hover { border-color: var(--orange-dark); }
.chip.active { background: var(--lemon); border-color: var(--orange-dark); font-weight: 700; }
.deadline-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.deadline-row input[type="date"],
.deadline-row input[type="time"] { width: auto; flex: 1 1 180px; min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
