/* Kinline - Family Tree Database Styles */

:root {
    /* Kinline Colors - clean archival blue */
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --accent: #7c3aed;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
    
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    
    /* Spacing Scale (8px base) */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.5rem;    /* 24px */
    --space-6: 2rem;      /* 32px */
    --space-8: 3rem;      /* 48px */
    
    /* Input sizing */
    --input-height: 2.5rem;      /* 40px - proper touch target */
    --input-height-sm: 2rem;     /* 32px */
    --input-height-lg: 3rem;     /* 48px */
    --input-padding-x: 0.875rem; /* 14px */
    --input-padding-y: 0.5rem;   /* 8px */
    --input-font-size: 0.9375rem; /* 15px */
}

/* Dark Mode */
[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --accent: #a78bfa;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #1a2540;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.5);
}

[data-theme="dark"] .book-cover {
    background: linear-gradient(135deg, #45475a 0%, #313244 100%);
}

[data-theme="dark"] .data-table tbody tr:hover {
    background: #313244;
}

/* Tree dark mode - forest theme colors */
[data-theme="dark"] .tree-node.male rect {
    fill: #1a3d2e;
    stroke: #5A9A6D;
}

[data-theme="dark"] .tree-node.female rect {
    fill: #3d2a1a;
    stroke: #B8986B;
}

[data-theme="dark"] .tree-node.unknown rect {
    fill: #2D3A2E;
    stroke: #6B7A6B;
}

[data-theme="dark"] .tree-node text {
    fill: #E8EBE4;
}

[data-theme="dark"] .tree-link {
    stroke: #4D5A4D;
}

/* Dark mode link colors */
[data-theme="dark"] a {
    color: #89b4fa;
}

[data-theme="dark"] a:hover {
    color: #b4befe;
}

[data-theme="dark"] .family-member,
[data-theme="dark"] .data-table a,
[data-theme="dark"] .person-card,
[data-theme="dark"] .linked-people a,
[data-theme="dark"] .external-links a {
    color: #89b4fa;
}

[data-theme="dark"] .linked-people a:hover {
    background: var(--primary);
    color: #1e1e2e;
}

[data-theme="dark"] .btn {
    background: #313244;
    border-color: #45475a;
    color: #cdd6f4;
}

[data-theme="dark"] .btn:hover {
    background: #45475a;
}

[data-theme="dark"] .btn-primary {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

[data-theme="dark"] .btn-primary:hover {
    background: #2563eb;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #313244;
    border-color: #45475a;
    color: #cdd6f4;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: #89b4fa;
    box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.2);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============ Base Form Elements ============ */
/* Consistent input styling across all forms */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="url"],
textarea,
select {
    height: var(--input-height);
    padding: var(--input-padding-y) var(--input-padding-x);
    font-size: var(--input-font-size);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

textarea {
    height: auto;
    min-height: 5rem;
    resize: vertical;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* Small inputs */
input.input-sm,
select.input-sm {
    height: var(--input-height-sm);
    font-size: 0.8125rem;
    padding: 0.25rem 0.625rem;
}

/* Large inputs */
input.input-lg,
select.input-lg {
    height: var(--input-height-lg);
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

/* Checkbox and radio - keep natural size */
input[type="checkbox"],
input[type="radio"] {
    height: auto;
    width: auto;
}

/* Navbar */
.navbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.nav-logo {
    height: 36px;
    width: auto;
}

/* Show light logo by default, hide dark logo */
.nav-logo-dark {
    display: none;
}

/* Dark mode: show dark logo, hide light logo */
[data-theme="dark"] .nav-logo-light {
    display: none;
}

[data-theme="dark"] .nav-logo-dark {
    display: block;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active,
.nav-links li.active > a {
    color: var(--primary);
    background: var(--bg-secondary);
}

/* Nav dropdown */
.nav-dropdown {
    position: relative;
}
.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    list-style: none;
    min-width: 200px;
    padding: 0.5rem 0;
    z-index: 200;
}

/* Bridge hover gap for nav dropdown */
.nav-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 4px;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}
.nav-dropdown-menu li a {
    display: block;
    padding: 0.5rem 1rem;
    border-radius: 0;
    white-space: nowrap;
}
.nav-dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin: 0.25rem 0;
}
.nav-dropdown-divider a { display: none; }

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--input-height);
    padding: 0 var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--input-font-size);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-small {
    height: var(--input-height-sm);
    padding: 0 var(--space-3);
    font-size: 0.8125rem;
}

.btn-large {
    height: var(--input-height-lg);
    padding: 0 var(--space-5);
    font-size: 1rem;
}

/* Dashboard */
.dashboard {
    text-align: center;
}

.dashboard h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.stats-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    min-width: 140px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary);
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.action-cards {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 3rem;
}

.action-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    min-width: 150px;
}

.action-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.action-icon {
    font-size: 2rem;
}

.action-text {
    font-weight: 500;
}

/* Recent Section */
.recent-section {
    text-align: left;
}

.recent-section h2 {
    margin-bottom: 1rem;
}

.people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.person-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.person-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.person-name {
    display: block;
    font-weight: 500;
}

.person-dates {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Search/Filter */
.search-filters {
    margin-bottom: 1rem;
}

.filter-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--bg-primary);
}

.result-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Data Table */
.data-table {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    border-collapse: collapse;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.data-table tbody tr {
    cursor: pointer;
    transition: all 0.15s;
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
    box-shadow: inset 3px 0 0 var(--primary);
}

.data-table a {
    color: var(--text-primary);
    text-decoration: none;
}

.data-table a:hover {
    color: var(--primary);
}

.nickname {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Person Detail */
.person-detail {
    
}

/* Tabs */
.tabs-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 2rem;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    overflow-x: auto;
}

.tab-btn {
    flex: 0 0 auto;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--primary);
    background: var(--bg-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-primary);
}

.tab-btn .badge {
    background: var(--text-muted);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
}

.tab-btn.active .badge {
    background: var(--primary);
}

.tab-content {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease-in;
    overflow: hidden;
}

.tab-content.active {
    display: block;
}

/* Remove extra borders from detail-section inside tabs */
.tab-content .detail-section {
    border: none;
    padding: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Overview Grid */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Table Scroll Container */
.table-scroll {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.table-scroll::-webkit-scrollbar {
    height: 8px;
}

.table-scroll::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Map Preview */
.map-preview {
    text-align: center;
    padding: 3rem 2rem;
}

/* Profile Photos */
.profile-photo-container {
    flex-shrink: 0;
    margin-right: 1.5rem;
}

.profile-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-color);
    box-shadow: var(--shadow);
}

.profile-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

[data-theme="dark"] .profile-photo {
    border-color: #45475a;
}

[data-theme="dark"] .profile-photo-placeholder {
    background: #313244;
    border-color: #45475a;
}

.header-content {
    flex: 1;
}

.header-content h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.life-dates {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.detail-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.detail-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.info-list dt {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-list dd {
    font-weight: 500;
}

.no-data {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
}

.help-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Family Groups */
.family-group {
    margin-bottom: 1.5rem;
}

.family-group h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.family-unit {
    margin-bottom: 0.5rem;
}

.family-member {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.family-member:hover {
    text-decoration: underline;
}

.marriage-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.children-list {
    list-style: none;
}

.children-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.children-list li:last-child {
    border-bottom: none;
}

.children-list li a {
    font-weight: 500;
}

/* Notes Section */
.notes-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.notes-section h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.notes-section p {
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.child-dates {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

/* Forms */
.add-relation-form,
.add-external-form,
.add-fact-form,
.add-link-form,
.add-evidence-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

/* Fix dropdown/select overflow */
.add-relation-form select,
.add-link-form select,
.add-evidence-form select,
.person-select {
    max-width: 100%;
    min-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure form containers don't overflow */
.detail-section {
    overflow: hidden;
}

.detail-section form {
    max-width: 100%;
}

.add-fact-form,
.add-link-form,
.add-evidence-form {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.add-fact-form h4,
.add-link-form h4,
.add-evidence-form h4 {
    width: 100%;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.form-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
}

/* Form inputs in detail sections - inherit base styles, just constrain width */
.add-relation-form input,
.add-external-form input,
.add-fact-form input,
.add-link-form input,
.add-evidence-form input {
    max-width: 100%;
    flex: 1;
    min-width: 0;
}

.add-relation-form select,
.add-external-form select,
.add-fact-form select,
.add-link-form select,
.add-evidence-form select {
    max-width: 100%;
    flex: 1;
    min-width: 0;
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.1);
}

/* Fix label wrapping */
.add-link-form label,
.upload-form label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    font-size: 0.875rem;
}

/* Responsive form layout */
@media (max-width: 500px) {
    .add-link-form,
    .add-relation-form,
    .add-evidence-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .add-link-form select,
    .add-relation-form select,
    .add-evidence-form select {
        width: 100%;
    }
}

/* Facts Table */
.facts-table {
    width: 100%;
    min-width: 600px;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.facts-table th,
.facts-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.facts-table th {
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.facts-table th:nth-child(1) { width: 15%; }
.facts-table th:nth-child(2) { width: 15%; }
.facts-table th:nth-child(3) { width: 30%; }
.facts-table th:nth-child(4) { width: 30%; }
.facts-table th:nth-child(5) { width: 10%; text-align: center; }

.facts-table td:nth-child(5) {
    text-align: center;
}

/* External Links */
.external-links {
    list-style: none;
    margin-bottom: 1rem;
}

.external-links li {
    padding: 0.25rem 0;
}

.external-links a {
    color: var(--primary);
}

/* Files */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.file-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

.file-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.file-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.file-icon {
    font-size: 2rem;
    padding: 1.5rem;
}

.file-name {
    display: block;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 0.25rem;
}

.primary-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

/* Upload Form */
.upload-form {
    margin-top: 2rem;
    padding: 1.5rem;
    border-top: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.upload-form h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.upload-form input[type="file"] {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    width: 100%;
    cursor: pointer;
}

.upload-form input[type="text"] {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.upload-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.upload-form button {
    width: 100%;
}

.upload-form-inline {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}

.upload-form-inline input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

/* Files Page */
.files-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.file-card-large {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.file-card-large:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.file-thumbnail {
    height: 150px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon-large {
    font-size: 4rem;
}

.file-info {
    padding: 1rem;
}

.file-title {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.file-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* File Detail */
.file-detail-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

.file-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.file-preview img {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-sm);
}

.file-icon-xlarge {
    font-size: 8rem;
    padding: 3rem;
    color: var(--text-muted);
}

.evidence-table {
    width: 100%;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.evidence-table th,
.evidence-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

/* Form Page */
.form-page {
    max-width: 800px;
    margin: 0 auto;
}

.main-form {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Import Page */
.import-page {
    max-width: 600px;
    margin: 0 auto;
}

.import-info {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.import-info h2 {
    margin-bottom: 1rem;
}

.import-info h3 {
    font-size: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.import-info ul {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.import-form {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
}

.import-form .form-group {
    margin-bottom: 1.5rem;
}

.import-form input[type="file"] {
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    cursor: pointer;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.alert-success {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.alert h3 {
    margin-bottom: 0.5rem;
}

/* Library */
.library-page .page-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.book-category {
    margin-bottom: 2rem;
}

.book-category h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    transition: all 0.2s;
}

.book-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.book-cover {
    width: 80px;
    min-height: 120px;
    background: linear-gradient(135deg, #8b5a2b 0%, #654321 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.book-icon {
    font-size: 2rem;
}

.book-info {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
}

.book-source {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.book-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    flex: 1;
}

.book-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

.unmarked-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.unmarked-section h2 {
    margin-bottom: 0.5rem;
}

.unmarked-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.unmarked-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.unmarked-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.unmarked-info .file-size {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.mark-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.mark-form select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Timeline */
.timeline {
    max-width: 800px;
}

.timeline-century {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
}

.timeline-event {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.timeline-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.timeline-content {
    flex: 1;
}

.timeline-date {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
}

.timeline-title {
    margin: 0.25rem 0;
}

.timeline-title .event-type {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.timeline-title a {
    color: var(--text-primary);
    font-weight: 500;
}

.timeline-place,
.timeline-value {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Tasks */
.add-task-form {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.add-task-form h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
}

.add-task-form .form-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.add-task-form input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.add-task-form textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.task-section {
    margin-bottom: 2rem;
}

.task-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.task-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.task-card.priority-1 {
    border-left: 3px solid var(--warning);
}

.task-card.priority-2 {
    border-left: 3px solid var(--danger);
}

.task-card.in-progress {
    border-left: 3px solid var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.task-card.done {
    opacity: 0.6;
}

.task-card.done .task-title {
    text-decoration: line-through;
}

.task-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.task-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.task-person {
    font-size: 0.875rem;
}

.task-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.danger-zone {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.danger-zone h2 {
    color: var(--danger);
}

/* Relationship Calculator */
.calculator-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.relationship-form {
    text-align: center;
}

.person-selectors {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.person-select-group {
    flex: 1;
    max-width: 300px;
}

.person-select-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.person-select-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.relationship-arrow {
    font-size: 2rem;
}

.result-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
}

.result-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.relationship-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.person-badge {
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    text-align: center;
}

.person-badge strong {
    display: block;
    margin-bottom: 0.25rem;
}

.person-badge span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.relationship-badge {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 1.125rem;
}

.relationship-path {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.relationship-path h3 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.path-chain {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.path-node {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.path-node:hover {
    background: var(--primary);
    color: white;
}

.path-connector {
    color: var(--text-muted);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        gap: 1rem;
    }
    
    .container {
        padding: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .header-actions .btn {
        flex: 1 1 auto;
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .overview-grid {
        grid-template-columns: 1fr;
    }
    
    .file-detail-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-form {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }
    
    .tab-content {
        padding: 1rem;
    }
    
    .profile-photo-container {
        margin-right: 1rem;
    }
    
    .profile-photo,
    .profile-photo-placeholder {
        width: 80px;
        height: 80px;
    }
    
    .header-content h1 {
        font-size: 1.25rem;
    }
    
    .life-dates {
        font-size: 0.9rem;
    }
}

/* Global Quick Search */
.nav-search {
    position: relative;
    margin-left: auto;
    margin-right: 1rem;
}

.nav-search input {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 200px;
    transition: width 0.2s, border-color 0.2s;
}

.nav-search input:focus {
    outline: none;
    border-color: var(--primary);
    width: 280px;
}

.nav-search input::placeholder {
    color: var(--text-muted);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-dropdown.active {
    display: block;
}

.search-result {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover, .search-result.selected {
    background: var(--bg-secondary);
}

.search-result .name {
    font-weight: 500;
}

.search-result .dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
}

/* Keyboard shortcut hint */
.kbd {
    background: var(--bg-secondary);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-family: monospace;
    border: 1px solid var(--border-color);
}

/* Welcome Header Branding */
.welcome-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.welcome-icon {
    width: 64px;
    height: 64px;
}

.welcome-header h1 {
    margin: 0;
    color: var(--kinline-green, var(--primary));
}

.tagline {
    font-style: italic;
    color: var(--accent, var(--warm-gold));
}

/* Footer Branding */
.footer-logo {
    height: 24px;
    width: auto;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

footer {
    text-align: center;
}

footer p {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* User Menu in Navbar */
.nav-user {
    position: relative;
    margin-left: 1rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    position: relative;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    font-weight: 600;
}

.user-role.role-admin { background: #dbeafe; color: #1e40af; }
.user-role.role-editor { background: #dcfce7; color: #166534; }
.user-role.role-viewer { background: #f3f4f6; color: #4b5563; }

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 200;
}

/* Bridge the gap so mouse hover isn't lost moving to dropdown */
.user-menu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.5rem;
}

.user-menu:hover .user-dropdown {
    display: block;
}

.user-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
}

.user-dropdown a:hover {
    background: var(--bg-secondary);
}

.user-dropdown a:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.user-dropdown a:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ============ Person Autocomplete ============ */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 2px;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg-secondary);
}

.autocomplete-name {
    font-weight: 500;
}

.autocomplete-dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.autocomplete-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Recent people pills */
.recent-people {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.recent-person {
    padding: 0.25rem 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.recent-person:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
}
