/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Navigation */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 1rem 0;
    display: block;
}

.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-menu li {
    position: relative;
}

.nav-menu a, .nav-menu .dropbtn {
    color: white;
    text-decoration: none;
    padding: 1rem 1.2rem;
    display: block;
    transition: background-color 0.3s;
}

.nav-menu a:hover, .nav-menu .dropbtn:hover {
    background-color: #34495e;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 1px solid #34495e;
    padding-left: 15px;
}

.user-menu span {
    padding: 0.5rem 1rem;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #2c3e50;
    min-width: 180px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1;
}

.dropdown-content a {
    padding: 12px 16px;
    display: block;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 180px);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 30px;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    font-size: 3rem;
}

.stat-info h3 {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-info p {
    color: #666;
}

/* Recent Section */
.recent-section {
    margin-bottom: 40px;
}

.recent-section h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

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

.individual-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.individual-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.individual-card a {
    text-decoration: none;
    color: inherit;
}

.individual-card h3 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.lifespan {
    color: #666;
    font-size: 0.9rem;
}

.location {
    color: #888;
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Quick Actions */
.quick-actions h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

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

.action-card {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.action-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.action-card h3 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.action-card p {
    color: #666;
    font-size: 0.9rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #667eea;
}

.page-header h1 {
    color: #2c3e50;
    font-size: 2rem;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5568d3;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

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

.btn-outline {
    background-color: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover {
    background-color: #667eea;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

/* Forms */
.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.data-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #2c3e50;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group.checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
}

fieldset {
    border: 1px solid #ddd;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
}

fieldset legend {
    color: #2c3e50;
    font-weight: 600;
    padding: 0 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: #2c3e50;
    color: white;
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.data-table .actions {
    display: flex;
    gap: 10px;
}

.person-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.person-link:hover {
    text-decoration: underline;
}

/* Search */
.search-box {
    margin-bottom: 30px;
}

.search-box form {
    display: flex;
    gap: 10px;
    max-width: 600px;
}

.search-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.search-input-large {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1.1rem;
}

.search-container {
    max-width: 800px;
    margin: 0 auto 40px;
}

.search-form {
    display: flex;
    gap: 15px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-tips {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-tips ul {
    margin-left: 25px;
    margin-top: 15px;
}

.search-tips li {
    margin-bottom: 10px;
}

.results-count {
    color: #666;
    margin-bottom: 20px;
}

/* Detail Pages */
.detail-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.detail-main,
.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.info-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 20px;
}

.info-list dt {
    font-weight: 600;
    color: #555;
}

.info-list dd {
    color: #333;
}

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

.person-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

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

.family-block {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 15px;
}

.family-block h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.family-block h4 {
    color: #555;
    margin: 15px 0 10px;
}

.marriage-info {
    color: #666;
    font-style: italic;
    margin: 5px 0;
}

/* Photos */
.photos-section h2 {
    margin-bottom: 15px;
}

.photo-gallery {
    display: grid;
    gap: 15px;
    margin-top: 20px;
}

.photo-item {
    position: relative;
    background: #f8f9fa;
    border-radius: 5px;
    overflow: hidden;
}

.photo-item img {
    width: 100%;
    height: auto;
    display: block;
}

.photo-caption {
    padding: 10px;
    font-size: 0.9rem;
    color: #555;
}

.photo-item .btn-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

.page-info {
    color: #666;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 20px;
}

.flash {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 10px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.flash-close:hover {
    opacity: 1;
}

/* Authentication */
.auth-container {
    max-width: 400px;
    margin: 60px auto;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.auth-card h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-admin {
    background-color: #e74c3c;
    color: white;
}

.badge-contributor {
    background-color: #3498db;
    color: white;
}

.badge-viewer {
    background-color: #95a5a6;
    color: white;
}

.badge-self_editor {
    background-color: #9b59b6;
    color: white;
}

.badge-family_editor {
    background-color: #e67e22;
    color: white;
}

.badge-success {
    background-color: #2ecc71;
    color: white;
}

.badge-danger {
    background-color: #e74c3c;
    color: white;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state p {
    margin-bottom: 15px;
}

/* Error Pages */
.error-page {
    text-align: center;
    padding: 80px 20px;
}

.error-page h1 {
    font-size: 6rem;
    color: #667eea;
    margin-bottom: 20px;
}

.error-page h2 {
    color: #2c3e50;
    margin-bottom: 20px;
}

/* Import/Upload */
.import-container {
    max-width: 800px;
    margin: 0 auto;
}

.import-card {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.upload-form {
    margin-top: 20px;
}

.import-history {
    margin-top: 40px;
}

.role-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 5px;
    margin-top: 20px;
}

.role-info h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.role-info ul {
    margin-left: 20px;
}

.role-info li {
    margin-bottom: 10px;
}

/* Footer */
.footer {
    background-color: #2c3e50;
    color: white;
    padding: 20px 0;
    margin-top: 60px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    padding: 0 20px;
}

/* Multilingual Support */
.bilingual-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lang-primary,
.lang-alternate {
    line-height: 1.6;
}

.lang-alternate {
    color: #555;
    font-style: italic;
}

/* Support for RTL languages (Hebrew, Arabic) */
.rtl {
    direction: rtl;
    text-align: right;
}

/* Preserve Unicode characters */
input[type="text"],
textarea {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
}

/* Fieldset styling for language sections */
fieldset {
    position: relative;
}

fieldset legend {
    display: flex;
    align-items: center;
    gap: 8px;
}

fieldset legend::before {
    content: 'ðŸŒ';
    font-size: 1.2em;
}

/* Language indicator badges */
.lang-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #667eea;
    color: white;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 5px;
}

.lang-badge.primary {
    background: #667eea;
}

.lang-badge.alternate {
    background: #95a5a6;
}

/* Inline icon buttons */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
    transition: transform 0.2s;
    margin-left: 8px;
}

.btn-icon:hover {
    transform: scale(1.2);
}

/* Tree controls */
.tree-controls {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.tree-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.tree-controls input[type="range"] {
    vertical-align: middle;
}

/* Tree container */
#treeContainer {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
}

/* Person list in families section */
.person-list {
    list-style: none;
    padding: 0;
}

.person-list li {
    padding: 8px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.person-list li a {
    flex-grow: 1;
}

.person-list .lifespan {
    color: #666;
    font-size: 0.9em;
    margin-left: 10px;
}

/* Header actions */
.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0;
    }
    
    .detail-container {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid,
    .actions-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-actions {
        width: 100%;
    }
}
