:root {
    /* Фірмові кольори PrivatGroup */
    --primary: #3C4A45; /* Темний графіт/зелений */
    --primary-light: #52635d; 
    --accent: #FDA122; /* Помаранчевий */
    --surface: #f1f5f9;
    --surface-card: #ffffff;
    --text-main: #0f172a;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --splash-bg: #3C4A45;
}

/* PWA Splash: html і body починаються темними — жодного білого спалаху */
html {
    background-color: var(--splash-bg);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Play', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--surface);
    color: var(--text-main);
    padding-bottom: 70px;
    /* Плавна поява після завантаження */
    animation: appFadeIn 0.4s ease forwards;
}

@keyframes appFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ===== PWA SPLASH SCREEN ===== */
/* Оверлей що показується поки додаток завантажується */
#splash-screen {
    position: fixed;
    inset: 0;
    background: var(--splash-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Обгортка іконки — дає тінь і анімацію пульсу */
.splash-icon-wrap {
    width: 110px;
    height: 110px;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.08);
    animation: splashPulse 2s ease-in-out infinite;
}

#splash-screen .splash-logo {
    width: 110px;
    height: 110px;
    object-fit: cover;
    display: block;
}

#splash-screen .splash-name {
    color: rgba(255,255,255,0.9);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

#splash-screen .splash-tagline {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    font-weight: 400;
}

#splash-screen .splash-bar {
    width: 120px;
    height: 3px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    overflow: hidden;
}

#splash-screen .splash-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    animation: splashLoad 1.2s ease forwards;
}

@keyframes splashPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.85; }
}

@keyframes splashLoad {
    from { width: 0%; }
    to   { width: 100%; }
}

/* App Bar */
.app-bar {
    position: fixed;
    top: 0;
    width: 100%;
    height: 60px;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
}

.app-logo {
    height: 40px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* white logo */
}

#app-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: white;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-btn {
    cursor: pointer;
    font-size: 24px;
    transition: opacity 0.2s;
}

.header-btn:active {
    opacity: 0.6;
}

.app-bar .back-btn {
    display: none;
    color: white;
    cursor: pointer;
}

/* Loading */
#loader {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60vh;
    flex-direction: column;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Listings Container */
.page {
    display: none; /* SPA logic */
    animation: fadeIn 0.3s ease;
    padding-top: 60px;
}

/* Home page: extra padding for sort bar (60px app-bar + 52px sort-bar) */
#page-home {
    padding-top: 112px;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.listings {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 20px;
}

/* Card Design */
.card {
    background: var(--surface-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.card:active {
    transform: scale(0.98);
}

.card-image-wrap {
    position: relative;
    height: 240px;
    background: #cbd5e1;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    display: flex;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.card-image-wrap::-webkit-scrollbar {
    display: none;
}

.card-image-slide {
    flex: 0 0 100%;
    height: 100%;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.5s cubic-bezier(0.1, 0.4, 0.2, 1);
    transform: scale(1.0);
}

.card.in-view .card-image {
    transform: scale(1.12); /* більш виражений ефект */
}

.badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

.badge-hot {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.card-content {
    padding: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-code {
    font-size: 14px;
    color: var(--text-secondary);
}

.price-wrap {
    text-align: right;
}

.price {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.price-secondary {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
    font-weight: 600;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 16px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 8px;
    margin-bottom: 16px;
}

.details-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-main);
}

.details-item .material-icons {
    color: var(--accent);
    font-size: 18px;
}

.details-item span {
    color: var(--text-secondary);
}



/* Bottom Nav - Scrollable */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--surface-card);
    border-top: 1px solid var(--border);
    display: flex;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding: 6px 4px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    z-index: 100;
    gap: 0;
}
.bottom-nav::-webkit-scrollbar { display: none; }

.bottom-nav.hidden {
    display: none;
}

.nav-item {
    flex: 0 0 64px;       /* фіксована ширина, не стискається */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 9px;
    font-weight: 600;
    padding: 5px 0;
    border-radius: 10px;
    transition: color 0.2s, background 0.15s;
    cursor: pointer;
}

.nav-item.active {
    color: var(--primary);
    background: rgba(60, 74, 69, 0.07);
}

.nav-item:active {
    background: rgba(60, 74, 69, 0.12);
}

.nav-item .material-icons {
    font-size: 22px;
}

/* Object Detail View */
.detail-gallery {
    width: 100%;
    height: 300px;
    overflow-x: auto;
    display: flex;
    scroll-snap-type: x mandatory;
    background: #cbd5e1;
}

.detail-gallery img {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    scroll-snap-align: center;
}

.detail-content {
    padding: 20px;
    background: white;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    margin-top: -24px;
    position: relative;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
}

.detail-price {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.detail-price-secondary {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 12px;
    font-weight: 600;
}

.detail-street {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    gap: 16px 8px;
}

.info-block {
    text-align: center;
}

.info-block span {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.info-block strong {
    font-size: 14px;
    color: var(--text-main);
}

/* Realtor Card */
.realtor-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f8fafc;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-top: 24px;
}

.realtor-avatar, .realtor-photo {
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    color: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    overflow: hidden;
}

.realtor-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.realtor-avatar .material-icons {
    font-size: 32px;
}

.realtor-info {
    flex: 1;
}

.realtor-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.realtor-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.realtor-bio {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 4px;
}

.detail-desc {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-main);
    white-space: pre-line;
    margin-bottom: 80px; /* Space for action button */
}

/* Action Bar Bottom */
.action-bar {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: white;
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    display: flex;
    gap: 12px;
    z-index: 101;
}

.btn-contact {
    flex: 1;
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    width: 100%;
    padding: 20px 16px;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.open .modal-content {
    transform: translateY(0);
}

.contact-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.contact-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
}

.btn-viber { background: #7360f2; color: white; }
.btn-telegram { background: #0088cc; color: white; }
.btn-phone { background: var(--primary); color: white; }

/* Styles for filters */
.filter-group { margin-bottom: 12px; }
.filter-group label { display: block; font-weight: 700; margin-bottom: 6px; color: var(--text-main); font-size: 14px; }

/* Two-column row (price, floor) */
.filter-row-2 {
    display: flex;
    gap: 10px;
    width: 100%;
}
.filter-input-half {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
}
.filter-select {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: inherit;
    font-size: 13px;
    background: white;
    box-sizing: border-box;
}

/* Share Modal */
.share-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 16px;
}
.share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
}
.share-item-code {
    font-weight: 800;
    color: var(--primary);
    font-size: 15px;
    min-width: 55px;
}
.share-item-title {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.share-actions {
    display: flex;
    gap: 10px;
}
.share-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.15s;
}
.share-action-btn:active { transform: scale(0.95); }
.share-action-btn .material-icons { font-size: 24px; }
.share-btn-main { background: var(--primary); color: white; }
.share-btn-copy { background: var(--surface); color: var(--primary); border: 1px solid var(--border); }
.share-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 14px;
}


.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-group input[type="radio"] { display: none; }
.radio-group label {
    padding: 8px 16px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
    margin-bottom: 0;
    user-select: none;
}
.radio-group input[type="radio"]:checked + label {
    background-color: var(--primary);
    color: white;
}

/* Categories removed — now in bottom-nav */

.filter-reset-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    margin: 8px 20px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.filter-reset-bar span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.filter-reset-bar button {
    background: var(--primary-light);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

/* Adjust listings for bottom nav */
.listings {
    padding-bottom: 80px !important;
}

/* Favorite button on card */
.card-fav-btn {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 3;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.15s;
}
/* Badge for Operation (Sale/Rent) */
.badge-op {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.badge-op.sale { background: var(--accent); }
.badge-op.rent { background: var(--primary); }

/* Badge for NEW listings */
.badge-new {
    position: absolute;
    top: 42px;
    left: 10px;
    z-index: 3;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    background: #facc15;
    color: #000;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ===== FAVORITE COUNT BADGE ===== */
.header-btn-wrap {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.fav-badge {
    position: absolute;
    top: -7px;
    right: -9px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-family: inherit;
    line-height: 1;
    border: 2px solid var(--primary);
}

.fav-badge.visible {
    display: flex;
}

/* ===== SORT BAR ===== */
.sort-bar {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--surface-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    z-index: 99;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sort-bar::-webkit-scrollbar { display: none; }

.sort-bar.hidden { display: none; }

.sort-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}
.sort-btn .material-icons { font-size: 14px; }
.sort-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== PRICE DROP INDICATOR ===== */
.price-drop {
    font-size: 11px;
    color: #16a34a;
    font-weight: 700;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 2px;
    justify-content: flex-end;
}

/* ===== FULLSCREEN GALLERY ===== */
.fg-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fg-overlay.open {
    display: flex;
}

.fg-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: env(safe-area-inset-top, 16px) 20px 20px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.fg-counter {
    color: white;
    font-size: 15px;
    font-weight: 700;
    background: rgba(0,0,0,0.4);
    padding: 4px 12px;
    border-radius: 20px;
}

.fg-close-btn {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.fg-track {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
    will-change: scroll-position;
    /* Плавний скрол на iOS */
    -webkit-overflow-scrolling: touch;
}

.fg-track::-webkit-scrollbar {
    display: none;
}

.fg-slide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    scroll-snap-align: start;
}

.fg-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.fg-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}
.fg-nav:active { background: rgba(255,255,255,0.3); }
.fg-prev { left: 12px; }
.fg-next { right: 12px; }

/* Tap on gallery image shows pointer */
.detail-gallery img { cursor: zoom-in; }
