/**
 * FaceMap - Шапка и навигация
 */

/* ===========================================
   ШАПКА
   =========================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    z-index: 999;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none; /* Позволяет кликать сквозь шапку на карту */
}

.header > * {
    pointer-events: auto; /* Элементы внутри шапки кликабельны */
}

/* ===========================================
   ЛОГОТИП
   =========================================== */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-icon {
    width: 50px;
    height: 68px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

/* ===========================================
   СЕЛЕКТОР СТРАН + ПОИСК
   =========================================== */
.country-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    position: relative;
}

.country-selector select {
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    padding-right: 20px;
    min-width: 140px;
}

.country-selector select:focus {
    outline: none;
}

.search-toggle-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-gray);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.search-toggle-btn:hover,
.search-toggle-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Панель поиска */
.search-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    display: none;
    z-index: 100;
}

.search-panel.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.search-panel .search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
}

.search-panel .search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
}

.search-result-item {
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.search-result-item:hover {
    background: var(--bg-gray);
}

.search-result-title {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.search-result-address {
    font-size: 12px;
    color: var(--text-light);
}

/* ===========================================
   БУРГЕР МЕНЮ
   =========================================== */
.burger-menu-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: white;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.burger-menu-btn:hover {
    transform: scale(1.05);
}

.burger-menu-btn.active {
    background: var(--primary-color);
    color: white;
}

.burger-menu-btn.has-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
    padding: 3px;
}

.burger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.burger-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.burger-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* Панель бургер меню */
.burger-menu-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 280px;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 12px;
    z-index: 1000;
    display: none;
}

.burger-menu-panel.show {
    display: block;
    animation: slideIn 0.2s ease;
}

/* Профиль в меню */
.menu-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-gray);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
}

.menu-profile-photo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
}

.menu-profile-name {
    font-weight: 600;
    color: var(--text-dark);
}

.menu-profile-role {
    font-size: 12px;
    color: var(--text-light);
}

/* Кнопки меню */
.menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.menu-btn:hover {
    background: var(--bg-gray);
}

.menu-btn-icon {
    font-size: 18px;
}

.menu-btn-badge {
    margin-left: auto;
    background: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 8px 0;
}

/* ===========================================
   ПАНЕЛЬ ИЗБРАННОГО
   =========================================== */
.favorites-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 360px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.favorites-panel.show {
    display: flex;
    animation: slideIn 0.2s ease;
}

.favorites-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.favorites-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.favorites-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    transition: all var(--transition-fast);
}

.favorites-close:hover {
    background: var(--danger-color);
    color: white;
}

.favorites-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.favorites-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.favorites-item:hover {
    background: var(--bg-gray);
}

.favorites-item-image {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.favorites-item-info {
    flex: 1;
    min-width: 0;
}

.favorites-item-title {
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorites-item-address {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorites-item-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
    margin-top: 4px;
}

.favorites-item-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.favorites-item-remove:hover {
    background: var(--danger-color);
    color: white;
}

.favorites-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
}

.favorites-footer .btn {
    flex: 1;
}

/* Счётчик избранного на кнопке */
.favorites-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===========================================
   ПУБЛИЧНАЯ ОФЕРТА
   =========================================== */
.offer-link-anchor {
    position: fixed;
    left: 18px;
    bottom: 22px;
    z-index: 930;
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.offer-link-anchor:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
}

.offer-modal {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(2, 6, 23, 0.58);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    box-sizing: border-box;
}

.offer-modal.show {
    display: flex;
}

.offer-modal-card {
    width: min(980px, calc(100vw - 24px));
    height: min(84vh, 820px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 50px rgba(15, 23, 42, 0.4);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.offer-modal-head {
    padding: 14px 56px 12px 18px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.offer-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.offer-modal-close:hover {
    background: #e2e8f0;
}

.offer-modal-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: #f8fafc;
}

/* ===========================================
   ЮРИДИЧЕСКАЯ ИНФОРМАЦИЯ
   =========================================== */
.legal-modal-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.legal-modal-card .offer-modal-head {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #ffffff;
}

.legal-modal-card .offer-modal-close {
    z-index: 7;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.legal-modal-nav {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    position: sticky;
    top: 51px;
    z-index: 3;
}

.legal-nav-btn {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.legal-nav-btn:hover {
    border-color: #94a3b8;
    color: #0f172a;
}

.legal-nav-btn.active {
    border-color: #6366f1;
    background: #eef2ff;
    color: #3730a3;
}

.legal-modal-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 14px;
    background: #f8fafc;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.legal-section {
    display: none;
}

.legal-section.show {
    display: block;
}

.legal-block-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 10px;
}

.legal-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legal-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    padding: 10px 12px;
}

.legal-row-label {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
}

.legal-row-value {
    font-size: 13px;
    line-height: 1.4;
    color: #0f172a;
    word-break: break-word;
}

.legal-row-value a {
    color: #1d4ed8;
    text-decoration: none;
}

.legal-row-value a:hover {
    text-decoration: underline;
}

.legal-offer-frame {
    width: 100%;
    min-height: min(62vh, 640px);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}

/* ===========================================
   WELCOME LIGHTBOX
   =========================================== */
.welcome-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2600;
    background: rgba(2, 6, 23, 0.64);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.welcome-lightbox.show {
    display: flex;
}

.welcome-lightbox-card {
    width: min(640px, calc(100vw - 24px));
    max-height: min(86vh, 760px);
    overflow-y: auto;
    background: linear-gradient(155deg, #0f172a 0%, #1e293b 46%, #312e81 100%);
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 18px 56px rgba(2, 6, 23, 0.45);
    border-radius: 22px;
    position: relative;
    padding: 22px 18px 18px;
    color: #e2e8f0;
}

.welcome-lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    color: #f8fafc;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.welcome-lightbox-close:hover {
    background: rgba(148, 163, 184, 0.34);
}

.welcome-lightbox-head {
    padding-right: 42px;
    margin-bottom: 14px;
}

.welcome-lightbox-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #93c5fd;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-lightbox-title {
    font-size: 24px;
    line-height: 1.2;
    color: #ffffff;
    font-weight: 800;
}

.welcome-lightbox-list {
    display: grid;
    gap: 10px;
}

.welcome-lightbox-item {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 12px;
    align-items: flex-start;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.36);
    padding: 12px;
}

.welcome-lightbox-index {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.24);
    border: 1px solid rgba(147, 197, 253, 0.45);
    color: #dbeafe;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-lightbox-item-title {
    font-size: 17px;
    line-height: 1.25;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 4px;
}

.welcome-lightbox-item-text {
    font-size: 14px;
    line-height: 1.45;
    color: #cbd5e1;
}

.welcome-lightbox-footer {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.welcome-lightbox-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    font-size: 13px;
    user-select: none;
    cursor: pointer;
}

.welcome-lightbox-checkbox input {
    width: 15px;
    height: 15px;
    accent-color: #3b82f6;
    cursor: pointer;
}

.welcome-lightbox-ok {
    border: 1px solid rgba(147, 197, 253, 0.5);
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    padding: 8px 14px;
    cursor: pointer;
}

.welcome-lightbox-ok:hover {
    filter: brightness(1.06);
}

/* ===========================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   =========================================== */
@media (max-width: 768px) {
    .header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .header > div:first-child {
        display: none; /* Скрываем пустой блок */
    }
    
    .header > div:last-child {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }
    
    .logo-icon {
        width: 40px;
        height: 55px;
    }
    
    .country-selector {
        padding: 6px 10px;
    }
    
    .country-selector select {
        min-width: 100px;
        font-size: 13px;
    }
    
    .burger-menu-btn {
        width: 40px;
        height: 40px;
    }
    
    .burger-menu-panel {
        top: 60px;
        right: 15px;
        left: auto;
        width: 260px;
        bottom: auto;
    }

    .offer-link-anchor {
        left: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        padding: 7px 11px;
        font-size: 12px;
    }

    .offer-modal {
        padding: 8px;
    }

    .offer-modal-card {
        width: calc(100vw - 12px);
        height: min(90vh, 860px);
        border-radius: 12px;
    }

    .offer-modal-head {
        font-size: 16px;
        padding: 12px 50px 10px 12px;
    }

    .offer-modal-close {
        top: 8px;
        right: 8px;
    }

    .legal-modal-card .offer-modal-close {
        top: 6px;
        right: 6px;
        width: 36px;
        height: 36px;
        z-index: 8;
    }

    .legal-modal-card {
        width: calc(100vw - 8px);
        max-width: calc(100vw - 8px);
        height: calc(100dvh - 8px - env(safe-area-inset-top));
        max-height: calc(100dvh - 8px - env(safe-area-inset-top));
        border-radius: 14px;
    }

    .legal-modal-card .offer-modal-head {
        font-size: 15px;
        padding: 12px 52px 10px 12px;
    }

    .legal-modal-nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: visible;
        padding: 8px 8px;
        gap: 6px;
        top: 46px;
    }

    .legal-modal-nav::-webkit-scrollbar {
        display: none;
    }

    .legal-nav-btn {
        min-height: 40px;
        white-space: normal;
        font-size: 12px;
        line-height: 1.2;
        padding: 7px 8px;
    }

    .legal-modal-content {
        padding: 10px;
        padding-bottom: calc(18px + env(safe-area-inset-bottom));
    }

    .legal-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 9px 10px;
    }

    .legal-row-label {
        font-size: 11px;
    }

    .legal-row-value {
        font-size: 12px;
    }

    .legal-offer-frame {
        min-height: calc(100dvh - 240px);
    }

    .welcome-lightbox {
        padding: 10px;
    }

    .welcome-lightbox-card {
        width: calc(100vw - 12px);
        max-height: calc(100dvh - 16px - env(safe-area-inset-top));
        border-radius: 16px;
        padding: 16px 12px 14px;
    }

    .welcome-lightbox-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
    }

    .welcome-lightbox-head {
        margin-bottom: 10px;
        padding-right: 38px;
    }

    .welcome-lightbox-kicker {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .welcome-lightbox-title {
        font-size: 20px;
    }

    .welcome-lightbox-item {
        grid-template-columns: 28px 1fr;
        gap: 10px;
        padding: 10px;
        border-radius: 12px;
    }

    .welcome-lightbox-index {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }

    .welcome-lightbox-item-title {
        font-size: 15px;
        margin-bottom: 3px;
    }

    .welcome-lightbox-item-text {
        font-size: 13px;
    }

    .welcome-lightbox-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .welcome-lightbox-checkbox {
        font-size: 12px;
    }

    .welcome-lightbox-ok {
        width: 100%;
        min-height: 38px;
        font-size: 12px;
    }
}
