/* ============================================================
   Family Heritage — Phase 7 & 8 Styles
   Map views, location tagging, export & import
   ============================================================ */

/* ----- Map Page Layout ----- */
.map-page {
    height: calc(100vh - var(--nav-height, 60px));
    display: flex;
    flex-direction: column;
}

.map-container {
    flex: 1;
    position: relative;
}

.map-container .leaflet-container {
    height: 100%;
    width: 100%;
}

/* ----- Map Filter Panel ----- */
.map-filter-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: var(--bg-card, #fff);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-width: 280px;
    max-height: 80vh;
    overflow-y: auto;
}

.map-filter-toggle {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--bg-card, #fff);
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary, #5B4A3F);
}

.map-filter-toggle:hover {
    background: var(--bg, #FAF8F5);
}

.map-filter-panel.collapsed {
    display: none;
}

.map-filter-section {
    margin-bottom: 1rem;
}

.map-filter-section:last-child {
    margin-bottom: 0;
}

.map-filter-title {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-light, #666);
    margin-bottom: 0.5rem;
    letter-spacing: 0.03em;
}

.map-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.85rem;
    cursor: pointer;
}

.map-filter-checkbox input {
    accent-color: var(--primary, #5B4A3F);
}

.map-filter-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light, #666);
    font-size: 1.2rem;
    padding: 0.2rem;
    line-height: 1;
}

.map-filter-person-search {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.map-filter-person-search:focus {
    outline: none;
    border-color: var(--border-focus, #C19A6B);
}

.map-filter-person-results {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    margin-top: 0.25rem;
    display: none;
}

.map-filter-person-results.show {
    display: block;
}

.map-filter-person-item {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border, #E5DDD5);
}

.map-filter-person-item:last-child {
    border-bottom: none;
}

.map-filter-person-item:hover {
    background: var(--bg, #FAF8F5);
}

.map-filter-person-item.selected {
    background: rgba(91, 74, 63, 0.08);
    font-weight: 600;
}

/* ----- Map Popup ----- */
.map-popup-content {
    min-width: 200px;
}

.map-popup-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--primary, #5B4A3F);
}

.map-popup-type {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    background: var(--bg, #FAF8F5);
    font-weight: 600;
    margin-bottom: 0.35rem;
    text-transform: capitalize;
}

.map-popup-person {
    font-size: 0.85rem;
    color: var(--primary-light, #8B7355);
    margin-bottom: 0.25rem;
}

.map-popup-person a {
    color: var(--primary-light, #8B7355);
    text-decoration: underline;
}

.map-popup-notes {
    font-size: 0.8rem;
    color: var(--text-light, #666);
    margin-bottom: 0.35rem;
}

.map-popup-photo {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm, 4px);
    margin-bottom: 0.35rem;
}

.map-popup-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.map-popup-actions a {
    font-size: 0.8rem;
    color: var(--primary, #5B4A3F);
    text-decoration: none;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    transition: all var(--transition, 0.2s);
}

.map-popup-actions a:hover {
    background: var(--bg, #FAF8F5);
    border-color: var(--accent, #C19A6B);
}

/* ----- Map Add Location Button ----- */
.map-add-btn {
    position: absolute;
    bottom: 2rem;
    right: 1rem;
    z-index: 1000;
    background: var(--primary, #5B4A3F);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 0.7rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--transition, 0.2s);
}

.map-add-btn:hover {
    background: var(--primary-dark, #3E3028);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* ----- Map Cluster ----- */
.map-cluster {
    background: var(--primary, #5B4A3F);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.6);
}

/* ----- Timeline Map ----- */
.map-timeline {
    padding: 1rem 1.5rem;
    background: var(--bg-card, #fff);
    border-top: 1px solid var(--border, #E5DDD5);
}

.map-timeline-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.map-timeline-year {
    font-family: Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary, #5B4A3F);
    min-width: 60px;
}

.map-timeline-slider {
    flex: 1;
}

.map-timeline-slider input[type="range"] {
    width: 100%;
    accent-color: var(--accent, #C19A6B);
    height: 6px;
}

.map-timeline-speed {
    font-size: 0.8rem;
    color: var(--text-light, #666);
}

.map-timeline-play-btn {
    background: var(--primary, #5B4A3F);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition, 0.2s);
}

.map-timeline-play-btn:hover {
    background: var(--primary-dark, #3E3028);
}

.map-timeline-speed-btns {
    display: flex;
    gap: 0.25rem;
}

.map-timeline-speed-btn {
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-light, #666);
    transition: all var(--transition, 0.2s);
}

.map-timeline-speed-btn.active {
    background: var(--primary, #5B4A3F);
    color: #fff;
    border-color: var(--primary, #5B4A3F);
}

.map-timeline-speed-btn:hover {
    border-color: var(--accent, #C19A6B);
}

/* ----- Person Places (Mini Map) ----- */
.person-map {
    height: 250px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border, #E5DDD5);
    margin-bottom: 1rem;
}

.person-locations-list {
    list-style: none;
    padding: 0;
}

.person-location-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border, #E5DDD5);
}

.person-location-item:last-child {
    border-bottom: none;
}

.person-location-type-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.person-location-info {
    flex: 1;
    min-width: 0;
}

.person-location-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text, #2C2C2C);
}

.person-location-meta {
    font-size: 0.8rem;
    color: var(--text-light, #666);
}

/* ----- Location Add/Edit Modal ----- */
.location-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.location-modal {
    background: var(--bg-card, #fff);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}

.location-modal h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.location-modal .form-group {
    margin-bottom: 0.75rem;
}

.location-modal .form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--text, #2C2C2C);
}

.location-modal .form-input,
.location-modal .form-select,
.location-modal .form-textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    font-size: 0.9rem;
    font-family: inherit;
}

.location-modal .form-input:focus,
.location-modal .form-select:focus,
.location-modal .form-textarea:focus {
    outline: none;
    border-color: var(--border-focus, #C19A6B);
}

.location-modal .form-textarea {
    min-height: 60px;
    resize: vertical;
}

.location-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.location-gps-btn {
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--primary, #5B4A3F);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all var(--transition, 0.2s);
}

.location-gps-btn:hover {
    border-color: var(--accent, #C19A6B);
    background: var(--bg-card, #fff);
}

.location-coords-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.location-coords-row .form-group {
    flex: 1;
}

/* ============================================================
   PHASE 8: EXPORT & IMPORT STYLES
   ============================================================ */

/* ----- Export Page ----- */
.export-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.export-section {
    margin-bottom: 2.5rem;
}

.export-section h2 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border, #E5DDD5);
    font-family: Georgia, serif;
}

.export-section-desc {
    font-size: 0.9rem;
    color: var(--text-light, #666);
    margin-bottom: 1rem;
}

/* ----- Export Options Grid ----- */
.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.export-option {
    padding: 1rem;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    background: var(--bg-card, #fff);
}

.export-option:hover {
    border-color: var(--accent, #C19A6B);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.export-option.selected {
    border-color: var(--primary, #5B4A3F);
    background: rgba(91, 74, 63, 0.05);
    box-shadow: 0 0 0 1px var(--primary, #5B4A3F);
}

.export-option-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.export-option-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text, #2C2C2C);
}

.export-option-desc {
    font-size: 0.75rem;
    color: var(--text-light, #666);
    margin-top: 0.25rem;
}

/* ----- Export Config Form ----- */
.export-config {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.export-config-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.export-config-row .form-group {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
}

.export-config-row .form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    color: var(--text, #2C2C2C);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.export-config .form-input,
.export-config .form-select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    font-size: 0.9rem;
}

.export-config .form-input:focus,
.export-config .form-select:focus {
    outline: none;
    border-color: var(--border-focus, #C19A6B);
}

.export-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* ----- Export Preview ----- */
.export-preview {
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 8px;
    padding: 1rem;
    background: var(--bg, #FAF8F5);
    margin-bottom: 1rem;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.export-preview-grid {
    display: grid;
    gap: 4px;
}

.export-preview-page {
    background: white;
    border: 1px solid var(--border, #E5DDD5);
    aspect-ratio: 0.707;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted, #999);
    position: relative;
}

.export-preview-page-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.6rem;
    color: var(--text-muted, #999);
}

/* ----- Data Export Cards ----- */
.export-data-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.export-data-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s;
}

.export-data-card:hover {
    box-shadow: var(--shadow-hover);
}

.export-data-card h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.export-data-card p {
    font-size: 0.85rem;
    color: var(--text-light, #666);
    margin-bottom: 0.75rem;
}

.export-data-card .btn {
    width: 100%;
}

/* ----- Import Section ----- */
.import-section {
    max-width: 700px;
    margin: 0 auto;
}

.import-dropzone {
    border: 2px dashed var(--border, #E5DDD5);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg, #FAF8F5);
}

.import-dropzone:hover,
.import-dropzone.dragover {
    border-color: var(--accent, #C19A6B);
    background: rgba(193, 154, 107, 0.05);
}

.import-dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted, #999);
}

.import-dropzone-text {
    font-size: 0.9rem;
    color: var(--text-light, #666);
}

.import-dropzone-text strong {
    color: var(--primary, #5B4A3F);
}

.import-preview {
    margin-top: 1.5rem;
}

.import-preview h4 {
    margin-bottom: 0.75rem;
}

.import-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.import-stat {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: var(--radius-sm, 4px);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.import-stat strong {
    color: var(--primary, #5B4A3F);
}

.import-person-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 8px;
}

.import-person {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border, #E5DDD5);
    font-size: 0.9rem;
}

.import-person:last-child {
    border-bottom: none;
}

.import-person.duplicate {
    background: rgba(193, 154, 107, 0.08);
}

.import-person-name {
    font-weight: 600;
    color: var(--text, #2C2C2C);
}

.import-person-dates {
    font-size: 0.8rem;
    color: var(--text-light, #666);
    margin-left: 0.5rem;
}

.import-duplicate-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: var(--accent-light, #D4B896);
    color: var(--primary, #5B4A3F);
    font-weight: 600;
    white-space: nowrap;
}

.import-strategy {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.import-strategy label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.import-strategy-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.import-strategy-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.import-strategy-option input {
    accent-color: var(--primary, #5B4A3F);
}

.import-progress {
    margin-top: 1rem;
}

.import-progress-text {
    font-size: 0.85rem;
    color: var(--text-light, #666);
    margin-bottom: 0.35rem;
}

.import-progress-bar {
    height: 8px;
    background: var(--border, #E5DDD5);
    border-radius: 4px;
    overflow: hidden;
}

.import-progress-fill {
    height: 100%;
    background: var(--success, #4A7C59);
    transition: width 0.3s;
    border-radius: 4px;
}

.import-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .map-filter-panel {
        max-width: 100%;
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        border-radius: 12px 12px 0 0;
        max-height: 50vh;
    }

    .map-filter-toggle {
        top: auto;
        bottom: 1rem;
        left: 1rem;
    }

    .map-add-btn {
        bottom: 1rem;
        right: 1rem;
    }

    .export-options {
        grid-template-columns: 1fr;
    }

    .export-config-row {
        flex-direction: column;
    }

    .map-timeline-controls {
        flex-wrap: wrap;
    }

    .location-coords-row {
        flex-direction: column;
    }
}
