/* css/modals.css - Estili per Modali, Pannelli e Popover */

/* Overlay generico per le modali */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

/* Overlay for popover (no flex centering) */
.popover-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: transparent;
}

.popover-overlay-mobile {
    background: rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background-color 0.22s ease, opacity 0.22s ease;
    opacity: 0;
}

.popover-overlay-mobile.is-visible {
    opacity: 1;
}

/* Premium Sidebar (Details Panel) */
#details-panel {
    position: absolute;
    top: 15px; /* Margin within main */
    bottom: 15px; /* Margin within main */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(25px);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Header fixed, content scrolls */
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Desktop Default */
    right: 20px;
    width: 380px;
    transform: none;
}

#details-panel.hidden {
    transform: translateX(110%);
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 768px) {
    #details-panel {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        width: 94%;
        max-width: 480px;
    }

    #details-panel.hidden {
        transform: translate(-50%, 100px);
        opacity: 0;
    }
}

#panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-top: 40px; /* Space for close button */
    
    /* Hide scrollbar while keeping scroll functionality */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

#panel-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

#close-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    z-index: 10;
    transition: all 0.2s;
}

#close-panel:hover {
    background: #f1f5f9;
    color: #0f172a;
    transform: scale(1.1);
}

/* Card principale per le modali */
.modal-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh; /* Increased from 80vh for better mobile use */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    font-family: 'Inter', sans-serif;
    overflow: hidden; /* Header/Footer stay fixed, content scrolls */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #1e293b;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #64748b;
}

.relationship-path-modal {
    width: min(1180px, 96vw);
    max-width: min(1180px, 96vw);
    max-height: min(88vh, 860px);
    padding: 0;
    border-radius: 24px;
    overflow: hidden;
}

.relationship-path-modal__header {
    padding: 22px 24px 18px;
    margin-bottom: 0;
    border-bottom: 1px solid #e2e8f0;
    background:
        radial-gradient(circle at top left, rgba(248, 113, 113, 0.16), transparent 36%),
        radial-gradient(circle at top right, rgba(251, 191, 36, 0.12), transparent 34%),
        linear-gradient(180deg, #fffdfb 0%, #ffffff 100%);
}

.relationship-path-modal__summary {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.45;
}

.relationship-path-modal__body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 24px 24px;
    overflow: auto;
}

.relationship-path-modal__meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.relationship-path-modal__actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.relationship-path-modal__badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
}

.relationship-path-modal__badge--blood {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
}

.relationship-path-modal__badge--affinal {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #b45309;
}

.relationship-path-modal__count {
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
}

.relationship-path-modal__print-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #cbd5e1;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #0f172a;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.relationship-path-modal__print-btn:hover {
    transform: translateY(-1px);
    border-color: #94a3b8;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.relationship-path-modal__print-btn:disabled {
    opacity: 0.68;
    cursor: wait;
    transform: none;
    box-shadow: none;
}

.relationship-path-modal__print-btn .material-symbols-outlined {
    font-size: 1.1rem;
}

.relationship-path-viewport {
    overflow: auto;
    padding: 8px 24px 16px;
    min-height: min(62vh, 640px);
}

.relationship-path-compact {
    --relationship-path-card-width: 228px;
    --relationship-path-card-min-height: 118px;
    --relationship-path-row-gap: 64px;
    --relationship-path-column-gap: 60px;
    position: relative;
    width: max-content;
    min-width: max-content;
    padding: 22px 28px 28px;
    margin: 0 auto;
}

.relationship-path-compact__grid {
    position: relative;
    display: grid;
    grid-auto-flow: row;
    gap: var(--relationship-path-row-gap) var(--relationship-path-column-gap);
    align-items: stretch;
    min-width: max-content;
    z-index: 2;
}

.relationship-path-compact__node {
    position: relative;
    z-index: 2;
    width: var(--relationship-path-card-width);
    justify-self: center;
}

.relationship-path-compact__svg,
.relationship-path-compact__labels {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.relationship-path-compact__svg {
    z-index: 1;
    overflow: visible;
}

.relationship-path-compact__labels {
    z-index: 3;
}

.relationship-path-compact__edge {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: square;
    stroke-linejoin: miter;
}

.relationship-path-compact__edge--blood {
    stroke: #fb7185;
}

.relationship-path-compact__edge--affinal {
    stroke: #f59e0b;
}

.relationship-path-compact__edge-label {
    position: absolute;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.relationship-path-compact__edge-label--blood {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.relationship-path-compact__edge-label--affinal {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.relationship-path-card {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    min-height: var(--relationship-path-card-min-height);
    min-width: 0;
    padding: 10px 13px;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

.relationship-path-card--principal {
    border-color: #cbd5e1;
    box-shadow: 0 14px 34px rgba(148, 163, 184, 0.15);
}

.relationship-path-card--target-blood {
    border-color: #fca5a5;
    box-shadow: 0 16px 36px rgba(248, 113, 113, 0.16);
}

.relationship-path-card--target-affinal {
    border-color: #fcd34d;
    box-shadow: 0 16px 36px rgba(245, 158, 11, 0.16);
}

.relationship-path-card__header {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.relationship-path-card__meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 1 auto;
}

.relationship-path-card__role {
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.relationship-path-card__name {
    margin: 0;
    color: #0f172a;
    font-size: 0.98rem;
    line-height: 1.25;
}

.relationship-path-card__dates,
.relationship-path-card__id {
    margin: 0;
    color: #64748b;
    font-size: 0.86rem;
}

.relationship-path-card__id {
    margin-top: 2px;
    padding-top: 4px;
    border-top: 1px solid #e2e8f0;
    word-break: break-word;
}

.relationship-path-loading,
.relationship-path-empty {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #64748b;
    text-align: center;
}

.relationship-path-loading .material-symbols-outlined,
.relationship-path-empty .material-symbols-outlined {
    font-size: 2rem;
    color: #c2410c;
}

@media (max-width: 900px) {
    .relationship-path-modal {
        width: min(96vw, 680px);
        max-width: min(96vw, 680px);
    }

    .relationship-path-modal__body {
        padding: 18px 16px 20px;
    }

    .relationship-path-compact {
        --relationship-path-card-width: 204px;
        --relationship-path-card-min-height: 114px;
        --relationship-path-row-gap: 74px;
        --relationship-path-column-gap: 84px;
        padding: 16px 18px 20px;
    }

    .relationship-path-compact__edge-label {
        font-size: 0.75rem;
    }
}

/* Gestione Backup (Version History) */
.vh-create-box {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vh-create-info p {
    margin: 0;
}

.vh-create-title {
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 4px !important;
}

.vh-create-subtitle {
    font-size: 0.85rem;
    color: #64748b;
}

.vh-list {
    overflow-y: auto;
    flex: 1;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.vh-list::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.vh-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid #e2e8f0;
    transition: background 0.15s;
    background: #fff;
}

.vh-item-row:nth-child(even) {
    background: #f8fafc;
}

.vh-item-row:hover {
    background: #f1f5f9;
}

.vh-item-info {
    flex: 1;
    min-width: 0;
}

.vh-item-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
}

.vh-item-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.vh-item-actions {
    display: flex;
    gap: 8px;
}

.vh-btn {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    cursor: pointer;
    color: #475569;
    display: flex;
    transition: all 0.2s;
}

.vh-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.vh-btn-delete {
    color: #94a3b8;
}

.vh-btn-delete:hover {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}

.vh-btn-restore {
    border: 1px solid #dc2626;
    background: #fef2f2;
    color: #dc2626;
}

.vh-btn-restore:hover {
    background: #fee2e2;
}

/* Popover (Contributi/Notifiche - Facebook-style Nuvoletta) */
.popover-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.1);
    position: absolute;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    border: 1px solid #e2e8f0;
    overflow: visible; /* To see the arrow */
    animation: popoverFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 70vh;
    max-width: 400px;
    width: 90%;
    box-sizing: border-box;
    border-radius: 24px;
}

.popover-card-mobile {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: min(78dvh, 720px) !important;
    border-radius: 24px 24px 0 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.22);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1), opacity 0.18s ease;
    will-change: transform, opacity;
    contain: layout paint;
    overflow: hidden;
}

.popover-card-mobile.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.popover-card-mobile.is-dragging,
.modal-card-mobile-sheet.is-dragging {
    transition: none !important;
}

.popover-card-mobile .popover-arrow {
    display: none;
}

.popover-sheet-handle,
.modal-sheet-handle {
    display: none;
}

.popover-card-mobile .modal-header {
    padding: max(14px, env(safe-area-inset-top)) 18px 12px;
    margin-bottom: 0;
}

.popover-card-mobile .popover-sheet-handle,
.modal-card-mobile-sheet .modal-sheet-handle {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.55);
    margin: 10px auto 8px;
    flex-shrink: 0;
}

.popover-card-mobile .popover-tabs {
    margin: 0 16px 12px;
    padding-bottom: 10px;
}

.popover-card-mobile .vh-list {
    padding: 0 14px calc(14px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.popover-card-mobile .vh-list::-webkit-scrollbar {
    display: none;
}

.popover-card > .modal-header {
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.modal-overlay-mobile-sheet {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: rgba(15, 23, 42, 0.6);
}

.modal-card-mobile-sheet {
    width: 100%;
    max-width: none;
    max-height: min(82dvh, 760px);
    margin: 0;
    padding: 0;
    border-radius: 24px 24px 0 0;
    transform: translateY(0);
    overflow: hidden;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.22);
}

.modal-card-mobile-sheet .modal-header {
    padding: 6px 18px 12px;
    margin-bottom: 0;
}

.modal-card-mobile-sheet .vh-list {
    padding: 0 14px calc(14px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-card-mobile-sheet .vh-list::-webkit-scrollbar {
    display: none;
}

.modal-skeleton-list {
    display: grid;
    gap: 10px;
}

.modal-skeleton-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.modal-skeleton-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-top: 8px;
    background: #e2e8f0;
    flex: 0 0 auto;
}

.modal-skeleton-content {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 8px;
}

.modal-skeleton-line {
    height: 11px;
    border-radius: 999px;
    background: #e2e8f0;
}

.modal-skeleton-line.w-35 { width: 35%; }
.modal-skeleton-line.w-55 { width: 55%; }
.modal-skeleton-line.w-80 { width: 80%; }

.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
    animation: modalShimmer 1.1s ease-in-out infinite;
}

@keyframes modalShimmer {
    100% {
        transform: translateX(100%);
    }
}

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

.popover-arrow {
    position: absolute;
    top: -8px;
    right: 14px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
    filter: drop-shadow(0 -1px 0 rgba(0,0,0,0.05));
    z-index: 1;
}

.popover-tabs {
    display: flex;
    gap: 8px;
    margin: 4px 16px 16px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.popover-tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.popover-tab-btn.active {
    background: #4f46e5;
    color: white;
}

/* Log Modifiche (Admin Logs) */
.log-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
    background: #fff;
}

.log-item-row:nth-child(even) {
    background: #f8fafc;
}

.log-profile-link {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.log-profile-link:hover {
    text-decoration: underline;
    color: #4338ca;
}

/* Template stili per index.html */
.fm-info-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.fm-info-meta {
    font-size: 0.85rem;
    color: #64748b;
}

.fm-info-extra {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 4px;
}

.inline-edit-area {
    margin-top: 10px;
}

.inline-edit-textarea {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid transparent;
    border-radius: 0;
    font-family: inherit;
    font-size: 0.9rem;
    color: #334155;
    box-sizing: border-box;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.inline-edit-textarea:focus {
    border-bottom-color: var(--primary-color, #3b82f6);
    background: rgba(59, 130, 246, 0.04);
}

.inline-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    justify-content: flex-end;
}

.inline-btn-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}

.inline-btn-save {
    background: rgba(22, 163, 74, 0.1);
    color: #16a34a;
}

.inline-btn-save:hover {
    background: rgba(22, 163, 74, 0.2);
}

.inline-btn-cancel {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.inline-btn-cancel:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Stemma Edit Controls */
.stemma-edit-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    display: flex;
}

.stemma-edit-controls {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
}

/* QR Code */
.qr-container {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    padding: 10px;
    background: white;
}

/* Contribuzioni */
.contrib-session-card {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.contrib-session-card:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.contrib-session-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contrib-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.contrib-author-name {
    color: #0f172a;
    font-size: 1rem;
    font-weight: 700;
}

/* Row-based Contribution Item (Admin List) */
.contrib-item-row, .contrib-item-card {
    padding: 1rem 1.5rem 0.5rem;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
    background: white;
}

.contrib-item-row:hover, .contrib-item-card:hover {
    background: #f1f5f9;
}

.contrib-item-card.unread {
    background: #eff6ff !important;
    border-color: #bfdbfe !important;
}

.contrib-item-card.read {
    opacity: 0.75;
}

.contrib-author {
    color: #1e293b;
    font-weight: 700;
}

.contrib-date {
    font-size: 0.75rem;
    color: #1e293b;
    margin-left: 8px;
}

.verified-badge {
    font-size: 16px !important;
    color: #1d9bf0;
    vertical-align: middle;
    margin-left: 4px;
    cursor: pointer;
    user-select: none;
}

.contrib-profile-info {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 4px;
}

.contrib-msg {
    font-size: 0.9rem;
    color: #334155;
    margin-bottom: 6px;
    white-space: pre-wrap;
}

.contrib-photo-link {
    font-size: 0.8rem;
    color: #4f46e5;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    margin-right: 12px;
}

.contrib-photo-link span {
    font-size: 16px;
}

/* User Notifications */
.notification-item-row {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.2s;
    cursor: pointer;
}

.notification-item-row:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.notification-sender {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
}

.notification-message {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.4;
}

.contrib-unread-dot, .notification-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4f46e5;
    flex-shrink: 0;
}

/* Lightbox Sidebar Tags */
.lb-tags-container {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lb-tags-header {
    margin: 0 0 16px 0;
    color: #64748b;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.lb-tag-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.2s;
}

.lb-tag-row:hover {
    background: #f8fafc;
}

.lb-tag-name-text {
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Stemmi Edit Items (Redesign) */
.stemma-edit-value {
    display: flex !important;
    align-items: center !important;
    gap: 8px;
    height: auto !important;
    line-height: normal !important;
    justify-content: flex-end !important;
}

.stemma-add-tile {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: 1.5px dashed #cbd5e1;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    font-size: 0;
}

.stemma-add-tile .material-symbols-outlined {
    font-size: 20px;
}

.stemma-add-tile:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #eef2ff;
}

.stemma-edit-item {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
}

.stemma-edit-item img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.stemma-remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px !important;
    border: 1.5px solid white;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.15s;
    padding: 0;
    line-height: 1;
}

.stemma-remove-btn:hover {
    transform: scale(1.15);
    background: #dc2626;
}

/* Stemmi Selector Modal */
.stemmi-selector-modal {
    width: 100%;
    max-width: 500px;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.stemmi-selector-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.stemmi-selector-modal .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

.stemmi-selector-modal .modal-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    font-size: 20px;
    transition: all 0.15s;
}

.stemmi-selector-modal .modal-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.search-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
}

.search-bar-container .relative {
    position: relative;
    flex: 1;
    min-width: 0;
}

.modal-search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.modal-search-input:focus {
    border-color: #4f46e5;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 18px;
    pointer-events: none;
}

.btn-stemma-action {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s;
    padding: 0;
}

.btn-stemma-action:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #eef2ff;
}

.btn-stemma-action .material-symbols-outlined {
    font-size: 18px;
}

.stemmi-selection-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.stemma-selection-item {
    aspect-ratio: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
}

.stemma-selection-item:hover {
    border-color: #4f46e5;
    background: #eef2ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.stemma-selection-item img {
    max-width: 100%;
    max-height: 50px;
    object-fit: contain;
    margin-bottom: 4px;
}

.stemma-selection-name {
    font-size: 0.75rem;
    color: #64748b;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Add Person Modal (Lightbox variation) */
.add-person-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-person-card {
    background: white;
    border-radius: 20px;
    padding: 0;
    max-width: 440px;
    width: 95%; /* More space on mobile */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 70px rgba(0,0,0,0.4);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
}

@media (max-width: 600px) {
    .add-person-card {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .ap-header {
        padding: 16px;
    }
    .ap-body {
        padding: 16px;
    }
}

.ap-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.ap-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ap-title {
    margin: 0;
    font-size: 1.35rem;
    color: #0f172a;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.ap-close-btn {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ap-tabs {
    display: flex;
    background: #f8fafc;
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
}

.ap-tab-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: transparent;
    color: #64748b;
}

.ap-tab-btn.active {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    color: #0f172a;
}

.ap-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto; /* Enable internal scrolling */
    flex: 1;
}

.ap-footer {
    padding: 16px 24px 24px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.ap-btn-save {
    padding: 10px 24px;
    border: none;
    background: #4f46e5;
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.ap-btn-cancel {
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
}

.ap-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ap-label {
    font-size: 0.85rem;
    color: #475569;
    font-weight: 600;
}

.ap-input, .ap-select {
    padding: 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    outline: none;
}

.vh-item {
    margin: 8px 16px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 16px;
    position: relative;
    transition: all 0.2s;
}

.vh-item:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}
/* Custom Autocomplete */
.custom-autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-top: 4px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
}

.stemma-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.stemma-suggestion-item:hover {
    background: #f1f5f9;
}

.stemma-suggestion-item img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
    background: #f8fafc;
}

.suggestion-info {
    display: flex;
    flex-direction: column;
}

.suggestion-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
}

.suggestion-filename {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Bio Editor Buttons */
.bio-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: flex-end;
}

/* Person Detail Panel (Sidebar) */
.panel-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 12px;
}

.panel-avatar-wrapper {
    margin-bottom: 8px;
    border-radius: 50%;
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 2px;
    color: #0f172a;
    line-height: 1.2;
}

.panel-id {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-bottom: 12px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.05em;
}

.panel-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.panel-action-buttons button {
    height: 38px;
    border-radius: 12px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
}

.panel-action-buttons button:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.panel-details, .panel-family {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-detail-label, .panel-family-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 2px;
}

.panel-detail-value, .panel-family-value {
    font-size: 0.85rem;
    color: #334155;
    font-weight: 500;
}

.panel-divider {
    border: none;
    border-top: 1px solid #f1f5f9;
    margin: 12px 0;
}

.privacy-blur {
    filter: blur(5px);
    user-select: none;
}

.footer-page-overlay {
    position: fixed;
    inset: 0;
    z-index: 14000;
    background: rgba(15, 23, 42, 0.46);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 1;
    transition: opacity 0.18s ease;
}

.footer-page-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.footer-page-shell {
    width: min(1040px, 100%);
    height: min(88vh, 860px);
    border-radius: 24px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.footer-page-overlay.hidden .footer-page-shell {
    transform: translateY(18px);
}

.footer-page-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(248, 250, 252, 0.96);
    border-bottom: 1px solid #e2e8f0;
}

.footer-page-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: #0f172a;
    text-align: center;
}

.footer-page-close,
.footer-page-dismiss {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    color: #334155;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.footer-page-content {
    flex: 1;
    width: 100%;
    background: white;
    overflow: auto;
    overscroll-behavior: contain;
}

.footer-page-document {
    min-height: 100%;
    box-sizing: border-box;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    color: #1e293b;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    background: #f8fafc;
}

.footer-page-document .header {
    text-align: center;
    margin-bottom: 3rem;
}

.footer-page-document .logo {
    max-width: 240px;
    height: auto;
    margin-bottom: 1.5rem;
}

.footer-page-document h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 1rem;
    line-height: 1.3;
}

.footer-page-document h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #0284c7;
    margin: 2rem 0 1rem;
    border-left: 4px solid #0284c7;
    padding-left: 1rem;
}

.footer-page-document h2:first-of-type {
    margin-top: 0;
}

.footer-page-document h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
}

.footer-page-document p,
.footer-page-document ul {
    margin: 0 0 1.25rem;
    font-size: 1rem;
    color: #334155;
}

.footer-page-document ul {
    padding-left: 1.5rem;
}

.footer-page-document li {
    margin-bottom: 0.5rem;
}

.footer-page-document a {
    color: #0284c7;
    text-decoration: none;
    font-weight: 500;
}

.footer-page-document a:hover {
    text-decoration: underline;
}

.footer-page-document .info-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    margin-bottom: 2rem;
    text-align: left;
}

.footer-page-document .contact-box {
    background-color: #f1f5f9;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
    border-left: 4px solid #94a3b8;
}

.footer-page-document .footer-legal {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
    color: #64748b;
    text-align: left;
}

.footer-page-document .footer-legal h4 {
    font-size: 0.9rem;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-page-document .legal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.footer-page-loading,
.footer-page-error {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: #64748b;
    font-weight: 500;
}

.footer-page-error .material-symbols-outlined {
    font-size: 28px;
}

body.footer-page-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .footer-page-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .footer-page-shell {
        width: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 18px 18px 0 0;
    }

    .footer-page-toolbar {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .footer-page-document {
        padding: 24px 16px;
    }

    .footer-page-document .info-card {
        padding: 1.5rem;
    }

    .footer-page-document .legal-grid {
        grid-template-columns: 1fr;
    }

    #panel-content,
    .relationship-path-modal__body,
    .relationship-path-viewport,
    .stemmi-selection-grid,
    .ap-body,
    .custom-autocomplete-results,
    .footer-page-content {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    #panel-content::-webkit-scrollbar,
    .relationship-path-modal__body::-webkit-scrollbar,
    .relationship-path-viewport::-webkit-scrollbar,
    .stemmi-selection-grid::-webkit-scrollbar,
    .ap-body::-webkit-scrollbar,
    .custom-autocomplete-results::-webkit-scrollbar,
    .footer-page-content::-webkit-scrollbar {
        width: 0;
        height: 0;
        display: none;
    }
}
