/* ── Route-finder page: unlock scrolling ─────────────────────────────────────
   main.css locks body + .app + .app-main to overflow:hidden for the main
   explorer's pan-zoom canvas. We need to undo that on this page.           */

/* Allow the whole page to scroll */
body {
    overflow-y: auto !important;
    height: auto !important;
}

.app {
    height: auto !important;
    min-height: 100vh;
    overflow: visible !important;
}

/* The main content area must scroll, not clip */
.app-main,
.app-main.full-width {
    overflow-y: auto !important;
    position: static !important;
    background-color: #f5f5f5 !important;
    flex: none !important;
}

/* ── Route Finder Specific Styles ────────────────────────────────────────── */
.route-finder-bar {
    background-color: #f8f9fa;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #ddd;
    z-index: 5;
}

.route-finder-container {
    max-width: 600px;
    margin: 0 auto;
}

.person-selector {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.person-selector h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.05rem;
    text-align: center;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.4rem;
}

.person-selection-group {
    margin-bottom: 0.75rem;
    padding: 0.625rem 0.75rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.person-selection-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #34495e;
    font-size: 0.85rem;
}

/* Search form inside each group */
.person-selection-group .search-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.person-selection-group .search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
}

.person-selection-group .search-field {
    position: relative;
    flex: 1;
    min-width: 120px;
}

.person-selection-group .search-field input {
    width: 100%;
    padding: 0.45rem 0.625rem;
    border: 1.5px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.person-selection-group .search-field input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.12);
}

.person-selection-group .search-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.person-selection-group .search-btn,
.person-selection-group .clear-btn {
    padding: 0.45rem 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.person-selection-group .search-btn {
    background: #3498db;
    color: white;
}

.person-selection-group .search-btn:hover {
    background: #2980b9;
}

.person-selection-group .clear-btn {
    background: #ecf0f1;
    color: #2c3e50;
    border: 1px solid #bdc3c7;
}

.person-selection-group .clear-btn:hover {
    background: #d5dbdb;
}

/* Location suggestions */
.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.location-suggestion-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.2s ease;
    color: #333;
    font-size: 0.9rem;
}

.location-suggestion-item:hover {
    background-color: #f8f9fa;
}

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

.selected-person-display {
    margin-top: 0.5rem;
    padding: 0.5rem 0.625rem;
    background-color: #ffffff;
    border-radius: 6px;
    border: 1.5px solid #e9ecef;
    min-height: 44px;
    display: flex;
    align-items: center;
    transition: border-color 0.2s;
}

.selected-person-display:has(.selected-person-card) {
    border-color: #3498db;
    background-color: #f8f9fa;
}

.selected-person-display .no-selection {
    color: #6c757d;
    font-style: italic;
    font-size: 0.95rem;
    text-align: center;
    width: 100%;
}

.selected-person-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 0.5rem;
}

.selected-person-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #3498db;
    flex-shrink: 0;
}

.selected-person-info {
    flex: 1;
}

.selected-person-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.selected-person-details {
    font-size: 0.85rem;
    color: #6c757d;
}

.remove-selection-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.remove-selection-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.route-actions {
    display: flex;
    gap: 0.625rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e9ecef;
}

.find-route-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 7px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.find-route-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.find-route-btn:hover:not(:disabled)::before {
    left: 100%;
}

.find-route-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.find-route-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.find-route-btn:disabled::before {
    display: none;
}

.route-info-container {
    flex: 0 0 320px;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 1rem;
}

.route-info {
    text-align: center;
}

.route-status {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.route-status span {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1.1rem;
}

.route-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.route-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.route-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
}

.stat-value {
    font-weight: 700;
    color: #3498db;
    font-size: 1.3rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.nav-btn {
    background: #7f8c8d;
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-block;
}

.nav-btn:hover {
    background: #6c757d;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Search results modal styles (reuse existing styles) */
.search-results-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.search-results-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-results-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.search-results-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.close-results-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.close-results-btn:hover {
    background: #c0392b;
}

/* Person cards in search results */
.person-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.person-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.person-card.male::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #007bff, #0056b3);
}

.person-card.female::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #e91e63, #c2185b);
}

.person-card.unknown::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6c757d, #495057);
}

.person-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #e9ecef;
}

.person-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.person-info {
    flex: 1;
}

.person-header h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.person-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.detail-label {
    font-weight: 600;
    color: #6c757d;
}

.detail-value {
    color: #2c3e50;
}

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

.add-to-chart-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-to-chart-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

/* Route path highlighting styles - updated for family chart */
.route-path-highlight,
.route-path-highlight .card,
.route-path-highlight .card-inner,
.route-path-highlight rect {
    outline: 4px solid #f39c12 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.6) !important;
    animation: routeHighlight 2s ease-in-out infinite !important;
}

.route-path-main,
.route-path-main .card,
.route-path-main .card-inner,
.route-path-main rect {
    outline: 4px solid #e74c3c !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 25px rgba(231, 76, 60, 0.8) !important;
    animation: routeMainHighlight 2s ease-in-out infinite !important;
}

/* Enhanced animations for route highlighting */
@keyframes routeHighlight {

    0%,
    100% {
        outline-color: #f39c12;
        box-shadow: 0 0 20px rgba(243, 156, 18, 0.6);
    }

    50% {
        outline-color: #e67e22;
        box-shadow: 0 0 30px rgba(243, 156, 18, 0.9);
    }
}

@keyframes routeMainHighlight {

    0%,
    100% {
        outline-color: #e74c3c;
        box-shadow: 0 0 25px rgba(231, 76, 60, 0.8);
    }

    50% {
        outline-color: #c0392b;
        box-shadow: 0 0 35px rgba(231, 76, 60, 1);
    }
}

/* Additional styles for SVG elements in the family chart */
.route-path-highlight svg,
.route-path-main svg {
    filter: drop-shadow(0 0 10px rgba(243, 156, 18, 0.7)) !important;
}

.route-path-main svg {
    filter: drop-shadow(0 0 15px rgba(231, 76, 60, 0.8)) !important;
}

/* Animation for route highlighting */
@keyframes routeHighlight {
    0% {
        outline-color: transparent;
    }

    50% {
        outline-color: #f39c12;
    }

    100% {
        outline-color: #f39c12;
    }
}

.route-path-highlight {
    animation: routeHighlight 1s ease-in-out;
}

/* Empty chart message styling */
.empty-chart-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    margin: 20px;
}

.empty-chart-content {
    text-align: center;
    color: white;
    padding: 2rem;
}

.empty-chart-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.empty-chart-content p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.9;
    line-height: 1.5;
}

.empty-chart-icon {
    font-size: 4rem;
    opacity: 0.8;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Chart mode controls */
/* ── Responsive design ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .route-finder-container {
        flex-direction: column;
        gap: 1rem;
    }

    .route-actions {
        flex-direction: column;
    }

    .find-route-btn {
        margin-bottom: 0.5rem;
    }

    .person-selection-group .search-form {
        flex-direction: column;
        gap: 0.5rem;
    }

    .search-results-container {
        width: 95%;
        max-height: 80vh;
    }

    .person-card {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .person-details {
        justify-content: center;
    }
}

/* ── Search summary pill (collapsed state) ──────────────────────────────────── */

.search-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    min-height: 48px;
}

.search-summary-names {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: #111827;
    min-width: 0;
}

.summary-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.summary-arrow {
    color: #6b7280;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.search-summary-edit {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    background: transparent;
    color: #3b6fd4;
    border: 1px solid #3b6fd4;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
    transition: background 0.15s, color 0.15s;
}

.search-summary-edit:hover {
    background: #3b6fd4;
    color: #ffffff;
}

.search-summary-edit svg {
    flex-shrink: 0;
}

/* ── Path card list (Phase 2) ─────────────────────────────────────────────── */

/* Wrapper for the whole result section */
.path-result {
    max-width: 480px;
    margin: 1.5rem auto 2rem;
    padding: 0 1rem;
}

/* Summary bar */
.path-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.6rem 1rem;
    background: #f0f4ff;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #444;
}

#path-summary-text {
    font-weight: 600;
}

.search-again-btn {
    flex-shrink: 0;
    background: transparent;
    color: #3b6fd4;
    border: 1px solid #3b6fd4;
    border-radius: 6px;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin: 0;
}

.search-again-btn:hover {
    background: #3b6fd4;
    color: #fff;
}

/* Card list container */
.path-cards {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Individual person card */
.path-person-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    background: #ffffff;
    border-radius: 8px;
    padding: 0.875rem 1rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #9ca3af; /* default: unknown */
    position: relative;
}

.path-person-card.gender-male {
    border-left-color: #3b82f6;
}

.path-person-card.gender-female {
    border-left-color: #ec4899;
}

/* Highlight start/end nodes */
.path-person-card.path-endpoint {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.path-person-card.path-start {
    border-left-color: #22c55e;
}

.path-person-card.path-end {
    border-left-color: #f59e0b;
}

/* Avatar circle with initials */
.path-avatar {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.path-person-card.gender-male .path-avatar {
    background: #dbeafe;
    color: #1d4ed8;
}

.path-person-card.gender-female .path-avatar {
    background: #fce7f3;
    color: #be185d;
}

/* Name + meta */
.path-person-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.path-person-name {
    font-size: 0.975rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.path-person-meta {
    font-size: 0.78rem;
    color: #6b7280;
}

/* Connector between cards */
.path-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.1rem 0;
    margin: 0 auto;
    width: 100%;
    max-width: 200px;
}

.path-connector-line {
    width: 2px;
    height: 14px;
    background: #d1d5db;
}

.path-connector-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.6rem;
    background: #f3f4f6;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    white-space: nowrap;
}

/* Selected person chip — initials instead of avatar img */
.selected-person-initials {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.selected-person-initials.gender-male {
    background: #dbeafe;
    color: #1d4ed8;
}

.selected-person-initials.gender-female {
    background: #fce7f3;
    color: #be185d;
}

/* Override main.css absolute positioning — these are in-flow on this page */
.data-source-indicator {
    position: static !important;
    background: none !important;
    color: #6b7280 !important;
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.95rem;
    border-radius: 0;
    z-index: auto;
}

.loading-indicator {
    position: static !important;
    transform: none !important;
    background: none !important;
    color: #6b7280 !important;
    text-align: center;
    padding: 1rem;
    font-size: 0.95rem;
}

/* Responsive path cards */
@media (max-width: 480px) {
    .path-result {
        margin: 1rem auto;
        padding: 0 0.5rem;
    }

    .path-summary-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .path-person-card {
        padding: 0.75rem;
    }

    .path-person-name {
        font-size: 0.9rem;
    }
}