/* ============================================
   МОДАЛЬНОЕ ОКНО + ПРОФИЛЬ (для auth.php)
============================================ */

/* ----- Модальное окно ----- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}
.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 440px;
    width: 100%;
    padding: 30px 25px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalFadeIn 0.3s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0 4px;
}
.modal-close:hover {
    color: #1a472a;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 25px;
    background: #f1f3f5;
    padding: 4px;
    border-radius: 30px;
}
.tab-btn {
    flex: 1;
    padding: 12px 0;
    border: none;
    background: transparent;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: #495057;
    text-align: center;
    min-width: 0;
}
.tab-btn.active {
    background: #1a472a;
    color: white;
}
.tab-btn:hover:not(.active) {
    background: #e2e6ea;
}

.form {
    display: none;
}
.form.active {
    display: block;
}

.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.95rem;
    color: #1e293b;
}
.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.form-group input:focus {
    border-color: #1a472a;
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 71, 42, 0.15);
}
.form-group small {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 0.85rem;
}

/* ----- Стили для ссылок на «Дела земельные» ----- */
.form-group small a[href*="delazemelnii.ru"],
.footer-note a[href*="delazemelnii.ru"],
.demo-info a[href*="delazemelnii.ru"] {
    color: #1a472a;
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s, text-decoration 0.2s;
}
.form-group small a[href*="delazemelnii.ru"]:hover,
.footer-note a[href*="delazemelnii.ru"]:hover,
.demo-info a[href*="delazemelnii.ru"]:hover {
    color: #0f2f1b;
    text-decoration: none;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #1a472a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 5px;
}
.btn-primary:hover {
    background: #0f2f1b;
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-secondary:hover {
    background: #c82333;
}

.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
}
.message.error {
    background: #ffebee;
    color: #b71c1c;
}
.message.success {
    background: #e8f5e9;
    color: #1b5e20;
}

.forgot-link {
    background: none;
    border: none;
    color: #1a472a;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    display: inline-block;
}
.forgot-link:hover {
    color: #0f2f1b;
}

.reset-block {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}
.reset-block.visible {
    display: block;
}

.remember-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #4caf50;
}
input:checked + .slider:before {
    transform: translateX(22px);
}
.slider.round {
    border-radius: 26px;
}
.slider.round:before {
    border-radius: 50%;
}
.toggle-label {
    font-weight: normal;
    cursor: pointer;
    user-select: none;
    margin-left: 5px;
    color: #1e293b;
}

.footer-note {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: #777;
}
.footer-note a {
    color: #1a472a;
    text-decoration: none;
}
.footer-note a:hover {
    text-decoration: underline;
}

/* ----- Блок профиля для авторизованных ----- */
.profile-page {
    min-height: 60vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px 16px 48px;
    box-sizing: border-box;
}
.profile-container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
    background: #fff;
    padding: 28px 24px 32px;
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(26, 71, 42, 0.10);
    border: 1px solid rgba(26, 71, 42, 0.08);
    box-sizing: border-box;
}
.profile-avatar {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(145deg, #e8f5ee, #d4ebe0);
    border: 2px solid rgba(26, 71, 42, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    line-height: 1;
}
.profile-container h1 {
    margin: 0 0 16px;
    color: #1a472a;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.profile-meta {
    margin: 0 0 18px;
}
.profile-email-line {
    margin: 0 0 14px;
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.45;
}
.profile-container .email {
    display: inline-block;
    margin-top: 4px;
    font-weight: 700;
    color: #1a472a;
    font-size: 1.05rem;
    word-break: break-all;
}
.profile-balance-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 0 auto;
    padding: 12px 16px;
    max-width: 100%;
    background: linear-gradient(180deg, #f3faf6 0%, #eaf6f0 100%);
    border: 1px solid rgba(26, 71, 42, 0.12);
    border-radius: 12px;
}
.profile-balance-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #5a7a66;
    font-weight: 600;
}
.profile-balance-value {
    color: #1a472a;
    font-weight: 700;
    font-size: 0.98rem;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
    margin: 4px auto 0;
}

.profile-actions-divider {
    width: 48%;
    height: 1px;
    margin: 2px auto;
    background: linear-gradient(90deg, transparent, rgba(26, 71, 42, 0.18), transparent);
}

.profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.98rem;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    font-family: inherit;
}
.profile-btn-primary {
    background: #1a472a;
    color: #fff;
    border-color: #1a472a;
    box-shadow: 0 2px 8px rgba(26, 71, 42, 0.22);
}
.profile-btn-primary:hover {
    background: #0f2f1b;
    border-color: #0f2f1b;
    color: #fff;
}
.profile-btn-outline {
    background: #fff;
    color: #1a472a;
    border-color: rgba(26, 71, 42, 0.35);
}
.profile-btn-outline:hover {
    background: #f3faf6;
    border-color: #1a472a;
}
.profile-btn-danger {
    background: #fff;
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.35);
}
.profile-btn-danger:hover {
    background: #fef2f2;
    border-color: #b91c1c;
}
.profile-btn-ghost {
    background: transparent;
    color: #4b5563;
    border-color: #e5e7eb;
    font-weight: 500;
    font-size: 0.9rem;
}
.profile-btn-ghost:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1a472a;
}

.auth-alert {
    margin: 0 auto 14px;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.92rem;
    line-height: 1.4;
    text-align: center;
}
.auth-alert-ok {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.auth-alert-err {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.change-password-box {
    display: none;
    margin: 18px auto 0;
    width: 100%;
    max-width: 280px;
    padding: 16px 14px 14px;
    text-align: left;
    background: #f8faf9;
    border: 1px solid rgba(26, 71, 42, 0.1);
    border-radius: 12px;
    box-sizing: border-box;
}
.change-password-box.is-open {
    display: block;
}
.change-password-box .profile-btn {
    margin-left: auto;
    margin-right: auto;
}
.change-password-title {
    margin: 0 0 12px;
    text-align: center;
    color: #1a472a;
    font-size: 1.05rem;
    font-weight: 700;
}
.change-password-form .form-field {
    margin-bottom: 10px;
}
.change-password-form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.88rem;
    color: #374151;
}
.change-password-form input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.change-password-form input[type="password"]:focus {
    outline: none;
    border-color: #1a472a;
    box-shadow: 0 0 0 3px rgba(26, 71, 42, 0.12);
}
.change-password-form .profile-btn {
    margin-top: 4px;
}
.change-password-reset-form {
    margin-top: 10px;
}

@media (max-width: 480px) {
    .profile-container {
        padding: 22px 16px 26px;
        border-radius: 14px;
    }
    .profile-actions,
    .change-password-box {
        max-width: 100%;
    }
}

/* ============================================
   ПЕРЕОПРЕДЕЛЕНИЕ СТИЛЕЙ ПОИСКА (из style.css)
   — широкое поле, компактные кнопки, выравнивание
============================================ */
.card .search-box,
.search-box {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    align-items: center !important;
}

.card .search-box .search-input,
.search-box .search-input {
    flex: 1 1 auto !important;
    min-width: 300px !important;
    padding: 10px 14px !important;
    font-size: 1rem !important;
    border: 1px solid #ced4da !important;
    border-radius: 8px !important;
    background: white !important;
    width: auto !important;
    vertical-align: middle !important;
}

.card .search-box .btn,
.search-box .btn {
    padding: 8px 20px !important;
    font-size: 0.95rem !important;
    line-height: 1.4 !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    vertical-align: middle !important;
    margin: 0 !important;
    height: auto !important;
}

/* ----- адаптивность для поиска ----- */
@media (max-width: 768px) {
    .card .search-box,
    .search-box {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .card .search-box .search-input,
    .search-box .search-input {
        min-width: 0 !important;
        width: 100% !important;
    }
    .card .search-box .btn,
    .search-box .btn {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* ===== Анимация загрузки страницы ===== */
.critical-css {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}
@keyframes fadeIn {
    to { opacity: 1; }
}

/* ===== Адаптивность для модалки ===== */
@media (max-width: 480px) {
    .modal {
        padding: 20px 16px;
    }
    .tabs {
        gap: 6px;
        padding: 3px;
        border-radius: 25px;
    }
    .tab-btn {
        padding: 10px 0;
        font-size: 0.85rem;
        flex: 1 1 50%;
    }
    .form-group input {
        padding: 12px 14px;
        font-size: 1rem;
    }
    .btn-primary,
    .btn-secondary {
        padding: 14px;
        font-size: 1rem;
    }
    .forgot-link {
        font-size: 0.85rem;
    }
    .footer-note {
        font-size: 0.8rem;
    }
}
@media (max-width: 380px) {
    .tab-btn {
        font-size: 0.75rem;
        padding: 8px 0;
    }
}