﻿*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background: #001445;
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    height: 100vh;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lang-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

/* Кнопка с текущим активным флагом */
.lang-current {
    background: rgba(0, 20, 69, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 10px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

    .lang-current:hover {
        background: rgba(0, 30, 90, 0.6);
        border-color: rgba(255, 255, 255, 0.3);
        transform: scale(1.05);
    }

.lang-arrow {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.2s ease;
}

/* Поворот стрелочки при открытии меню */
.lang-switcher.open .lang-arrow {
    transform: rotate(180deg);
}

/* Выпадающее меню с остальными флагами */
.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(0, 20, 69, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

/* Класс отображения меню */
.lang-switcher.open .lang-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Иконка внутри выпадающего списка */
.lang-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 50%;
    padding: 3px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    width: auto !important;
    margin: 0 !important;
}

    .lang-btn:hover {
        opacity: 1;
        background: rgba(255, 255, 255, 0.1);
        transform: scale(1.1);
    }

    .lang-btn.active {
        opacity: 1;
        border-color: #0078d4;
        background: rgba(0, 120, 212, 0.2);
    }

.flag-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.flag-current-icon .flag-icon {
    width: 20px;
    height: 20px;
}

/* Адаптив для мобилок */
@media (max-width: 600px) {
    .lang-switcher {
        top: 12px;
        right: 12px;
    }
}

#dashboardView {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.top-right-actions {
    position: fixed !important;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 9999 !important;
    pointer-events: auto;
}

    .top-right-actions button,
    .profileBtn,
    #logoutBtn {
        width: auto !important;
        margin: 0 !important;
        flex-shrink: 0;
        touch-action: manipulation;
    }

.dashboard-content {
    max-width: 600px;
    margin: 60px auto 0 auto;
    text-align: center;
}

#treesList {
    margin: 20px 0;
}

@media (max-width: 600px) {
    #dashboardView {
        padding: 10px;
    }

    .top-right-actions {
        top: 12px;
        right: 12px;
        gap: 8px;
    }

    .profileBtn, #logoutBtn {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 38px;
    }

        .profileBtn:hover, #logoutBtn:hover {
            transform: none !important;
        }

    .dashboard-content {
        margin-top: 60px;
    }

        .dashboard-content h2 {
            font-size: 1.3rem;
        }
}

.auth-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-redirect {
    font-family: sans-serif;
    font-size: 14px;
    color: white;
}

    .auth-redirect a {
        color: #007bff;
        text-decoration: none;
        font-weight: bold;
    }

        .auth-redirect a:hover {
            text-decoration: underline;
            color: #0056b3;
        }

input[type="text"],
input[type="password"],
input[type="number"] {
    display: block;
    width: 100%;
    height: 45px;
    padding: 0 14px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(217, 217, 217, 0.1);
    color: white;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s, transform 0.2s ease-in-out;
}

    input[type="text"]:hover,
    input[type="password"]:hover,
    input[type="number"]:hover {
        transform: scale(1.04);
        background: #06174e;
    }

    input[type="text"]:focus,
    input[type="password"]:focus,
    input[type="number"]:focus {
        border-color: rgba(255, 255, 255, 0.6);
        transform: scale(1.02);
    }

select {
    display: block;
    width: 100%;
    height: 45px;
    padding: 0 40px 0 14px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background-color: rgba(217, 217, 217, 0.1);
    color: white;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s, transform 0.2s ease-in-out, background-color 0.2s;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    box-sizing: border-box;
}

    select option {
        background: #06174e;
        color: white;
    }

    select:hover {
        transform: scale(1.04);
        background-color: #06174e;
    }

    select:focus {
        border-color: rgba(255, 255, 255, 0.6);
        transform: scale(1.02);
        background-color: #06174e;
    }

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

button {
    display: block;
    width: 100%;
    padding: 12px;
    background: rgba(0, 20, 69, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    cursor: pointer;
    font-size: 16px;
    border-radius: 12px;
    gap: 25px;
    margin: 0 6px;
    transition: border-color 0.2s, transform 0.2s ease-in-out;
}

    button:hover {
        background: rgba(0, 82, 204, 0.3);
        transform: scale(1.04);
    }

    button:active {
        transform: scale(0.98);
    }

/* Объединенный блок модального окна без повторений */
.modal-content {
    background: rgba(0, 20, 69, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    padding: 25px 30px;
    border-radius: 12px;
    text-align: center;
    width: 100%;
    max-width: 320px;
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

    .modal-content::-webkit-scrollbar {
        width: 5px;
    }

    .modal-content::-webkit-scrollbar-track {
        background: transparent;
        margin: 12px 0;
    }

    .modal-content::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.18);
        border-radius: 20px;
        transition: background 0.2s ease, box-shadow 0.2s ease;
    }

        .modal-content::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.45);
            box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
        }

.btn-fab {
    display: none;
    position: absolute;
    pointer-events: auto;
    z-index: 20;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 40px;
    background-color: #6366f1;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    align-items: center;
    justify-content: center;
}

    .btn-fab:hover {
        background-color: #4f46e5;
        box-shadow: 0 15px 35px rgba(99, 102, 241, 0.6);
    }

h1, h2, h3 {
    color: white;
    margin: 0 0 25px 0;
}

#messageText {
    margin-top: 15px;
    margin-bottom: 0;
    font-size: 14px;
    color: #ff4d4d;
}

.password-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
}

    .password-wrapper input {
        margin-bottom: 0 !important;
        padding-right: 45px !important;
    }

.toggle-password-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    user-select: none;
    z-index: 5;
}

    .toggle-password-btn:hover {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }

#staySignedLbl {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 20px;
    color: white !important;
}

#rememberMe {
    appearance: none;
    -webkit-appearance: none;
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
    margin: 0 10px 0 0;
    background: rgba(217, 217, 217, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    cursor: pointer;
    outline: none;
    position: relative;
    transition: all 0.2s ease;
}

    #rememberMe:hover {
        border-color: rgba(255, 255, 255, 0.5);
        background: rgba(217, 217, 217, 0.2);
    }

    #rememberMe:checked {
        background: #0052cc;
        border-color: #0052cc;
        box-shadow: 0 0 8px rgba(0, 82, 204, 0.5);
    }

        #rememberMe:checked::before {
            content: "";
            position: absolute;
            left: 5px;
            top: 2px;
            width: 5px;
            height: 9px;
            border: solid white;
            border-width: 0 2px 2px 0;
            transform: rotate(45deg);
        }

#welcomeTitle {
    font-weight: normal;
    color: white;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 10, 35, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.btnPerson-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.btnRship-row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.btnTree-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

    .btnTree-row h2 {
        margin: 0 !important;
        line-height: 1;
    }

.gender-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.btn-genderFemale,
.btn-genderMale {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 45px !important;
    height: 45px !important;
    padding: 0 !important;
    font-size: 24px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn-genderOther {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 45px !important;
    height: 45px !important;
    padding: 0 !important;
    font-size: 24px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #a855f7;
}

    .btn-genderOther:hover {
        background: rgba(168, 85, 247, 0.25);
        box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
    }

    .btn-genderOther.active {
        background: #a855f7 !important;
        color: #ffffff !important;
        box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
    }

.btn-genderFemale {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #f43f5e;
}

    .btn-genderFemale:hover {
        background: rgba(244, 63, 94, 0.25);
        box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
    }

    .btn-genderFemale.active {
        background: #f43f5e !important;
        color: #ffffff !important;
        box-shadow: 0 0 15px rgba(244, 63, 94, 0.6);
    }

.btn-genderMale {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

    .btn-genderMale:hover {
        background: rgba(59, 130, 246, 0.25);
        box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
    }

    .btn-genderMale.active {
        background: #3b82f6 !important;
        color: #ffffff !important;
        box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
    }

.char-gender-icon {
    font-size: 20px;
    font-weight: bold;
    margin-right: 4px;
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
}

.char-gender-text {
    color: #9ca3af;
    vertical-align: middle;
}

.char-gender-icon.female {
    color: #f43f5e;
    text-shadow: 0 0 10px rgba(244, 63, 94, 0.6);
}

.char-gender-icon.male {
    color: #3b82f6;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

.char-gender-icon.other {
    color: #a855f7;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

.tree-card-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 20px;
    margin: 10px 0;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s, transform 0.2s ease-in-out, background 0.2s;
}

    .tree-card-item:hover {
        transform: scale(1.04);
        background: rgba(255, 255, 255, 0.1);
        border-color: #007acc;
    }

.btn-danger {
    background: rgba(235, 64, 52, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(235, 64, 52, 0.4);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

    .btn-danger:hover {
        background: rgba(235, 64, 52, 0.4);
        color: #fff;
        box-shadow: 0 0 10px rgba(235, 64, 52, 0.3);
    }

#treeWorkspaceView {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.tree-canvas-workspace {
    position: relative;
    width: 100%;
    height: calc(100vh - 100px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: #000b26;
    overflow: hidden;
    box-shadow: inset 0 8px 32px rgba(0, 0, 0, 0.6);
}

.btn-delete-small {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.5;
    border-radius: 6px;
    transition: all 0.2s ease;
}

    .btn-delete-small:hover {
        opacity: 1;
        background: rgba(235, 64, 52, 0.2);
        transform: scale(1.1);
    }

.character-card {
    position: absolute;
    display: inline-block;
    width: 175px;
    pointer-events: auto;
    z-index: 10;
    margin: 0 !important;
    box-sizing: border-box;
    color: #ffffff;
    text-align: center;
    vertical-align: top;
    background: rgba(0, 20, 69, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    padding: 38px 38px 16px 38px !important;
    animation: fadeInCard 0.3s ease-out;
}

    .character-card .char-name {
        font-weight: 600;
        font-size: 16px;
        margin-bottom: 6px;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.2;
    }

.btn-delete-char {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(244, 63, 94, 0.1);
    color: #f43f5e;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, background 0.2s;
}

.character-card:hover .btn-delete-char {
    opacity: 1;
}

.btn-delete-char:hover {
    background: #f43f5e !important;
    color: #ffffff !important;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.5);
}

.character-card .char-age {
    font-size: 13px;
    color: #9ca3af;
}

.char-controls-left {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    z-index: 10;
    transition: opacity 0.2s ease-in-out;
}

.character-card:hover .char-controls-left {
    opacity: 1;
}

.btn-link-char, .btn-add-relative-char {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    padding: 0;
}

.btn-link-char {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

    .btn-link-char:hover {
        background: #3b82f6 !important;
        color: #ffffff !important;
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    }

.btn-add-relative-char {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

    .btn-add-relative-char:hover {
        background: #10b981 !important;
        color: #ffffff !important;
        box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    }

.btn-edit-char {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    opacity: 0;
    z-index: 10;
    transition: all 0.2s ease-in-out;
}

.character-card:hover .btn-edit-char {
    opacity: 1;
}

.btn-edit-char:hover {
    background: #f59e0b !important;
    color: #ffffff !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

@keyframes fadeInCard {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spouse-icon {
    paint-order: stroke fill;
    stroke: #000b26;
    stroke-width: 6px;
    stroke-linejoin: round;
    filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.5));
}

.input-hint {
    display: block;
    text-align: left;
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 6px;
    margin-left: 2px;
}

.traits-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
    margin-bottom: 12px;
    min-height: 24px;
}

.trait-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 50px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(129, 140, 248, 0.4);
    color: #c7d2fe;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

textarea {
    display: block;
    width: 100%;
    min-height: 90px;
    padding: 10px 14px;
    margin-top: 10px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(217, 217, 217, 0.1);
    color: white;
    font-family: Arial, sans-serif;
    font-size: 15px;
    outline: none;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s, background-color 0.2s, transform 0.2s ease-in-out;
}

    textarea:hover {
        background-color: #06174e;
    }

    textarea:focus {
        border-color: rgba(255, 255, 255, 0.6);
        background-color: #06174e;
    }

    textarea::-webkit-scrollbar {
        width: 6px;
    }

    textarea::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 10px;
    }

        textarea::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.4);
        }

/* Единственные рабочие правила выпадашки в профиле */
#profileModal .modal-content {
    overflow: visible !important;
}

.profile-lang-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    position: relative !important;
    z-index: 1000 !important;
}

#profileModal .lang-switcher {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    display: inline-block !important;
}

#profileModal .lang-menu {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) translateY(-8px) !important;
    z-index: 99999 !important;
}

#profileModal .lang-switcher.open .lang-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) !important;
}
