/* ========================================= */
/* TOOLBAR */
/* ========================================= */

.sticky-toolbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #f8f8f8;
    padding: 12px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.table-container {
    overflow-y: auto;
    max-height: 80vh;
}

thead tr:first-child th {
    position: sticky;
    top: 62px;   /* height of toolbar */
    z-index: 900;
    background: #eee;
}

thead tr:nth-child th {
    position: sticky;
    top: 92px;  /* toolbar + first header row */
    z-index: 899;
    background: #eee;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

thead th {
    background: #f4f4f4;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    margin: 30px;
    background: #f8f8f8;
    color: #222;
    text-rendering: optimizeLegibility;
}

/* ========================================= */
/* HEADINGS */
/* ========================================= */

h1, h2, h3 {
    margin-top: 0;
    margin-bottom: .65em;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 600;
    line-height: 1.25;
    color: #1f2f3d;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.2rem;
}

/* ========================================= */
/* CONTAINER */
/* ========================================= */

.container {
    max-width: 1400px;
    margin: auto;
    width: 100%;
    box-sizing: border-box;
}

/* ========================================= */
/* TWO COLUMN LAYOUT */
/* ========================================= */

.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.left-column,
.right-column {
    min-width: 0;
}

/* ========================================= */
/* CARDS */
/* ========================================= */

.card {
    background: #fff;
    padding: 18px 20px;
    margin-bottom: 20px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ========================================= */
/* FORMS */
/* ========================================= */

.search-form {
    margin-bottom: 0;
}

input[type="text"] {
    padding: 8px;
    width: 100%;
    max-width: 320px;
    font: inherit;
    font-size: .95rem;
    line-height: 1.4;
    box-sizing: border-box;
}

select,
textarea {
    padding: 8px;
    font: inherit;
    font-size: .95rem;
    line-height: 1.4;
    max-width: 100%;
}

/* ========================================= */
/* BUTTONS */
/* ========================================= */

button,
.button {
    padding: 6px 10px;
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    letter-spacing: .01em;
    cursor: pointer;
    border: 1px solid #aaa;
    border-radius: 4px;
    background: #eee;
    color: #222;
    text-decoration: none;
    display: inline-block;
    line-height: 1.25;
}

button:hover,
.button:hover {
    background: #ddd;
    text-decoration: none;
}

.primary-button {
    background: #0645ad;
    color: #fff;
    border-color: #0645ad;
}

.primary-button:hover {
    background: #04347f;
}

.danger-button {
    background: #7a1f1f;
    color: #fff;
    border-color: #7a1f1f;
}

.danger-button:hover {
    background: #5f1717;
}

.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Legacy compatibility */
.merge-button {
    background: #eee;
    color: #222;
    border: 1px solid #aaa;
    border-radius: 4px;
}

.merge-button:hover {
    background: #ddd;
}

.small-button {
    padding: 2px 4px;
    font-size: 10px;
    margin-left: 6px;
}

/* ========================================= */
/* TABLES */
/* ========================================= */

table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
}

th,
td {
    padding: 9px 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    vertical-align: top;
    font-size: .95rem;
    line-height: 1.45;
}

th {
    background: #eee;
    font-weight: 700;
    color: #2c3e50;
}

tr:hover {
    background: #f2f6ff;
}

/* ========================================= */
/* LINKS */
/* ========================================= */

a {
    color: #0645ad;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.clear-link {
    margin-left: 8px;
}

/* ========================================= */
/* TEXT */
/* ========================================= */

.meta {
    color: #666;
    margin-top: 6px;
    font-size: 14px;
}

.note {
    color: #666;
    font-size: 14px;
}

.warning {
    color: #a00000;
    font-weight: bold;
}

.id-col {
    color: #666;
    font-size: 13px;
}

.count {
    margin-bottom: 10px;
    color: #555;
}

/* ========================================= */
/* ALERTS */
/* ========================================= */

.alert {
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

.alert-error {
    color: #7a1f1f;
    border: 1px solid #7a1f1f;
    background: #fff4f4;
}

.alert-success {
    color: #1f6b2a;
    border: 1px solid #1f6b2a;
    background: #f2fff4;
}

.alert-warning {
    color: #6b4a00;
    border: 1px solid #b8860b;
    background: #fff8e1;
}

/* ========================================= */
/* MERGE / SELECT CELLS */
/* ========================================= */

.merge-cell {
    white-space: nowrap;
    font-size: 14px;
}

.merge-cell label {
    display: block;
    margin-bottom: 4px;
    cursor: pointer;
}


/* ========================================= */
/* FACTS / INLINE EDIT BOXES */
/* ========================================= */

.fact-item {
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.edit-fact-box {
    margin-top: 12px;
    padding: 12px;
    background: #f4f4f4;
    border-radius: 6px;
}

/* ========================================= */
/* MOBILE ONLY */
/* ========================================= */

@media (max-width: 600px) {

    .two-column-layout {
        grid-template-columns: 1fr;
    }

    body {
        margin: 15px;
    }

    .sticky-toolbar {
        position: static;
    }

}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;

    background: #2c3e50;
    color: white;

    padding: 12px 20px;
    margin-bottom: 20px;

    border-radius: 8px;
}

.site-title a {
    color: white;
    text-decoration: none;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.site-nav {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    font-size: .95rem;
}

.site-nav .button {
    margin: 0;
}

.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    white-space: nowrap;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 210px;
    z-index: 1200;
    background: #ffffff;
    border: 1px solid #bbb;
    border-radius: 4px;
    box-shadow: 0 3px 8px rgba(0,0,0,.18);
    padding: 6px 0;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    padding: 8px 12px;
    color: #222;
    text-decoration: none;
    white-space: nowrap;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active-nav {
    background: #e8f6f3;
    text-decoration: none;
}

.header-search form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.header-search input[type="text"] {
    max-width: 220px;
}

.active-nav {
    background-color: #1abc9c !important;
}

/* ========================================= */
/* READ ONLY FORM FIELDS */
/* ========================================= */

input:disabled,
select:disabled,
textarea:disabled {
    color: #222;
    background-color: #ffffff;
    border: 1px solid #ccc;
    opacity: 1;
    cursor: default;
}

input:disabled::placeholder,
textarea:disabled::placeholder {
    color: #666;
}

/* ========================================= */
/* PHOTO STYLES */
/* ========================================= */

.photo-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 16px;
}

.photo-card img {
	max-width: 100%;
	max-height: 260px;
	display: block;
	margin-bottom: 8px;
	border-radius: 8px;
}

.primary-badge {
	font-weight: bold;
	color: green;
	margin-bottom: 8px;
}

.photo-actions form {
	margin-top: 6px;
}

.person-edit-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px 18px;
	align-items: start;
}

.person-edit-grid p {
	margin: 0 0 8px 0;
}

.person-edit-grid input,
.person-edit-grid select {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.person-edit-full {
	grid-column: 1 / -1;
}

.date-row {
	display: flex;
	gap: 6px;
}

.date-row select {
	width: auto;
	flex: 1;
}
@media (max-width: 850px) {
    .person-edit-grid {
        grid-template-columns: 1fr;
    }

    .person-edit-full {
        grid-column: auto;
    }
}

/* ========================================= */
/* NOTE EDITOR */
/* ========================================= */

.note-editor textarea {
    width: 100%;
    min-height: 420px;
	font-family: Georgia, "Times New Roman", serif;
    box-sizing: border-box;
    font-size: 16px;
    line-height: 1.7;
}

.note-editor input[type="text"] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 18px;
}
/* ========================================= */
/* NOTE CONTENT */
/* ========================================= */


.note-full-text {
    margin-top: 12px;
    line-height: 1.65;
}

.note-full-text p {
    margin: 0 0 1em 0;
}

.note-full-text ul,
.note-full-text ol {
    margin-left: 2em;
    margin-bottom: 1em;
}

.note-full-text blockquote {
    border-left: 4px solid #ccc;
    padding-left: 12px;
    color: #666;
    margin-left: 0;
}

.note-full-text table {
    border-collapse: collapse;
    margin-bottom: 1em;
}

.note-full-text th,
.note-full-text td {
    border: 1px solid #ccc;
    padding: 6px 10px;
}

/* ========================================= */
/* NOTE CONTENT */
/* ========================================= */


.site-header {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.site-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.header-search {
    margin-left: auto;
}

.header-search form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-search input {
    width: 250px;
}

.person-edit-full {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 1em;
}

.review-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.needs-review-row {
    background-color: #fff4f4;   /* pale yellow */
}

.needs-review-row:hover {
    background-color: #ffe4e4;
}
/* ========================================= */
/* HOME DASHBOARD */
/* ========================================= */

.home-hero-layout {
    --home-hero-height: 193px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.home-hero-layout .card {
    margin-bottom: 0;
}

.home-welcome-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: var(--home-hero-height);
    overflow: auto;
}

.home-hero-layout .home-graphic-placeholder {
    height: var(--home-hero-height);
}

.home-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr);
    gap: 20px;
    align-items: start;
}

.home-dashboard .card {
    margin-bottom: 0;
}

.home-dashboard-column {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.home-hero-card {
    display: flex;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.home-graphic {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
}

.home-graphic-placeholder {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, #2c3e50, #1abc9c);
}

.home-graphic-title {
    font-size: 42px;
    font-weight: bold;
    letter-spacing: 1px;
}

.home-graphic-subtitle {
    margin-top: 8px;
    font-size: 18px;
}

.dashboard-item {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.dashboard-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.dashboard-item h3 {
    margin-bottom: 4px;
}

.section-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.home-blog-card,
.home-blog-card .blog-results,
.home-blog-card .blog-result {
    max-width: 100%;
    min-width: 0;
}

.home-blog-card .blog-result {
    overflow-wrap: anywhere;
}

@media (max-width: 850px) {
    .home-dashboard,
    .home-hero-layout {
        grid-template-columns: 1fr;
    }

    .home-welcome-card,
    .home-hero-layout .home-graphic-placeholder {
        height: auto;
        min-height: 0;
    }
}

/* ========================================= */
/* RESOURCE / COMMUNITY PAGES */
/* ========================================= */

.resource-list {
    line-height: 1.5;
    margin-bottom: 0;
}

.resource-list li {
    margin-bottom: 12px;
}

.resource-list .meta {
    display: block;
}

.site-nav {
    flex-wrap: wrap;
}

.note-issue-type {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid #bbb;
    border-radius: 999px;
    background: #f4f4f4;
    color: #333;
    font-size: 12px;
    font-weight: 600;
}

/* ========================================= */
/* BLOG */
/* ========================================= */

.blog-layout {
    display: grid;
    grid-template-columns: minmax(280px, 40%) 1fr;
    gap: 16px;
    align-items: start;
}

.blog-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.blog-filter-bar {
    border-left: 4px solid #0645ad;
}

.blog-filter-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.blog-filter-form p {
    margin: 0;
}

.blog-filter-form input,
.blog-filter-form select {
    width: 100%;
}

.blog-filter-form label {
    display: block;
    min-width: 180px;
}

.blog-filter-form .button-group {
    margin-bottom: 1px;
}

.blog-list-panel {
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    position: sticky;
    top: 12px;
}

.blog-view-panel {
    position: sticky;
    top: 12px;
}

.blog-list-panel input,
.blog-list-panel select {
    width: 100%;
    max-width: 100%;
}

.blog-result {
    border-top: 1px solid #ddd;
    padding: 12px 0;
}

.blog-result-with-thumbnail {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.blog-result-thumbnail {
    flex: 0 0 84px;
}

.blog-result-thumbnail img {
    display: block;
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 4px;
}

.blog-result-content {
    min-width: 0;
    flex: 1;
}

.blog-result-actions {
    margin-top: 8px;
}

.blog-result-selected {
    background: #f5f8ff;
    margin-left: -8px;
    margin-right: -8px;
    padding-left: 8px;
    padding-right: 8px;
}

.blog-result h3 {
    margin-bottom: 4px;
}

.blog-meta,
.muted {
    color: #666;
    font-size: .9rem;
}

.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fff3cd;
    color: #654800;
    font-size: .75rem;
    vertical-align: middle;
}

.blog-category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.blog-person-results,
.blog-selected-people {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.blog-person-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid #bbb;
    border-radius: 999px;
    background: #f6f6f6;
}

.blog-person-chip button {
    padding: 0 5px;
    border-radius: 50%;
}

.blog-audit {
    border-top: 1px solid #ddd;
    margin-top: 24px;
    padding-top: 12px;
}

@media (max-width: 850px) {
    .blog-layout {
        grid-template-columns: 1fr;
    }

    .blog-heading-row {
        display: block;
    }

    .blog-list-panel,
    .blog-view-panel {
        max-height: none;
        overflow-y: visible;
        position: static;
    }
}

.blog-featured-image {
    float: right;
    width: 33.333%;
    margin: 0 0 18px 18px;
}

.blog-featured-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.blog-source-section,
.blog-audit {
    clear: both;
}

@media (max-width: 650px) {
    .blog-featured-image {
        float: none;
        width: 100%;
        margin: 12px 0 18px;
    }
}

.blog-source-section {
    border-top: 1px solid #ddd;
    margin-top: 24px;
    padding-top: 12px;
}

.plain-textarea {
    min-height: 120px;
}

.note-editor .plain-textarea {
    min-height: 96px;
}

/* ========================================= */
/* PERSON SUMMARY */
/* ========================================= */

.person-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 24px;
    align-items: start;
}

.person-summary-grid .card {
    min-width: 0;
}

@media (max-width: 700px) {
    .person-summary-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================= */
/* PERSON VIEW LAYOUT */
/* ========================================= */

.person-view-layout {
    grid-template-columns: minmax(260px, 40fr) minmax(0, 35fr) minmax(260px, 25fr);
}

.person-view-layout .card,
.person-sidebar {
    min-width: 0;
}

.person-sidebar-section h2 {
    font-size: 1.25rem;
}

.person-sidebar-item {
    border-top: 1px solid #ddd;
    padding: 12px 0;
}

.person-sidebar-item:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.person-sidebar-item h3 {
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.person-sidebar-item p,
#person-notes .fact-item p {
    margin-bottom: 0;
}

#person-notes .note-preview,
#person-notes .note-full-text,
.person-sidebar-item p {
    overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
    .person-view-layout {
        grid-template-columns: minmax(240px, .9fr) minmax(0, 1.35fr);
    }

    .person-sidebar {
        grid-column: 1 / -1;
    }
}

@media (max-width: 700px) {
    .person-view-layout {
        grid-template-columns: 1fr;
    }

    .person-sidebar {
        grid-column: auto;
    }

    .person-photo-preview-layout {
        flex-direction: column;
    }

    .person-photo-preview-actions {
        align-self: stretch;
    }
}

.gallery-filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem 1rem;
    align-items: end;
}

.gallery-grid .photo-card h3 {
    margin: 0.6rem 0 0.25rem;
}

.gallery-detail-image {
    max-width: 100%;
    max-height: 75vh;
    height: auto;
    display: block;
    margin: 0 auto 1rem;
}

.gallery-edit-preview {
    max-width: 320px;
    max-height: 320px;
    height: auto;
}

.photo-metadata {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1rem;
}

.photo-metadata dt {
    font-weight: bold;
}

.pagination {
    margin-top: 1rem;
}

.person-featured-photo {
    margin-top: 15px;
}

.person-featured-photo img {
    max-width: 220px;
    max-height: 260px;
    border-radius: 8px;
    cursor: pointer;
}

.person-featured-photo-empty {
    display: inline-block;
    padding: 16px;
    border: 1px dashed #bbb;
    border-radius: 8px;
    color: #666;
    background: #fafafa;
}

.person-photo-preview-layout {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.person-photo-preview-thumbnails {
    flex: 1 1 auto;
    min-width: 0;
}

.person-photo-preview-actions {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
}

.person-tagged-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
    gap: 12px;
}

.person-tagged-photo-card img {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.person-tagged-photo-title {
    font-size: 0.9rem;
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.photo-compact-actions form {
    display: inline;
}
