/**
 * Family Tree Expansions CSS
 * Comprehensive styling for advanced family tree features including
 * search, analytics, and multiple layout options
 */

/* ===== SEARCH AND NAVIGATION STYLES ===== */

.family-search-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.family-search-container:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.search-bar-container {
    margin-bottom: 20px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #dee2e6;
    border-radius: 30px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    background: white;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-clear-btn, .advanced-search-toggle {
    margin-left: 12px;
    padding: 12px;
    border: none;
    background: #6c757d;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover, .advanced-search-toggle:hover {
    background: #5a6268;
    transform: scale(1.05);
}

.search-filters {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

.search-filters.visible {
    display: block;
}

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

.filter-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f3f4;
}

.filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.filter-group label {
    margin-right: 20px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: color 0.3s ease;
}

.filter-group label:hover {
    color: #007bff;
}

.filter-group input[type="checkbox"],
.filter-group input[type="radio"] {
    margin-right: 8px;
    transform: scale(1.1);
}

.search-results-container {
    background: white;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.results-count {
    font-weight: 600;
    color: #495057;
    font-size: 16px;
}

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

.action-btn {
    padding: 8px 16px;
    border: none;
    background: #007bff;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.search-results-list {
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #dee2e6 transparent;
}

.search-results-list::-webkit-scrollbar {
    width: 8px;
}

.search-results-list::-webkit-scrollbar-track {
    background: transparent;
}

.search-results-list::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 4px;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid #f1f3f4;
    transition: all 0.3s ease;
}

.search-result-item:hover {
    background: #f8f9fa;
    transform: translateX(3px);
}

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

.result-info {
    flex: 1;
}

.result-name {
    font-weight: 600;
    color: #007bff;
    font-size: 16px;
    margin-bottom: 4px;
}

.result-title {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 6px;
}

.result-snippet {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.4;
}

.result-actions {
    display: flex;
    gap: 6px;
}

.result-actions button {
    padding: 8px 10px;
    border: none;
    background: #6c757d;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.result-actions button:hover {
    background: #5a6268;
    transform: scale(1.05);
}

/* Navigation Styles */

.navigation-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 25px;
}

.breadcrumb-navigation, .quick-navigation {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.breadcrumb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f3f4;
}

.breadcrumb-header h4 {
    margin: 0;
    color: #495057;
    font-size: 16px;
}

.clear-btn {
    padding: 6px 10px;
    border: none;
    background: #dc3545;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

.breadcrumb-trail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    border-radius: 20px;
    font-size: 12px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.breadcrumb-item:hover {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    transform: scale(1.02);
}

.breadcrumb-name {
    margin-right: 6px;
}

.breadcrumb-select {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px;
    transition: transform 0.3s ease;
}

.breadcrumb-select:hover {
    transform: scale(1.2);
}

.breadcrumb-separator {
    color: #6c757d;
    font-size: 14px;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section:last-child {
    margin-bottom: 0;
}

.nav-section h4 {
    margin: 0 0 12px 0;
    color: #495057;
    font-size: 16px;
}

.quick-nav-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.nav-btn, .bookmark-btn {
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn:hover, .bookmark-btn:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
}

.bookmark-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.bookmarks-list {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #dee2e6 transparent;
}

.no-bookmarks {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
}

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.3s ease;
}

.bookmark-item:hover {
    background: #f8f9fa;
}

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

.bookmark-info {
    flex: 1;
}

.bookmark-name {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
}

.bookmark-title {
    font-size: 11px;
    color: #6c757d;
}

.bookmark-actions {
    display: flex;
    gap: 6px;
}

.bookmark-actions button {
    padding: 6px 8px;
    border: none;
    background: #6c757d;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.3s ease;
}

.bookmark-actions button:hover {
    background: #5a6268;
    transform: scale(1.05);
}

/* Notification Styles */

.search-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== ANALYTICS STYLES ===== */

.family-analytics-container {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    margin-top: 25px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.analytics-header h3 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.analytics-controls {
    display: flex;
    gap: 10px;
}

.analytics-btn {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.analytics-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.analytics-content {
    padding: 25px;
}

/* Stats Overview */

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

.stat-card {
    display: flex;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    margin-right: 15px;
    font-size: 24px;
    color: #007bff;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: #495057;
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Chart Tabs */

.chart-tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 25px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chart-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.tab-btn:hover {
    color: #007bff;
    background: rgba(0, 123, 255, 0.05);
}

/* Chart Panels */

.chart-panels {
    position: relative;
    min-height: 400px;
}

.chart-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.chart-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.panel-header h4 {
    margin: 0;
    color: #495057;
    font-size: 18px;
}

.chart-options select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    cursor: pointer;
}

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 20px;
    background: #fafafa;
    border-radius: 8px;
    padding: 15px;
}

.timeline-container {
    height: 250px;
}

/* Chart Insights */

.chart-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.insight-item {
    font-size: 14px;
    color: #495057;
}

.insight-item strong {
    color: #007bff;
}

/* Generation Details */

.generation-details {
    margin-top: 20px;
}

#generation-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.generation-card {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.generation-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
}

.generation-stats {
    font-size: 13px;
    color: #6c757d;
}

/* Relationship Metrics */

.relationship-metrics {
    margin-bottom: 20px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.metric-item {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #007bff;
    margin-bottom: 5px;
}

.metric-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Timeline Insights */

.timeline-insights {
    margin-top: 20px;
}

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

.insight-card {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    text-align: center;
}

.insight-card h5 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 14px;
}

.insight-card div {
    font-weight: 600;
    color: #007bff;
    font-size: 16px;
}

/* Longevity Trends */

.longevity-trends {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Detailed Insights */

.detailed-insights {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #e9ecef;
}

.detailed-insights h4 {
    margin-bottom: 20px;
    color: #495057;
    font-size: 18px;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.insight-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.insight-section h5 {
    margin: 0 0 15px 0;
    color: #007bff;
    font-size: 16px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
}

.insight-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.insight-section li {
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
    color: #495057;
}

.insight-section li:last-child {
    border-bottom: none;
}

/* ===== ADVANCED LAYOUT STYLES ===== */

/* Force-directed layout specific styles */
.force-link {
    stroke: #999;
    stroke-opacity: 0.6;
}

.force-link.marriage {
    stroke: #4caf50;
    stroke-width: 3px;
    stroke-dasharray: 5,5;
}

.force-node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.force-node:hover circle {
    stroke-width: 3px;
    r: 10;
}

.force-node.current circle {
    stroke: #007bff;
    stroke-width: 4px;
}

/* Radial layout specific styles */
.radial-link {
    stroke: #666;
    stroke-width: 2;
    fill: none;
    opacity: 0.7;
}

.generation-label {
    font-size: 12px;
    fill: #666;
    text-anchor: middle;
    font-weight: bold;
}

/* Timeline layout specific styles */
.timeline-axis {
    stroke: #333;
    stroke-width: 2;
}

.timeline-tick {
    stroke: #666;
    stroke-width: 1;
}

.timeline-tick-label {
    font-size: 10px;
    fill: #666;
    text-anchor: middle;
}

.timeline-connection {
    stroke: #999;
    stroke-width: 1;
    stroke-dasharray: 2,2;
    opacity: 0.5;
}

/* Layout controls */
.layout-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.layout-btn {
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.layout-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.layout-btn:hover {
    border-color: #007bff;
    color: #007bff;
}

.layout-btn.active:hover {
    background: #0056b3;
    color: white;
}

/* Tree highlighting styles */
.tree-node.highlighted circle {
    stroke: #ff9800;
    stroke-width: 4px;
    fill: #fff3e0;
}

.tree-node.search-result circle {
    stroke: #e91e63;
    stroke-width: 3px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.5; }
    100% { stroke-opacity: 1; }
}

/* Responsive Design */

@media (max-width: 1024px) {
    .navigation-container {
        grid-template-columns: 1fr;
    }
    
    .stats-overview {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .family-search-container,
    .family-analytics-container {
        margin: 15px;
        padding: 15px;
    }
    
    .search-input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-clear-btn,
    .advanced-search-toggle {
        margin: 10px 0 0 0;
        align-self: flex-end;
        width: auto;
    }
    
    .filter-group {
        margin-bottom: 15px;
    }
    
    .filter-group label {
        display: block;
        margin: 5px 0;
    }
    
    .breadcrumb-trail {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        flex: 1;
        min-width: 120px;
    }
    
    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .insight-grid {
        grid-template-columns: 1fr;
    }
    
    .analytics-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .analytics-controls {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stats-overview {
        grid-template-columns: 1fr;
    }
    
    .metric-grid {
        grid-template-columns: 1fr;
    }
    
    .search-results-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .timeline-container {
        height: 200px;
    }
}

/* Dark mode support (only when explicit theme not set to light) */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .family-search-container,
    html:not([data-theme="light"]) .family-analytics-container {
        background: #2d3436;
        border-color: #636e72;
        color: #ddd;
    }

    html:not([data-theme="light"]) .search-input {
        background: #2d3436;
        border-color: #636e72;
        color: #ddd;
    }

    html:not([data-theme="light"]) .search-filters,
    html:not([data-theme="light"]) .breadcrumb-navigation,
    html:not([data-theme="light"]) .quick-navigation {
        background: #2d3436;
        border-color: #636e72;
    }

    html:not([data-theme="light"]) .stat-card,
    html:not([data-theme="light"]) .chart-insights,
    html:not([data-theme="light"]) .insight-card,
    html:not([data-theme="light"]) .metric-item {
        background: #2d3436;
        border-color: #636e72;
        color: #ddd;
    }

    html:not([data-theme="light"]) .analytics-header {
        background: linear-gradient(135deg, #0984e3 0%, #74b9ff 100%);
    }
}

/* Print styles */
@media print {
    .family-search-container,
    .analytics-controls,
    .chart-tabs {
        display: none;
    }
    
    .family-analytics-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .chart-panel.active {
        page-break-inside: avoid;
    }
}