/* Контейнер дерева */
#family-tree-container {
    width: 100%;
    height: calc(100vh - 80px);
    position: relative;
    background: url('/images/bg.jpg') center center / cover no-repeat;
    background-attachment: fixed;
}

/* Кнопки зума справа */
.zoom-buttons {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.zoom-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #333;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background: #4299e1;
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.4);
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-btn i {
    margin: 0;
    padding: 0;
}

/* SVG контейнер */
#family-tree-svg {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    background: 
        linear-gradient(90deg, rgba(200,200,200,0.1) 1px, transparent 1px),
        linear-gradient(rgba(200,200,200,0.1) 1px, transparent 1px);
    background-size: 50px 50px;
}

#family-tree-svg:active {
    cursor: grabbing;
}

#family-tree-svg svg {
    width: 100%;
    height: 100%;
}

/* Карточка персоны в SVG */
.person-card {
    cursor: pointer;
    transition: all 0.2s ease;
}

.person-card:hover {
    filter: drop-shadow(0 10px 18px rgba(15,23,42,0.22));
}

.person-card rect.card-bg {
    transition: all 0.2s ease;
}

.person-card:hover rect.card-bg {
    stroke: #555759;
    stroke-width: 2.5;
}

/* Кнопки в карточке SVG */
.card-button {
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.card-button text {
    font-weight: 600;
}

.person-card:hover .card-button {
    opacity: 1;
}

.card-button circle {
    transition: all 0.2s ease;
}

.card-button:hover circle {
    r: 17;
    filter: brightness(1.1);
}

/* Модальное окно */
.person-info-grid {
    display: grid;
    gap: 10px;
}

.info-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px;
}

.info-row strong {
    color: #666;
}

/* ============================================
   СТИЛИ МОДАЛЬНОГО ОКНА ПЕРСОНЫ - МИНИМАЛИЗМ
   ============================================ */

/* Основные контейнеры модального окна */
.person-modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    background: #ffffff;
}

.person-modal-header {
    background: #ffffff;
    color: #2d3748;
    padding: 1.75rem 2rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.modal-avatar-icon {
    width: 50px;
    height: 50px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #495057;
    transition: all 0.2s ease;
}

.person-modal-header .modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: #212529;
    letter-spacing: -0.02em;
}

.person-modal-header .text-muted {
    color: #6c757d !important;
    font-size: 0.875rem;
    font-weight: 400;
}

.person-modal-header .btn-close {
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.person-modal-header .btn-close:hover {
    opacity: 0.8;
}

.person-modal-body {
    padding: 2rem;
    background: #fafbfc;
}

.person-modal-footer {
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    padding: 1rem 1.5rem;
    gap: 0.75rem;
}

/* Фото персоны */
.person-photo-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid #e9ecef;
    height: 100%;
    transition: border-color 0.2s ease;
}

.person-photo-card:hover {
    border-color: #ced4da;
}

/* Список информации под фото */
.person-info-list {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid #f1f3f5;
}

.info-item {
    display: flex;
    flex-direction: column;
    padding: 0.625rem 0;
    border-bottom: 1px solid #f8f9fa;
}

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

.info-item .info-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.info-item .info-value {
    font-size: 0.9375rem;
    color: #212529;
    font-weight: 400;
}

.person-photo-wrapper {
    position: relative;
    width: 100%;
    /* aspect-ratio: 3/4; */
    border-radius: 8px;
    overflow: hidden;
    /* background: #f8f9fa; */
    cursor: pointer;
    transition: transform 0.2s ease;
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); */
}

.person-photo-wrapper:hover {
    transform: translateY(-2px);
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); */
}

.person-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-overlay {
    display: none;
}

/* Основная информация */
.person-details-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.info-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
    transition: border-color 0.2s ease;
}

.info-section:hover {
    border-color: #ced4da;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #343a40;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f3f5;
}

.section-title i {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Карточки информации */
.info-cards-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.info-cards-grid-compact {
    display: grid;
    gap: 0.625rem;
    grid-template-columns: 1fr;
}

.info-card {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.info-card:hover {
    background: #ffffff;
    border-color: #ced4da;
    transform: translateX(2px);
}

.info-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid #dee2e6;
    color: #6c757d;
}

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

.info-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.info-value {
    font-size: 0.9375rem;
    color: #212529;
    font-weight: 500;
    word-wrap: break-word;
}

/* Биография и заметки */
.biography-content,
.notes-content {
    color: #495057;
    line-height: 1.6;
    font-size: 0.9375rem;
}

.biography-content p,
.notes-content p {
    margin-bottom: 0.75rem;
}

.biography-content p:last-child,
.notes-content p:last-child {
    margin-bottom: 0;
}

/* Форматирование текста из Quill */
.biography-content strong {
    font-weight: 700;
}

.biography-content em {
    font-style: italic;
}

.biography-content u {
    text-decoration: underline;
}

.biography-content s {
    text-decoration: line-through;
}

.biography-content a {
    color: #007bff;
    text-decoration: none;
}

.biography-content a:hover {
    text-decoration: underline;
}

.biography-content ul,
.biography-content ol {
    margin: 0.5rem 0;
    padding-left: 2rem;
}

.biography-content li {
    margin-bottom: 0.25rem;
}

.biography-content blockquote {
    border-left: 4px solid #dee2e6;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #6c757d;
}

.biography-content h1,
.biography-content h2,
.biography-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.biography-content h1 {
    font-size: 1.5rem;
}

.biography-content h2 {
    font-size: 1.25rem;
}

.biography-content h3 {
    font-size: 1.1rem;
}

/* Родственники */
.relatives-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid #e9ecef;
    height: 100%;
    transition: all 0.2s ease;
}

.relatives-card:hover {
    border-color: #ced4da;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.relatives-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #343a40;
    margin-bottom: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f3f5;
}

.relatives-title i {
    color: #6c757d;
    font-size: 0.875rem;
}

.relatives-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.relative-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.relative-item:hover {
    background: #ffffff;
    border-color: #ced4da;
    transform: translateX(3px);
}

.relative-link {
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    display: flex;
    align-items: center;
    flex: 1;
    transition: color 0.2s ease;
    font-size: 0.9375rem;
}

.relative-link:hover {
    color: #212529;
}

.relative-link i {
    color: #adb5bd;
    font-size: 1.1rem;
}

/* Фото в списке родственников */
.relative-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e9ecef;
}

.relative-badge {
    font-size: 0.6875rem;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #e9ecef;
    color: #6c757d;
}

.relative-badge.married {
    background: #d1f4e0;
    color: #2d6a4f;
}

.relative-badge.divorced {
    background: #ffe5d9;
    color: #9d4521;
}

.relative-years {
    font-size: 0.8125rem;
    color: #6c757d;
    font-weight: 400;
}

/* Футер - кнопки управления */
.position-controls {
    display: flex;
    gap: 0.375rem;
}

.action-controls {
    display: flex;
    gap: 0.5rem;
}

.person-modal-footer .btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.person-modal-footer .btn-sm {
    padding: 0.375rem 0.75rem;
}

.person-modal-footer .btn-outline-secondary {
    border-color: #ced4da;
    color: #6c757d;
}

.person-modal-footer .btn-outline-secondary:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #495057;
}

.person-modal-footer .btn-primary {
    background: #495057;
    border-color: #495057;
    color: white;
}

.person-modal-footer .btn-primary:hover {
    background: #343a40;
    border-color: #343a40;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.person-modal-footer .btn-success {
    background: #52b788;
    border-color: #52b788;
    color: white;
}

.person-modal-footer .btn-success:hover {
    background: #40916c;
    border-color: #40916c;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(82, 183, 136, 0.3);
}

.person-modal-footer .btn-danger {
    background: #e76f51;
    border-color: #e76f51;
    color: white;
}

.person-modal-footer .btn-danger:hover {
    background: #d9614b;
    border-color: #d9614b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(231, 111, 81, 0.3);
}

/* Адаптивность для модального окна */
@media (max-width: 992px) {
    .person-modal-body {
        padding: 1.5rem;
    }
    
    .info-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .person-modal-footer {
        flex-wrap: wrap;
    }
    
    .position-controls,
    .action-controls {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .person-modal-header {
        padding: 1.25rem;
    }
    
    .modal-avatar-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
    
    .person-modal-header .modal-title {
        font-size: 1.25rem;
    }
    
    .relatives-card {
        margin-bottom: 0.75rem;
    }
}

/* Линии связей */
.connection-line {
    stroke: #333;
    stroke-width: 2;
    fill: none;
}

.connection-line.divorced {
    stroke-dasharray: 5, 5;
    stroke: #e91e63; /* Тот же цвет что и у обычных браков */
}

/* Коннекторы для бывших супругов - тоже пунктирные и того же цвета */
.connection-line.connector.ex-spouse-left,
.connection-line.connector.ex-spouse-right {
    stroke-dasharray: 5, 5;
    stroke: #e91e63;
    stroke-width: 3; /* Та же толщина что и у обычных браков */
}

.connection-line.marriage {
    stroke: #e91e63;
    stroke-width: 3;
}

/* Адаптивность */
@media (max-width: 768px) {
    .tree-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .tree-controls h2 {
        font-size: 18px;
    }
    
    .controls-right {
        width: 100%;
        justify-content: center;
    }
    
    .info-row {
        grid-template-columns: 1fr;
    }
}

/* Анимация появления */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.person-card {
    animation: fadeIn 0.3s ease;
}

/* Стили для текста в SVG */
text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    user-select: none;
    pointer-events: none;
}

text.person-surname {
    font-size: 15px;
    font-weight: 700;
    fill: #2d3748;
}

text.person-name {
    font-size: 13px;
    fill: #2d3748;
}

text.person-dates {
    font-size: 11px;
    fill: #4a5568;
}

text.person-place {
    font-size: 11px;
    fill: #4a5568;
}

/* Социальные сети */
.social-links-wrapper {
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 18px;
    transition: all 0.3s ease;
    text-decoration: none;
    line-height: 1;
}

.social-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.social-icon i {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 100%;
    height: 100%;
    vertical-align: middle;
}

.social-icon i::before {
    display: block;
}

/* Цвета для разных соцсетей */
#googleLink:hover {
    background: #EA4335;
    color: white;
}

#facebookLink:hover {
    background: #1877F2;
    color: white;
}

#instagramLink:hover {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
}

#telegramLink:hover {
    background: #0088cc;
    color: white;
}

#twitterLink:hover {
    background: #1DA1F2;
    color: white;
}

#youtubeLink:hover {
    background: #FF0000;
    color: white;
}

/* Фотоальбомы */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.album-card {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

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

.album-cover {
    position: relative;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
    background: #f3f4f6;
}

.album-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.album-card:hover .album-overlay {
    opacity: 1;
}

.album-overlay i {
    color: white;
    font-size: 32px;
}

.album-info {
    padding: 10px;
    background: #fff;
}

.album-name {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 5px 0;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.album-count {
    font-size: 12px;
    color: #718096;
}
