/* style.css — FINAL VERSION WITH FIXED MODAL SPACING & BLUE POSITION BADGES */

:root {
    --primary-dark: #2c3e50;
    --bg-body: #f4f7f6;
    --white: #ffffff;
    --accent-color: #3498db;
    
    /* Кнопки */
    --btn-add: #27ae60;
    --btn-report: #2980b9;
    --btn-logs: #8e44ad;
    --btn-logout: #c0392b;
    --btn-login: #f39c12;
    --btn-delete: #e74c3c; 
    
    /* Иконки */
    --icon-birth: #d4ac0d;
    --icon-death: #333333;
    --icon-row: #e67e22;
    --icon-place: #c0392b;
    --icon-info: #3498db;

    --star-color: #bf9b5e;  
    --title-color: #d4ac0d;
    
    --radius-table: 8px;
    --radius-btn: 50px;
    --radius-card: 12px;
    
    /* Цвета для фото */
    --photo-green-light: #e8f5e9;
    --photo-green-border: #4caf50;
    --photo-green-glow: rgba(76, 175, 80, 0.2);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-body);
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ================= HEADER ================= */
header {
    background-color: var(--primary-dark);
    color: var(--white);
    padding: 12px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: sticky; top: 0; z-index: 1000;
}
.header-inner {
    max-width: 1400px; margin: 0 auto; padding: 0 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.logo-area { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }

/* 🔥 НОВОЕ: Стили для логотипа logo.png (40x40) */
.tree-logo-icon {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.tree-logo-icon:hover {
    transform: scale(1.05);
}

.magen-david-icon { width: 36px; height: 36px; color: var(--star-color); }
.logo-text h1 { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--title-color); }
.logo-text span { font-size: 0.9rem; opacity: 0.9; }
.header-nav { display: flex; align-items: center; gap: 10px; }

/* ================= BUTTONS ================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px; font-size: 0.9rem; font-weight: 600;
    text-decoration: none; color: #fff; background-color: #555; border: none; cursor: pointer;
    transition: all 0.2s ease; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.btn:active { transform: translateY(0); }

.btn-add { background-color: var(--btn-add); }
.btn-report { background-color: var(--btn-report); }
.btn-logs { background-color: var(--btn-logs); padding: 8px 12px; }
.btn-logout { background-color: var(--btn-logout); padding: 8px 12px; }
.btn-login { background-color: var(--btn-login); }
.btn-delete { background-color: var(--btn-delete); }

.btn-icon { background: none; border: none; cursor: pointer; color: #7f8c8d; font-size: 1em; padding: 4px; transition: color 0.2s; }
.btn-icon:hover { color: var(--accent-color); }

.lang-switch { display: flex; background: rgba(255,255,255,0.1); border-radius: 15px; padding: 2px; margin-right: 5px; }
.lang-link { color: #fff; text-decoration: none; padding: 4px 8px; border-radius: 12px; font-size: 0.75rem; opacity: 0.7; }
.lang-link.active { background: var(--title-color); color: #000; opacity: 1; }

/* ================= CONTAINER ================= */
.container { max-width: 1400px; margin: 20px auto; padding: 0 15px; flex: 1; width: 100%; }

/* ================= SEARCH & CONTROLS ================= */
.search-bar {
    display: flex; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; align-items: center;
    background: #fff; padding: 15px; border-radius: var(--radius-card); box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.search-input-wrapper { position: relative; flex: 1; min-width: 200px; }
.search-input-wrapper input {
    width: 100%; padding: 10px 15px 10px 35px; border: 1px solid #ddd;
    border-radius: var(--radius-btn); font-size: 0.95rem; transition: border-color 0.3s;
}
.search-input-wrapper input:focus { border-color: var(--accent-color); outline: none; }
.search-input-wrapper i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #999; }

/* КНОПКИ ПЕРЕКЛЮЧЕНИЯ ВИДА */
.view-switch { 
    display: flex; 
    background: #f0f0f0; 
    border-radius: 30px; 
    padding: 3px; 
}
.view-switch button { 
    background: none; 
    border: none; 
    padding: 6px 12px; 
    border-radius: 25px; 
    cursor: pointer; 
    color: #777; 
    transition: all 0.2s; 
    font-size: 0.9rem;
}
.view-switch button i {
    margin-right: 5px;
}
.view-switch button.active { 
    background: #fff; 
    color: var(--primary-dark); 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

/* === SORT CHIPS (СОРТИРОВКА) === */
.sort-container { 
    display: none;
    margin-bottom: 20px; 
}
.sort-container.active { display: block; }
.sort-chips-wrapper { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
.sort-chip {
    display: inline-flex; align-items: center; justify-content: center; padding: 6px 14px;
    background: #fff; border: 1px solid #e0e0e0; border-radius: 30px; color: #555;
    text-decoration: none; font-size: 0.85rem; font-weight: 600; white-space: nowrap;
    transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.sort-chip:hover { background: #f8fbff; border-color: var(--accent-color); color: var(--accent-color); transform: translateY(-1px); }
.sort-chip.active { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); box-shadow: 0 3px 8px rgba(44, 62, 80, 0.2); }

/* ================= КАРТОЧКИ ================= */
.cards-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); 
    gap: 20px; 
    padding-bottom: 20px; 
}

.card {
    background: #fff;
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: grid;
    grid-template-columns: 130px 1fr;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #eee;
    cursor: pointer;
    height: 100%;
    min-height: 170px;
    max-height: 190px;
    width: 100%;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* КАРТОЧКИ С ФОТО - ЗЕЛЕНОЕ ВЫДЕЛЕНИЕ */
.card.has-photo {
    border-left: 4px solid var(--photo-green-border);
    box-shadow: 0 2px 10px var(--photo-green-glow);
}

.card.has-photo:hover {
    box-shadow: 0 5px 15px var(--photo-green-glow);
}

.card-photo-wrapper {
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    overflow: hidden;
    padding: 8px;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.card:hover .card-img {
    transform: scale(1.03);
}

.card-content {
    padding: 10px 10px 10px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #f9f9f9;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: 8px 8px 8px 0;
    transition: transform 0.3s ease;
    border: 1px solid #e0e0e0;
    height: calc(100% - 16px);
    min-height: 154px;
    width: calc(100% - 8px);
    overflow: hidden;
}

.card.has-photo .card-content {
    background: linear-gradient(135deg, #f9f9f9 0%, #f0f7f0 100%);
    border-color: var(--photo-green-border);
}

.card:hover .card-content {
    transform: scale(1.01);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.card-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 30px);
}

/* Имя и фамилия одинаковым шрифтом в карточках */
.card-name .first-name {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.2rem;
    display: inline;
    margin-left: 8px;
}

/* ДАТЫ В ОДНУ СТРОКУ СО СТРЕЛКОЙ */
.card-dates-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 6px;
    background: rgba(255,255,255,0.7);
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.05);
    width: 100%;
}

.card.has-photo .card-dates-row {
    background: rgba(232, 245, 233, 0.7);
    border-color: var(--photo-green-border);
}

.date-item {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.date-item.birth {
    justify-content: flex-start;
}

.date-item.death {
    justify-content: flex-end;
}

.date-item i.fa-star-of-david {
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.date-item.birth i.fa-star-of-david {
    color: var(--icon-birth);
}

.date-item.death i.fa-star-of-david {
    color: var(--icon-death);
}

.date-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Стрелка между датами */
.date-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #f6f9fc 0%, #e9f0f5 100%);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
    border: 1px solid rgba(52, 152, 219, 0.2);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.card.has-photo .date-arrow {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: var(--photo-green-border);
    box-shadow: 0 2px 4px var(--photo-green-glow);
}

.date-arrow i {
    font-size: 0.85rem;
    color: var(--accent-color);
}

.card.has-photo .date-arrow i {
    color: var(--photo-green-border);
}

.card:hover .date-arrow {
    transform: scale(1.1);
}

/* Ряд, место и расположение */
.card-location {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    width: 100%;
}

.loc-badge {
    background: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    border: 1px solid #ddd;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card.has-photo .loc-badge {
    background: #f1f8e9;
    border-color: var(--photo-green-border);
}

.loc-badge small {
    color: #666;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.loc-badge strong {
    font-weight: 600;
    color: var(--primary-dark);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 🔥 НОВОЕ: Стили для бейджей расположения (Синие оттенки) */
.position-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
    flex: 1;
    min-width: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.position-left {
    background-color: #e3f2fd;
    color: #1565c0;
    border-color: #bbdefb;
}

.position-middle {
    background-color: #e8eaf6;
    color: #283593;
    border-color: #c5cae9;
}

.position-right {
    background-color: #e1f5fe;
    color: #0277bd;
    border-color: #b3e5fc;
}

.card-info {
    margin-top: 4px;
    padding: 5px 8px;
    background-color: #fff;
    border-radius: 5px;
    font-size: 0.8rem;
    color: #555;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    border: 1px solid #e1f0fa;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card.has-photo .card-info {
    background-color: #f1f8e9;
    border-color: var(--photo-green-border);
}

.card-info i {
    color: var(--icon-info);
    margin-top: 2px;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.card-info span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-header .btn-icon {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.card.has-photo .btn-icon {
    background: #f1f8e9;
    color: #2e7d32;
}

/* ================= ТАБЛИЦА ================= */
.records-count { margin-bottom: 10px; color: #7f8c8d; font-size: 0.85rem; font-weight: 500; }

.table-responsive { 
    overflow: visible;
    background: #fff; 
    border-radius: var(--radius-table); 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    width: 100%;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 0.9rem; 
    table-layout: fixed;
}

th { 
    background-color: var(--primary-dark); 
    color: #fff; 
    padding: 10px 4px 10px 8px;
    text-align: left; 
    white-space: nowrap; 
    font-weight: 600;
    font-size: 0.85rem;
}

/* Левый отступ для первой колонки (фамилия) */
th:first-child, td:first-child {
    padding-left: 8px;
}

/* Настройка ширины колонок для администратора (9 колонок с position) */
.admin-mode th:nth-child(1), .admin-mode td:nth-child(1) { /* last_name */
    width: 14%;
}
.admin-mode th:nth-child(2), .admin-mode td:nth-child(2) { /* first_name */
    width: 14%;
}
.admin-mode th:nth-child(3), .admin-mode td:nth-child(3) { /* birth_date */
    width: 10%;
}
.admin-mode th:nth-child(4), .admin-mode td:nth-child(4) { /* death_date */
    width: 10%;
}
.admin-mode th:nth-child(5), .admin-mode td:nth-child(5) { /* row */
    width: 7%;
    text-align: center;
}
.admin-mode th:nth-child(6), .admin-mode td:nth-child(6) { /* place */
    width: 7%;
    text-align: center;
}
.admin-mode th:nth-child(7), .admin-mode td:nth-child(7) { /* position */
    width: 10%;
    text-align: center;
}
.admin-mode th:nth-child(8), .admin-mode td:nth-child(8) { /* relatives */
    width: 18%;
}
.admin-mode th:nth-child(9), .admin-mode td:nth-child(9) { /* actions */
    width: 10%;
    text-align: center;
}

/* Настройка ширины колонок для обычного пользователя (7 колонок с position) */
.user-mode th:nth-child(1), .user-mode td:nth-child(1) { /* last_name */
    width: 20%;
}
.user-mode th:nth-child(2), .user-mode td:nth-child(2) { /* first_name */
    width: 20%;
}
.user-mode th:nth-child(3), .user-mode td:nth-child(3) { /* birth_date */
    width: 15%;
}
.user-mode th:nth-child(4), .user-mode td:nth-child(4) { /* death_date */
    width: 15%;
}
.user-mode th:nth-child(5), .user-mode td:nth-child(5) { /* row */
    width: 10%;
    text-align: center;
}
.user-mode th:nth-child(6), .user-mode td:nth-child(6) { /* place */
    width: 10%;
    text-align: center;
}
.user-mode th:nth-child(7), .user-mode td:nth-child(7) { /* position */
    width: 10%;
    text-align: center;
}

/* СТРОКИ С ФОТО - ЗЕЛЕНОЕ ВЫДЕЛЕНИЕ */
tr.has-photo {
    background-color: var(--photo-green-light);
    position: relative;
}

tr.has-photo td:first-child {
    position: relative;
    box-shadow: inset 3px 0 0 var(--photo-green-border);
}

tr.has-photo:hover {
    background-color: #d4edda !important;
}

.th-sort-link { 
    color: #fff; 
    text-decoration: none; 
    display: flex; 
    align-items: center; 
    gap: 3px; 
    font-size: 0.8rem;
}

.th-sort-link i {
    font-size: 0.75rem;
}

/* СТИЛИ ДЛЯ ИМЕНИ И ФАМИЛИИ В ТАБЛИЦЕ - ОДИНАКОВЫЕ */
td:nth-child(1) { /* Last name */
    font-weight: 700;
    color: var(--primary-dark);
}

td:nth-child(2) { /* First name */
    font-weight: 700;
    color: var(--primary-dark);
}

td { 
    padding: 8px 4px 8px 8px;
    border-bottom: 1px solid #eee; 
    vertical-align: middle; 
    color: #444; 
    word-break: break-word;
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Для поля родственников */
.relatives-cell {
    font-size: 0.75rem;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-weight: 400;
}

tr:hover { 
    background-color: #f8fcfd; 
    cursor: pointer; 
}

.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.w-action { 
    width: 40px; 
    text-align: center; 
}

/* ================= МОДАЛЬНЫЕ ОКНА ================= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 25px;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 10;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(0,0,0,0.1);
}

.close:hover {
    color: #333;
    background: #f0f0f0;
    transform: rotate(90deg);
}

#viewPhoto {
    max-width: 200px;
    max-height: 200px;
    width: auto;
    height: auto;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border: 3px solid #fff;
}

#viewName {
    color: var(--primary-dark);
    margin-bottom: 20px;
    font-size: 1.8rem;
    font-weight: 700;
    word-break: break-word;
}

.view-data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 25px 0;
}

.view-data-item {
    background: #f8f9fa;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid #eee;
    transition: all 0.2s;
}

.view-data-item:hover {
    background: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.view-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.view-label i {
    font-size: 1rem;
    width: 20px;
}

.view-value-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    margin-top: 0;
    margin-bottom: 0;
    padding-left: 28px;
    word-break: break-word;
}

#viewRelativesContainer {
    display: none;
    margin-top: 25px;
    text-align: left;
    background: #fff3cd;
    padding: 20px 25px;
    border-radius: 16px;
    border: 1px solid #ffe69c;
}

#viewRelatives {
    display: block;
    margin-top: 10px;
    line-height: 1.6;
    font-size: 1rem;
    word-break: break-word;
}

/* ================= ФОРМЫ ================= */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #333; font-size: 0.9rem; }
.form-input {
    width: 100%; padding: 10px 14px;
    border: 2px solid #e0e0e0; border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.2s; background: #fff;
}
.form-input:focus { border-color: var(--accent-color); outline: none; box-shadow: 0 0 0 4px rgba(52,152,219,0.1); }

/* Поле для родственников - фиксированный размер, нельзя менять */
textarea.form-input {
    min-height: 60px;
    max-height: 60px;
    resize: none;
}

#currentPhotoContainer {
    display: none; align-items: center; gap: 15px; margin-bottom: 15px;
    background: #f8f9fa; padding: 10px; border-radius: 8px;
}
#editPhotoPreview { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }

#newPhotoPreviewContainer {
    display: none; margin-bottom: 15px;
}
#newPhotoPreview {
    width: 60px; height: 60px; object-fit: cover; border-radius: 4px; border: 2px solid var(--accent-color);
}

.custom-file-upload {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px;
    border: 2px dashed #ccc; border-radius: 12px; background-color: #f8f9fa;
    cursor: pointer; color: #555; transition: all 0.2s; width: 100%; text-align: center; font-weight: 500; font-size: 0.9rem;
}
.custom-file-upload:hover { background-color: #e8f0fe; border-color: var(--accent-color); color: var(--accent-color); transform: translateY(-2px); }
input[type="file"] { display: none; }

/* ===== КНОПКИ В МОДАЛЬНОМ ОКНЕ ===== */
.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ДЕСКТОП: кнопки рядом по горизонтали симметрично */
.btn-submit {
    background: var(--btn-add);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    flex: 1;
    min-width: 160px;
}

.btn-submit i {
    font-size: 1.1rem;
}

.btn-submit:hover {
    background: #219a52;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39,174,96,0.3);
}

.btn-delete-modal {
    background: var(--btn-delete);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    flex: 1;
    min-width: 160px;
}

.btn-delete-modal i {
    font-size: 1.1rem;
}

.btn-delete-modal:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231,76,60,0.3);
}

/* Маленькая кнопка удаления фото */
.btn-delete-small { 
    background-color: #e74c3c; 
    color: white; 
    border: none; 
    padding: 8px 16px; 
    border-radius: 8px; 
    font-size: 0.85rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s; 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
}

.btn-delete-small i {
    font-size: 0.9rem;
}

.btn-delete-small:hover { 
    background-color: #c0392b; 
    transform: translateY(-1px); 
}

/* ================= LOGIN PAGE ================= */
body.login-page { 
    display: flex;
    align-items: center; justify-content: center; 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh; padding: 20px; 
}
.login-wrapper { width: 100%; max-width: 400px; margin: auto; }
.login-card {
    background: #fff; padding: 40px 35px; border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2); text-align: center; 
}
.login-logo { margin-bottom: 25px; }
.login-logo svg { width: 60px; height: 60px; margin-bottom: 15px; color: var(--star-color); }
.login-logo h1 { margin: 0; font-size: 1.8rem; font-weight: 700; color: var(--primary-dark); }
.login-logo span { font-size: 0.9rem; color: #666; text-transform: uppercase; letter-spacing: 1.5px; }

.input-with-icon { position: relative; margin-bottom: 20px; }
.input-with-icon i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #999; font-size: 1.1rem; }
.input-with-icon input { 
    padding: 14px 18px 14px 48px; border: 2px solid #e0e0e0; border-radius: 12px; 
    font-size: 1rem; width: 100%; transition: all 0.3s;
}
.input-with-icon input:focus { border-color: var(--accent-color); outline: none; box-shadow: 0 0 0 4px rgba(52,152,219,0.1); }

.error-message {
    background: #fee; color: #c33; padding: 14px; border-radius: 10px;
    margin-bottom: 25px; font-size: 0.95rem; border: 1px solid #fcc;
}
.back-link { display: inline-block; margin-top: 25px; color: #666; text-decoration: none; font-size: 0.95rem; transition: color 0.2s; }
.back-link:hover { color: var(--primary-dark); }

/* ================= LANGUAGE BUTTONS ================= */
.lang-buttons-container { margin-top: 30px; display: flex; justify-content: center; gap: 12px; }
.lang-btn {
    display: inline-block; text-decoration: none; padding: 10px 20px;
    border: 2px solid #e0e0e0; border-radius: 30px; color: #555;
    font-size: 0.9rem; font-weight: 600; transition: all 0.2s; background-color: #fff;
}
.lang-btn:hover { background: var(--accent-color); border-color: var(--accent-color); color: #fff; transform: translateY(-2px); }
.lang-btn.active { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); }

/* ================= REPORT PAGE ================= */
.report-search-card {
    background: #fff; padding: 30px; border-radius: 20px; margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.report-form {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 25px; align-items: end;
}
.filter-input-wrapper { display: flex; flex-direction: column; gap: 8px; }
.filter-input-wrapper label { font-size: 0.85rem; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: 0.5px; }
.filter-input-wrapper input { 
    padding: 12px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 0.95rem; width: 100%; 
}
.filter-input-wrapper input:focus { border-color: var(--accent-color); outline: none; }

.report-buttons {
    grid-column: 1 / -1; display: flex; gap: 15px; margin-top: 25px;
    padding-top: 25px; border-top: 1px solid #eee;
}
.btn-search { background-color: var(--accent-color); color: white; flex: 2; }
.btn-pdf { background-color: #e74c3c; color: white; flex: 1; }
.btn-reset-filter { background-color: #95a5a6; color: white; flex: 1; }

/* ================= FOOTER ================= */
.site-footer {
    background: linear-gradient(135deg, #1e2b38 0%, #2c3e50 100%);
    color: #ecf0f1;
    padding: 50px 0 25px;
    margin-top: 50px;
    border-top: 3px solid var(--title-color);
}

.footer-content {
    max-width: 1400px; margin: 0 auto; padding: 0 25px;
    display: grid; grid-template-columns: 1.5fr 1.5fr 2fr; gap: 50px;
}

.footer-section h3 {
    color: var(--title-color); font-size: 1.2rem; margin-bottom: 25px;
    padding-bottom: 10px; border-bottom: 2px solid rgba(212, 172, 13, 0.2);
    display: inline-block; font-weight: 600;
}

.footer-contact p {
    display: flex; align-items: center; gap: 15px; margin-bottom: 15px;
    color: #ddd; font-size: 0.95rem;
}
.footer-contact i { color: var(--title-color); width: 22px; font-size: 1.1rem; }

.footer-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.footer-links a {
    color: #ddd; text-decoration: none; display: inline-flex; align-items: center;
    gap: 10px; transition: all 0.2s; font-size: 0.95rem;
}
.footer-links a:hover { color: #fff; transform: translateX(5px); }
.footer-links i { color: var(--title-color); font-size: 0.85rem; }

.footer-lang-wrapper { display: flex; flex-direction: column; gap: 10px; }
.footer-lang-btn {
    text-decoration: none; padding: 10px 20px; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 30px; color: #fff; font-size: 0.9rem; transition: all 0.2s;
    background: rgba(255,255,255,0.05); display: inline-flex; align-items: center; gap: 8px; width: fit-content;
}
.footer-lang-btn:hover { background: var(--title-color); color: var(--primary-dark); border-color: var(--title-color); transform: translateY(-2px); }
.footer-lang-btn.active { background: var(--title-color); color: var(--primary-dark); border-color: var(--title-color); }

.footer-bottom {
    text-align: center; margin-top: 50px; padding-top: 25px;
    border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.9rem; color: #aaa;
}
.footer-bottom .modiart-link a { color: #fff; text-decoration: none; }
.footer-bottom .modiart-link a:hover { text-decoration: underline; }

/* ================= UTILITY CLASSES ================= */
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.p-20 { padding: 20px; }
.desktop-only { display: block; }
.no-results { grid-column: 1 / -1; text-align: center; padding: 50px; color: #666; font-size: 1.1rem; }

/* ================= RESPONSIVE ================= */

/* Десктоп */
@media (min-width: 769px) {
    .view-switch { 
        display: flex !important; 
    }
}

/* ===== МОБИЛЬНЫЕ СТИЛИ ===== */
@media (max-width: 768px) {
    /* 🔥 Уменьшаем логотип на мобильных */
    .tree-logo-icon {
        width: 32px !important;
        height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
    }
    
    /* Модальные окна на мобильных */
    .modal-content {
        padding: 20px 15px;
        max-width: 95%;
    }
    
    #viewName {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .view-data-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        margin: 15px 0;
    }
    
    .view-data-item {
        padding: 15px;
    }
    
    .view-value-text {
        font-size: 1.1rem;
        padding-left: 24px;
    }
    
    #viewPhoto {
        max-width: 150px;
        max-height: 150px;
        margin-bottom: 15px;
    }
    
    #viewRelativesContainer {
        padding: 15px 20px;
        margin-top: 15px;
    }
    
    .close {
        right: 12px;
        top: 12px;
        width: 36px;
        height: 36px;
        font-size: 24px;
        background: rgba(255,255,255,0.9);
    }
    
    /* Форма редактирования на мобильных */
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-input {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    textarea.form-input {
        min-height: 50px;
        max-height: 50px;
    }
    
    .custom-file-upload {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    /* ===== ВЕРТИКАЛЬНАЯ МОБИЛЬНАЯ ОРИЕНТАЦИЯ (ПОРТРЕТ) ===== */
    @media (orientation: portrait) {
        .modal-actions {
            flex-direction: column;
            gap: 10px !important;
        }
        
        .btn-submit, .btn-delete-modal {
            width: 100%;
            min-width: auto;
            padding: 14px 20px;
            font-size: 1rem;
            flex: none;
        }
        
        .btn-submit i, .btn-delete-modal i {
            font-size: 1.1rem;
        }
    }
    
    /* ===== ГОРИЗОНТАЛЬНАЯ МОБИЛЬНАЯ ОРИЕНТАЦИЯ (ЛАНДШАФТ) ===== */
    @media (orientation: landscape) {
        .modal-content {
            max-width: 85%;
            padding: 20px;
        }
        
        .view-data-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
        }
        
        .modal-actions {
            flex-direction: row;
            gap: 15px;
        }
        
        .btn-submit, .btn-delete-modal {
            flex: 1;
            min-width: 140px;
            padding: 10px 16px;
            font-size: 0.95rem;
        }
        
        .btn-submit i, .btn-delete-modal i {
            font-size: 1rem;
        }
    }
}

/* ===== ГОРИЗОНТАЛЬНАЯ МОБИЛЬНАЯ ВЕРСИЯ (ЛАНДШАФТ) ===== */
@media (max-width: 900px) and (orientation: landscape) {
    .container { padding: 0 10px; }
    
    .view-switch { 
        display: flex !important; 
    }
    
    #tableView, #cardsView {
        display: none;
    }
    
    #tableView[style*="display: block"], 
    #cardsView[style*="display: block"] {
        display: block !important;
    }
    
    .sort-container { display: block !important; }
    .sort-chips-wrapper {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 5px;
    }
    .sort-chip { 
        width: 100%; 
        text-align: center; 
        padding: 6px 2px; 
        font-size: 0.7rem; 
    }
    .sort-chip:nth-child(1), .sort-chip:nth-child(2), .sort-chip:nth-child(3) { grid-column: span 2; }
    .sort-chip:nth-child(4), .sort-chip:nth-child(5) { grid-column: span 3; }
    
    /* Карточки в ландшафтном режиме */
    .cards-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px; 
    }
    
    .card { 
        grid-template-columns: 100px 1fr !important;
        min-height: 140px;
        max-height: 160px;
    }
    
    .card-photo-wrapper { 
        padding: 5px;
    }
    
    .card-content { 
        padding: 6px 6px 6px 8px;
        margin: 5px 5px 5px 0;
        height: calc(100% - 10px);
        min-height: 130px;
    }
    
    .card-name {
        font-size: 1rem;
    }
    
    .card-name .first-name {
        font-size: 1rem;
        margin-left: 6px;
    }
    
    .card-dates-row {
        padding: 2px 4px;
        gap: 2px;
        margin-bottom: 4px;
    }
    
    .date-item i.fa-star-of-david {
        font-size: 0.7rem;
        width: 12px;
    }
    
    .date-value {
        font-size: 0.7rem;
    }
    
    .date-arrow {
        width: 18px;
        height: 18px;
    }
    
    .date-arrow i {
        font-size: 0.7rem;
    }
    
    .loc-badge {
        padding: 2px 4px;
        font-size: 0.7rem;
        gap: 3px;
    }
    
    .loc-badge small {
        font-size: 0.6rem;
    }
    
    .card-header .btn-icon {
        width: 22px;
        height: 22px;
        font-size: 0.7rem;
    }
    
    /* ТАБЛИЦА В ЛАНДШАФТНОМ РЕЖИМЕ */
    table {
        font-size: 0.7rem;
    }
    
    th { 
        padding: 6px 2px 6px 6px;
        font-size: 0.7rem;
    }
    
    .th-sort-link { 
        font-size: 0.7rem;
        gap: 2px;
    }
    
    .th-sort-link i {
        font-size: 0.65rem;
    }
    
    td:nth-child(1), td:nth-child(2) {
        font-weight: 700;
        color: var(--primary-dark);
    }
    
    td { 
        padding: 5px 2px 5px 6px;
        font-size: 0.7rem;
    }
    
    .admin-mode th:nth-child(8), .admin-mode td:nth-child(8) {
        width: 15%;
    }
    
    .relatives-cell {
        font-size: 0.65rem;
    }
    
    .admin-mode th:nth-child(9), .admin-mode td:nth-child(9) {
        width: 8%;
    }
    
    .w-action { 
        width: 30px; 
    }
    
    .btn-icon {
        font-size: 0.7rem;
        padding: 2px;
    }
    
    tr.has-photo td:first-child {
        box-shadow: inset 2px 0 0 var(--photo-green-border);
    }
    
    .footer-content {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

/* ===== ВЕРТИКАЛЬНАЯ МОБИЛЬНАЯ ВЕРСИЯ (ПОРТРЕТ) ===== */
@media (max-width: 768px) and (orientation: portrait) {
    .view-switch { 
        display: none !important; 
    }
    
    #cardsView { display: block !important; }
    #tableView { display: none !important; }
    
    .sort-container { display: block !important; }
    .sort-chips-wrapper {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 5px;
    }
    .sort-chip { width: 100%; text-align: center; padding: 6px 2px; font-size: 0.7rem; }
    .sort-chip:nth-child(1), .sort-chip:nth-child(2), .sort-chip:nth-child(3) { grid-column: span 2; }
    .sort-chip:nth-child(4), .sort-chip:nth-child(5) { grid-column: span 3; }

    .container { padding: 0 8px; }
    .header-inner { flex-direction: column; gap: 8px; padding: 8px; }
    .search-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px; }
    
    .cards-grid { grid-template-columns: 1fr; gap: 12px; }
    
    .card { 
        grid-template-columns: 90px 1fr !important;
        min-height: 140px;
        max-height: 160px;
    }
    
    .card-photo-wrapper { padding: 5px; }
    .card-content { 
        padding: 5px 6px 5px 8px;
        margin: 5px 5px 5px 0;
        height: calc(100% - 10px);
        min-height: 130px;
    }
    
    .card-name {
        font-size: 1rem;
    }
    
    .card-name .first-name {
        font-size: 1rem;
        margin-left: 6px;
    }
    
    .card-dates-row {
        padding: 2px 4px;
    }
    
    .date-item i.fa-star-of-david {
        font-size: 0.7rem;
        width: 12px;
    }
    
    .date-value {
        font-size: 0.7rem;
    }
    
    .date-arrow {
        width: 18px;
        height: 18px;
    }
    
    .loc-badge {
        padding: 2px 4px;
        font-size: 0.7rem;
    }
    
    .card-header .btn-icon {
        width: 22px;
        height: 22px;
        font-size: 0.7rem;
    }
}

/* Общие стили для футера на мобильных */
@media (max-width: 768px) {
    .footer-content { 
        grid-template-columns: 1fr; 
        gap: 25px; 
        padding: 0 15px;
    }
    .footer-section { 
        text-align: center; 
    }
    .footer-contact p { 
        justify-content: center; 
        font-size: 0.85rem;
    }
    .footer-links { 
        align-items: center; 
    }
    .footer-lang-wrapper { 
        align-items: center; 
    }
    .footer-lang-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
	
	/* ================= ОТЧЁТЫ: ГАРАНТИРОВАННОЕ ЦЕНТРИРОВАНИЕ ================= */
    /* Переопределяет базовое th { text-align: left } для таблицы отчётов */

    .report-table th:nth-child(3),
    .report-table th:nth-child(4),
    .report-table th:nth-child(5),
    .report-table th:nth-child(6),
    .report-table th:nth-child(7) {
       text-align: center !important;
    }

    .report-table td:nth-child(3),
    .report-table td:nth-child(4),
    .report-table td:nth-child(5),
    .report-table td:nth-child(6),
    .report-table td:nth-child(7) {
        text-align: center !important;
    }

    /* Фамилия, имя и родственники — по левому краю */
    .report-table th:nth-child(1),
    .report-table th:nth-child(2),
    .report-table th:nth-child(8),
    .report-table td:nth-child(1),
    .report-table td:nth-child(2),
    .report-table td:nth-child(8) {
         text-align: left !important;
    }
	
	/* ================= ИСПРАВЛЕНИЕ ЦЕНТРИРОВАНИЯ ЗАГОЛОВКОВ ОТЧЁТА ================= */
    /* Проблема: .th-sort-link имеет display:flex, который игнорирует text-align родителя */

    .report-table th.center-col .th-sort-link,
    .report-table th.center-col a.th-sort-link {
        justify-content: center !important;
    }

    /* Для заголовков без ссылки (Notes) */
    .report-table th.center-col {
        text-align: center !important;
    }

    .report-table td.center-col {
        text-align: center !important;
    }
}