/* ── Dark theme ─────────────────────────────────────────────
   Activated by body.theme-dark (shared/theme.ts resolves the saved
   preference or the system prefers-color-scheme). Most surfaces use the
   shared CSS variables, so flipping them does the bulk of the work;
   the rules below patch the remaining hardcoded colours. */

body.theme-dark {
  --clr-dark:    #dce3e9;   /* primary text */
  --clr-light:   #2b333c;   /* subtle surfaces / hover */
  --clr-white:   #1e242b;   /* cards, modals, panels */
  --clr-header:  #10141a;
  --clr-sidebar: #1a2129;
  --clr-bg:      #15181c;
  --shadow:      0 2px 8px rgba(0,0,0,.5);
}

/* Form controls and Quill */
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #242b33;
  color: var(--clr-dark);
  border-color: #3a434d;
}
body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder { color: #8593a0; }

/* Form field labels and table headers (editor panel + person modal + auth):
   hardcoded #636e72/#7f8c8d greys are too dim on dark surfaces */
body.theme-dark .form-group label,
body.theme-dark .section-label,
body.theme-dark .links-table th,
body.theme-dark #person-edit-modal .form-group label,
body.theme-dark #person-edit-modal .section-label,
body.theme-dark .auth-form-group label { color: #aab8c4; }
body.theme-dark #person-edit-modal .links-table th,
body.theme-dark #person-edit-modal .links-table td { border-bottom-color: #3a434d; }

/* Quill placeholder text ("Přidejte poznámky…") is rgba(0,0,0,.6) by default */
body.theme-dark .ql-editor.ql-blank::before { color: #8593a0; }
body.theme-dark .ql-toolbar,
body.theme-dark .ql-container { border-color: #3a434d !important; }
body.theme-dark .ql-toolbar { background: #242b33; }
body.theme-dark .ql-editor { color: var(--clr-dark); }
body.theme-dark .ql-snow .ql-stroke { stroke: #aab6c0; }
body.theme-dark .ql-snow .ql-fill { fill: #aab6c0; }
body.theme-dark .ql-snow .ql-picker { color: #aab6c0; }

/* Borders that are hardcoded light greys in the component styles */
body.theme-dark .links-table th,
body.theme-dark .links-table td,
body.theme-dark .modal,
body.theme-dark .modal-header,
body.theme-dark .modal-footer,
body.theme-dark .toolbar-menu-items,
body.theme-dark .toast,
body.theme-dark .palette-input { border-color: #3a434d; }

/* Inline-styled rows/boxes from the settings & dashboards (literal colours) */
body.theme-dark [style*="#2c3e50"] { color: var(--clr-dark) !important; }
body.theme-dark [style*="background:#f9fafb"],
body.theme-dark [style*="background: #f9fafb"] { background: #242b33 !important; }
body.theme-dark [style*="#dfe6e9"] { border-color: #3a434d !important; }

/* ── Text on coloured or fixed-dark surfaces ──
   These elements use var(--clr-white)/var(--clr-light) as TEXT colour;
   after the variable flip that would be dark-on-dark, so pin it light. */
body.theme-dark #header,
body.theme-dark .btn-primary-action,
body.theme-dark #btn-goto-root,
body.theme-dark .actions-row button,
body.theme-dark .dashboard-header-actions button,
body.theme-dark .auth-btn,
body.theme-dark .auth-btn-secondary:hover,
body.theme-dark .export-download-btn,
body.theme-dark .modal-footer .btn-primary,
body.theme-dark .modal-footer .btn-danger { color: #eef2f6; }
/* …but on the yellow warning button light text is unreadable */
body.theme-dark .btn-set-root { color: #26313a; }
/* Sidebar inherits --clr-light as text colour, which is now a surface tone */
body.theme-dark #sidebar { color: #c9d3dc; }

/* Buttons don't inherit text colour — the UA default (black) disappears
   on the dark tab surfaces */
body.theme-dark .view-tab { color: var(--clr-dark); }
body.theme-dark .view-tab:hover { background: #353f4a; }
body.theme-dark .modal-footer button { border-color: #3a434d; }

/* ── Tree view ── */
body.theme-dark .tree-card { border-color: #3a434d; }
body.theme-dark .tree-card__dates { color: #93a1ad; }
body.theme-dark [class*="tree-"][style*="#fffde7"],
body.theme-dark [class*="tree-"][style*="#fff9c4"] { background: #3a3a22 !important; }

/* Focal cards: dark gender tints instead of the light pastels */
body.theme-dark .tree-focal-card--m { background: #20303f; border-color: #3c5a78; }
body.theme-dark .tree-focal-card--f { background: #3b2b21; border-color: #7a543a; }
body.theme-dark .tree-focal-card--u { background: #262d34; border-color: #4a545e; }
body.theme-dark .tree-focal-card--m .tree-focal-card__header { background: rgba(120,170,225,.10); }
body.theme-dark .tree-focal-card--f .tree-focal-card__header { background: rgba(235,160,95,.10); }
body.theme-dark .tree-focal-card__year,
body.theme-dark .tree-focal-card__detail-label,
body.theme-dark .tree-focal-card__menu-btn { color: #9db0bf; }
body.theme-dark .tree-focal-card__avatar {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.16);
}
body.theme-dark .tree-focal-card__footer { border-top-color: rgba(255,255,255,.08); }
body.theme-dark .tree-focal-card__btn {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.24);
  color: var(--clr-dark);
}
body.theme-dark .tree-focal-card__btn:hover { background: rgba(255,255,255,.15); }
body.theme-dark .tree-focal-card__menu-btn:hover { background: rgba(255,255,255,.10); }
body.theme-dark .tree-focal-card__menu-dropdown { border-color: #3a434d; }
body.theme-dark .tree-focal-card__menu-item { border-bottom-color: #3a434d; }
body.theme-dark .tree-focal-card__menu-item:hover,
body.theme-dark .tree-context-menu__item:hover { background: #2b333c; }
body.theme-dark .tree-context-menu { border-color: #3a434d; }

/* Couple-edit buttons + family strip */
body.theme-dark .tree-couple-edit { border-color: #3a434d; }
body.theme-dark .tree-couple-edit--has-marriage {
  background: #3a3322;
  border-color: #8a742c;
  color: #e6c454;
}
body.theme-dark .tree-couple-edit--has-marriage:hover {
  background: #4a4128;
  border-color: #b29a3d;
  color: #f0d36b;
}
body.theme-dark .tree-family-strip { border-color: #3a434d; }
body.theme-dark .tree-family-strip__children { color: #98a6b3; }
body.theme-dark .tree-family-strip__link-btn:hover { color: #7ec3f0; }
body.theme-dark .tree-family-strip__edit-btn { border-color: #3a434d; }
body.theme-dark .tree-family-strip__edit-btn:hover { background: #2b333c; border-color: #4a545e; }

/* ── Family view ── */
body.theme-dark .marriage-details { background: #242b33; border-color: #3a434d; }
body.theme-dark .marriage-detail-row label { color: #9db0bf; }

/* ── Places screen ── */
body.theme-dark .places-screen { background: var(--clr-bg); }
body.theme-dark .places-col { border-right-color: #3a434d; }
body.theme-dark .places-list-item { border-bottom-color: #2b333c; }
body.theme-dark .places-list-item:hover,
body.theme-dark .places-list-sub-item:hover,
body.theme-dark .places-bulk-item:hover,
body.theme-dark .places-bulk-col-toolbar button:hover { background: #2b333c; }
body.theme-dark .places-list-item.selected { background: #1d2c3d; }
body.theme-dark .places-list-group-header { background: #20262d; }
body.theme-dark .places-list-group-header:hover { background: #2b333c; }
body.theme-dark .places-list-sub-item { background: #1a2026; }
body.theme-dark .places-col-detail h3,
body.theme-dark .places-col-detail h4 { color: var(--clr-dark); }
body.theme-dark .places-detail-section { background: #20262d; border-color: #3a434d; }
body.theme-dark .places-detail-section label,
body.theme-dark .places-detail-aliases { color: #9db0bf; }
body.theme-dark .places-candidate { background: #242b33; border-color: #3a434d; }
body.theme-dark .places-candidate:hover { background: #1d2c3d; }
body.theme-dark .places-bulk-col-places { border-right-color: #3a434d; }
body.theme-dark .places-bulk-col-toolbar { border-bottom-color: #2b333c; }
body.theme-dark .places-bulk-col-toolbar button {
  background: #242b33;
  border-color: #3a434d;
  color: var(--clr-dark);
}

/* ── Zajímavosti screen ── */
body.theme-dark .zajimavosti-screen { background: var(--clr-bg); }
body.theme-dark .zajimavosti-persons-table th { background: #10141a; }
body.theme-dark .zajimavosti-persons-table td { border-color: #3a434d; }
body.theme-dark .zajimavosti-persons-table tbody tr:hover td { background: #1d2c3d; }
body.theme-dark .zajimavosti-persons-table .note-cell { color: #9aa7b2; }

/* ── Projects dashboard ── */
body.theme-dark .project-item,
body.theme-dark .project-item-actions button { border-color: #3a434d; }
/* Icon buttons (open/delete) don't inherit text colour — UA default is black */
body.theme-dark .project-item-actions button { color: var(--clr-dark); }
body.theme-dark .project-item.archived .project-item-icon,
body.theme-dark .project-item-archive-badge { background: rgba(255, 255, 255, 0.07); }

/* ── Match-import (zvoneček, detail shody, wizard) ── */
body.theme-dark .match-bell-menu { border-color: #3a434d; }
body.theme-dark .match-compare-table th,
body.theme-dark .match-compare-table td { border-color: #3a434d; }
body.theme-dark .match-compare-table td.cell-eq { background: rgba(39, 174, 96, 0.22); }
body.theme-dark .match-compare-table td.cell-partial { background: rgba(241, 196, 15, 0.16); }
body.theme-dark .match-wizard-step { border-bottom-color: #3a434d; }
body.theme-dark .match-wizard-mini-btn { border-color: #3a434d; }
body.theme-dark .match-wizard-table th,
body.theme-dark .match-wizard-table td { border-bottom-color: #3a434d; }
body.theme-dark .match-wizard-badge--exists { color: #f0a558; }
body.theme-dark .match-wizard-badge--complete { color: #58d68d; }
body.theme-dark .match-wizard-badge--self { color: #7ec3f0; }
body.theme-dark .merge-choice-card { border-color: #3a434d; }
body.theme-dark .merge-choice-card:hover { border-color: #4a545e; }
body.theme-dark .merge-choice-card.selected {
  border-color: #27ae60;
  background: rgba(39, 174, 96, 0.12);
}
body.theme-dark .merge-choice-card__row { color: #9db0bf; }
body.theme-dark .merge-choice-card__badge { color: #f0a558; }
body.theme-dark .merge-choice-card.selected .merge-choice-card__badge { color: #58d68d; }

/* ── Settings screen ── */
body.theme-dark .settings-nav { border-color: #3a434d; }
body.theme-dark .settings-section-title { border-bottom-color: #3a434d; }
body.theme-dark .settings-nav-item.active { background: rgba(90, 150, 220, 0.16); color: #7ec3f0; }

/* ── Auth screen ── */
body.theme-dark .auth-backup-separator::before,
body.theme-dark .auth-backup-separator::after { background: #3a434d; }
body.theme-dark .auth-uri-row button:hover { background: #2b333c; }

/* ── Misc ── */
body.theme-dark .export-progress-track { background: #2b333c; }
body.theme-dark #embed-code-modal textarea {
  background: #242b33;
  color: var(--clr-dark);
  border-color: #3a434d;
}
