:root{
    --text:#0f1724;
    --muted:#555;
    --accent-male:#1E90FF;
    --accent-female:#FF4C4C;
    --bg-primary:#f5f7fa;
    --bg-secondary:#eef2f8;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: auto;
}

@media (max-width: 768px) {
    html, body {
        overflow: auto;
    }
}

body {
    margin: 0;
    font-family: 'Sakha', 'Georgia', serif;
    min-height: 100vh;
    color: var(--text);
    background-image: url('/static/bg-pattern.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

@font-face{
    font-family: 'Sakha';
    src: url('/static/BauhausSaUni.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

h1 { text-align:center; color:#2d3436; margin:20px 0; font-size:2.2rem; letter-spacing:1.5px; }
.family-selector-container{
    text-align:center;
    padding:12px;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(10,15,30,0.04);
    display:flex;
    gap:12px;
    align-items:center;
    justify-content:center;
    flex-wrap:wrap;
}

.family-selector-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 6px rgba(10,15,30,0.04);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .family-selector-container {
        padding: 10px 12px;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .family-selector-container {
        padding: 8px 10px;
        gap: 6px;
    }
}

.family-selector-container .site-title {
    margin: 0;
    font-size: 1.9rem;
    line-height: 1.1;
}

@media (max-width: 768px) {
    .family-selector-container .site-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .family-selector-container .site-title {
        font-size: 1.2rem;
        letter-spacing: 0.5px;
    }
}

.top-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}
.logout-link {
    color: #9b2d30;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: background 0.12s, color 0.12s;
}
.logout-link:hover {
    background: rgba(155,45,48,0.06);
}

.control-row {
    width: 100%;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.control-row .field-label {
    display: block;
    font-size: 13px;
    color: #374151;
    font-weight: 400;
    margin: 0 0 4px 0;
}

.control-row.orientation-row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.control-row.orientation-row .field-label {
    font-weight: 400;
    font-size: 14px;
    margin: 0;
    white-space: nowrap;
}

.control-row.orientation-row select {
    min-width: 220px;
    max-width: 320px;
    width: auto;
}

.control-row select { 
    min-width: 260px; 
    max-width: 420px; 
    width: 70%; 
}

@media (max-width: 768px) {
    .control-row select {
        min-width: auto;
        max-width: 100%;
        width: 90%;
    }
}

@media (max-width: 480px) {
    .control-row select {
        min-width: auto;
        max-width: 100%;
        width: 95%;
        font-size: 14px;
    }
}

.control-row .field-label {
    margin: 0;
    font-size: 1.9rem;
    line-height: 1.1;
}

#loading-message { display: none; }

#mynetwork {
    position: relative;
    flex: 1;
    width: 100%;
    overflow: hidden;
    cursor: grab;
    
    background-image: url('/static/bg-pattern.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-blend-mode: overlay;

    z-index: 1;
    pointer-events: auto;
}

@media (max-height: 600px) {
    #mynetwork { 
        min-height: 60vh; 
    }
}

#mynetwork::before,
.cloud1, .cloud2 {
    pointer-events: none !important;
}

button, input, select, textarea, .family-selector-container, .modal-content {
    pointer-events: auto !important;
    z-index: 120 !important;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.45);
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    visibility: visible;
    box-sizing: border-box;
    padding: 10px;
}

.modal-content {
    margin: 6% auto;
    padding: 0;
    width: 90%;
    max-width: 520px;
    background: #fff;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 8px 30px rgba(15,23,42,0.12);
    border: 1px solid rgba(10,15,30,0.04);
    z-index: 2010;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        transform: none;
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        transform: none;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: 0;
        overflow-y: auto;
        box-sizing: border-box;
    }
}

#nodeModal .modal-content {
    width: calc(100% - 40px);
    max-width: 90vw;
    height: calc(100vh - 80px);
    max-height: 90vh;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 40px auto;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    #nodeModal .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        padding: 16px;
        margin: 0;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

@media (max-width: 480px) {
    #nodeModal .modal-content {
        width: 100%;
        padding: 12px;
        margin: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

#nodeModal .modal-content h3 {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
}

#nodeModal .modal-content p {
    margin: 10px 0;
    font-size: 15px;
    color: #374151;
    line-height: 1.5;
    word-break: break-word;
}

#nodeModal .modal-content p strong {
    color: #1f2937;
    font-weight: 600;
}

#nodeModal .member-photo {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: 8px;
    margin: 12px 0 16px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    display: block;
}

#nodeModal .member-photo:hover {
    transform: scale(1.03);
    filter: brightness(1.08);
}

@media (max-width: 768px) {
    #nodeModal .member-photo {
        max-width: 100%;
        max-height: 40vh;
        margin: 10px 0 12px 0;
    }
}

#nodeModal .info-block {
    background-color: #f9fafb;
    border-left: 4px solid #3b82f6;
    padding: 14px;
    border-radius: 4px;
    margin: 12px 0;
    max-height: 400px;
    overflow-y: auto;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    #nodeModal .info-block {
        max-height: 300px;
        padding: 12px;
        margin: 10px 0;
    }
}

#nodeModal .info-block p {
    margin: 8px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: justify;
    hyphens: auto;
    font-size: 15px;
    line-height: 1.6;
}

#nodeModal .info-block img {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    display: block;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
}

#nodeModal .info-block img:hover {
    transform: scale(1.03);
    filter: brightness(1.08);
}

.form-modal {
    width: 500px !important;
    max-width: 90%;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.form-container {
    padding: 20px;
}

.form-group {
    margin-bottom: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: #374151;
    text-transform: none;
}

.label-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.label-with-button label {
    margin: 0;
}

.btn-insert-photo {
    padding: 4px 8px;
    font-size: 12px;
    background-color: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-insert-photo:hover {
    background-color: #e0f2fe;
    border-color: #0ea5e9;
}

.btn-insert-photo:active {
    background-color: #cffafe;
}

.form-group label .required {
    color: #ef4444;
    margin-left: 2px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 0px;
    font-size: 14px;
    color: #1f2937;
    background-color: #f3f4f6;
    border: none;
    border-radius: 6px;
    transition: background-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    background-color: #e5e7eb;
    box-shadow: inset 0 0 0 1px #d1d5db;
}

.form-group input:hover,
.form-group textarea:hover,
.form-group select:hover {
    background-color: #e5e7eb;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    font-family: inherit;
    overflow-y: auto;
    text-align: justify;
    padding: 10px;
}

.rich-text-editor {
    width: 100%;
    min-height: 80px;
    max-height: 250px;
    padding: 10px;
    font-size: 14px;
    color: #1f2937;
    background-color: #f3f4f6;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    overflow-y: auto;
    text-align: justify;
    word-wrap: break-word;
    outline: none;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.rich-text-editor:hover {
    background-color: #e5e7eb;
}

.rich-text-editor:focus {
    background-color: #e5e7eb;
    box-shadow: inset 0 0 0 1px #d1d5db;
}

.rich-text-editor img {
    max-width: 100%;
    height: auto;
    margin: 8px 4px 8px 0;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: inline-block;
    max-height: 150px;
}

.form-group input[type="file"] {
    padding: 8px 0;
    background-color: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-group input[type="file"]:hover {
    border-color: #3b82f6;
}

.form-group input[type="file"]:focus {
    border-color: #3b82f6;
    outline: none;
}

.photo-preview {
    margin-top: 10px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 200px;
}

.photo-preview img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-group select:focus {
    background-color: #e5e7eb;
}

.parent-field {
    position: relative;
}

#newMemberParentDisplay {
    display: block;
    width: 100%;
    padding: 10px 0px;
    font-size: 14px;
    color: #1f2937;
    background-color: #f3f4f6;
    border-radius: 6px;
    min-height: 20px;
    transition: background-color 0.2s;
}

#newMemberParentDisplay:hover {
    background-color: #e5e7eb;
}

#newMemberParentDisplay:empty::before {
    content: '-- Без родителя --';
    color: #9ca3af;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.checkbox-group .checkbox-label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
    margin-top: 20px;
}

.btn {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    font-family: inherit;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

.btn-secondary:active {
    background-color: #9ca3af;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:active {
    background-color: #b91c1c;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
}

.edit-mode .node-controls {
    display: flex !important;
    gap: 4px;
    justify-content: center;
}

.delete-btn, .add-child-btn {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s, transform 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.delete-btn {
    background-color: #ef4444;
}

.delete-btn:hover {
    background-color: #dc2626;
    transform: scale(1.1);
}

.add-child-btn {
    background-color: #10b981;
}

.add-child-btn:hover {
    background-color: #059669;
    transform: scale(1.1);
}

.node-controls {
    display: none;
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    gap: 4px;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px;
    border-radius: 4px;
}

.lightbox {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    overflow: hidden;
    animation: fadeIn 0.3s ease-in-out;
}

.lightbox.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 6px;
    animation: zoomIn 0.3s ease-in-out;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: rgb(255, 200, 0);
    font-size: 40px;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 3001;
}

.lightbox-close:hover {
    color: #ddd;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 30px;
    cursor: pointer;
    user-select: none;
    padding: 20px;
    transition: color 0.2s;
    z-index: 3001;
}

.lightbox-nav:hover {
    color: #ddd;
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

.lightbox-caption {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 4px;
    max-width: 80%;
}

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

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal .close {
    position: absolute;
    right: 20px;
    top: 12px;
    font-size: 22px;
    color: #777;
    cursor: pointer;
    z-index: 2020;
    transition: color 0.2s;
}
.modal .close:hover { 
    color: #000; 
}

#nodeModal .modal-content .close {
    right: 16px;
    top: 14px;
}

@media (max-width: 768px) {
    .modal .close {
        right: 16px;
        top: 10px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .modal .close {
        right: 12px;
        top: 8px;
        font-size: 18px;
    }
}
