:root {
    --primary: #4a90e2;
    --primary-light: #6fb1fc;
    --primary-dark: #357abd;

    --male-bg: #e3f2fd;
    --female-bg: #fce4ec;
    --male-dark: #bbdefb;
    --female-dark: #ffd1dc;

    --deceased-male: #455a64;
    --deceased-female: #5d4037;

    --link-father: #2196f3;
    --link-mother: #f44336;
    --accent-red: #c2185b;
    --accent-blue: #1976d2;

    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass: rgba(255, 255, 255, 0.8);
    --glass-heavy: rgba(255, 255, 255, 0.95);
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --shadow-strong: 0 8px 32px 0 rgba(31, 38, 135, 0.25);

    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
}

.search-container {
    position: relative;
    max-width: 300px;
    width: 100%;
}

.search-container input {
    padding: 10px 18px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-family: inherit;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 200px;
}

.search-container input:focus {
    background: #fff;
    width: 100%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.search-results {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: 0;
    background: var(--glass-heavy);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 18px;
    box-shadow: var(--shadow-strong);
    z-index: 2100;
    max-height: 350px;
    overflow-y: auto;
    display: none;
    padding: 8px;
    animation: modalSlide 0.3s ease-out;
}

.search-item {
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}

.search-item:last-child {
    margin-bottom: 0;
}

.search-item:hover {
    background: var(--primary);
    color: white;
}

.search-item .name {
    font-weight: 700;
    font-size: 0.95rem;
}

.search-item .meta {
    font-size: 0.75rem;
    opacity: 0.7;
}

.search-item:hover .meta {
    opacity: 0.9;
}

.node-name {
    font-size: 14px;
    font-weight: bold;
    fill: #2c3e50;
    pointer-events: none;
}

.node-date {
    font-size: 12px;
    fill: #7f8c8d;
    pointer-events: none;
}

.search-highlight {
    stroke: #ffeb3b !important;
    stroke-width: 6px !important;
    filter: drop-shadow(0 0 10px #ffeb3b);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient);
    height: 100vh;
    overflow: hidden;
    color: var(--text-main);
}

/* Header Styling */
.main-header {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 70px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-soft);
    z-index: 1000;
    transition: all 0.3s ease;
}

.main-header:hover {
    box-shadow: var(--shadow-strong);
}

.main-header h1 {
    font-weight: 700;
    font-size: 1.6rem;
    background: linear-gradient(45deg, var(--primary-dark), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Tree Container */
#tree-container {
    width: 100vw;
    height: 100vh;
    background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.05) 1px, transparent 0);
    background-size: 40px 40px;
    cursor: grab;
    transition: background-color 0.3s ease;
}

#tree-container:active {
    cursor: grabbing;
}

/* Zoom Controls */
.controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 900;
}

.controls button {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: var(--glass);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    font-size: 1.4rem;
    color: var(--primary-dark);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls button:hover {
    background: white;
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-strong);
    color: var(--primary);
}

.controls button:active {
    transform: translateY(0) scale(0.95);
}

/* Tree Nodes Styling */
.person-circle circle,
.spouse-circle circle {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05));
    cursor: pointer;
}

.person-circle:hover circle,
.spouse-circle:hover circle {
    transform: translateY(-2px);
    filter: drop-shadow(0 8px 15px rgba(0, 0, 0, 0.15));
}

.node-name {
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
    fill: var(--text-main);
}

.node-date {
    font-size: 11px;
    fill: var(--text-muted);
    font-weight: 300;
    pointer-events: none;
}

.deceased .node-name,
.deceased .node-date {
    fill: #ffffff !important;
}

/* Connection Lines */
.link-father {
    fill: none;
    stroke: var(--accent-blue);
    stroke-width: 2.5;
    opacity: 0.4;
    transition: opacity 0.3s, stroke-width 0.3s;
}

.link-mother {
    fill: none;
    stroke: var(--accent-red);
    stroke-width: 2.5;
    opacity: 0.4;
    transition: opacity 0.3s, stroke-width 0.3s;
}

.node-group:hover~.link-father,
.node-group:hover~.link-mother {
    opacity: 1;
    stroke-width: 4;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-edit {
    background: #f39c12;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-edit:hover {
    background: #e67e22;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.btn-add-child {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-add-child:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #546e7a;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #37474f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(84, 110, 122, 0.3);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-danger:hover {
    background: #e53935;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.3);
}

.btn-success {
    background: #43a047;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    margin-top: 15px;
    transition: all 0.3s;
}

.btn-success:hover {
    background: #2e7d32;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 160, 71, 0.3);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 62, 80, 0.4);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: var(--glass-heavy);
    margin: 8vh auto;
    padding: 40px;
    border-radius: 30px;
    width: 90%;
    max-width: 650px;
    box-shadow: var(--shadow-strong);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: modalSlide 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.modal-content.small {
    max-width: 450px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlide {
    from {
        transform: translateY(50px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.close {
    position: absolute;
    left: 25px;
    top: 25px;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
}

.close:hover {
    color: var(--accent-red);
}

/* Form Styling */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 18px;
}

input,
select,
textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid #edf2f7;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
    background: white;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

textarea {
    height: 120px;
    resize: none;
}

.error {
    color: var(--accent-red);
    font-size: 0.95rem;
    margin-top: 12px;
    text-align: center;
    font-weight: 500;
}

/* Person Profile Detail */
#person-details {
    padding-top: 10px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 25px;
}

.profile-img {
    width: 120px;
    height: 120px;
    border-radius: 30px;
    background: linear-gradient(135deg, #f1f3f5 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    color: #ced4da;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

.profile-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    color: var(--text-main);
}

.profile-info p {
    color: var(--text-muted);
    margin-bottom: 4px;
}

.bio-section {
    background: #f8fafc;
    padding: 20px;
    border-radius: 20px;
    margin-top: 20px;
    border: 1px solid #edf2f7;
}

.bio-section h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.bio-section p {
    line-height: 1.6;
    color: #4a5568;
}

/* Relations Styling */
.relations-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.rel-box {
    background: #f1f5f9;
    padding: 15px;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.rel-box h4 {
    margin-bottom: 10px;
    color: var(--primary-dark);
    font-size: 1rem;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 5px;
    margin-top: 0;
}

.relation-link {
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
    text-decoration: none;
}

.relation-link:hover {
    opacity: 0.7;
}

.rel-male {
    color: #1a73e8 !important;
}

.rel-female {
    color: #e91e63 !important;
}

.rel-deceased {
    color: #70757a !important;
    text-decoration-style: dashed;
}

.children-list {
    max-height: 100px;
    overflow-y: auto;
}


.admin-actions button {
    flex: 1;
}

/* Responsiveness */
@media (max-width: 900px) {
    .main-header {
        padding: 0 20px;
    }
}

@media (max-width: 600px) {
    .main-header {
        top: 10px;
        left: 10px;
        right: 10px;
        height: auto;
        flex-direction: column;
        padding: 15px;
        gap: 15px;
    }

    .main-header h1 {
        font-size: 1.2rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    .search-container {
        margin-right: 0;
        width: 100%;
    }

    .search-container input {
        width: 100% !important;
    }

    .header-actions button {
        width: 100%;
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .controls {
        bottom: 20px;
        right: 20px;
    }

    .controls button {
        width: 40px;
        height: 40px;
    }
}

/* New visitor specific buttons */
.login-corner-btn {
    position: fixed;
    top: 30px;
    left: 40px;
    z-index: 1100;
    background: var(--glass);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 6px 15px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s;
}

.login-corner-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-soft);
}

.whatsapp-fab {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background-color: #25d366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1200;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.whatsapp-fab img {
    width: 35px;
    height: 35px;
}

.whatsapp-fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.login-btn {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    padding: 8px 20px;
    color: var(--primary-dark);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

.login-btn:hover {
    background: white;
    box-shadow: var(--shadow-strong);
    color: var(--primary);
    transform: translateY(-2px);
}

.help-fab {
    position: fixed;
    bottom: 30px;
    right: 100px;
    height: 50px;
    padding: 0 20px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary-dark);
    box-shadow: var(--shadow-soft);
    z-index: 1200;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.help-fab:hover {
    transform: translateY(-3px);
    background: white;
    box-shadow: var(--shadow-strong);
    color: var(--primary);
}

.guide-section {
    margin-bottom: 25px;
}

.guide-section h2 {
    color: var(--primary-dark);
    font-size: 1.4rem;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    line-height: 1.6;
}

.guide-icon {
    min-width: 24px;
    height: 24px;
    background: var(--primary-light);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.legend-color {
    width: 30px;
    height: 4px;
    border-radius: 2px;
}

.legend-blue {
    background: var(--link-father);
}

.legend-red {
    background: var(--link-mother);
}

@media (max-width: 600px) {
    .help-fab {
        width: auto;
        height: 40px;
        bottom: 20px;
        right: 80px;
        padding: 0 15px;
        font-size: 0.85rem;
    }

    .whatsapp-fab img {
        width: 30px;
        height: 30px;
    }

    .header-actions {
        gap: 8px;
    }
}