/* ========== Design Tokens ========== */
:root {
    --primary: #FF5A5F;
    --primary-dark: #E04850;
    --accent: #00A699;
    --bg: #FFFFFF;
    --bg-warm: #FFF8F6;
    --surface: #F7F7F7;
    --text: #222222;
    --text-secondary: #717171;
    --border: #DDDDDD;
    --border-light: #EBEBEB;
    --shadow: 0 2px 16px rgba(0,0,0,0.08);
    --shadow-hover: 0 6px 20px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --font-display: 'DM Serif Display', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========== Reset ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ========== Header ========== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
}
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo-mark {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
}
.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.logo-dot { color: var(--primary); }

.header-nav {
    display: flex;
    gap: 24px;
    align-items: center;
}
.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    transition: color 0.2s;
}
.nav-link:hover { color: var(--primary); }
.nav-phone {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    padding: 8px 16px;
    border-radius: 24px;
}

/* ========== Hero ========== */
.hero {
    background: var(--bg-warm);
    padding: 64px 0 48px;
}
.hero-title {
    font-family: var(--font-display);
    font-size: 3rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    color: var(--text);
}
.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 480px;
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: stretch;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 48px;
    overflow: hidden;
    box-shadow: var(--shadow);
    max-width: 720px;
}
.search-field {
    flex: 1;
    padding: 12px 20px;
    min-width: 0;
}
.search-field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
    margin-bottom: 2px;
}
.search-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0;
}
.search-divider {
    width: 1px;
    background: var(--border-light);
    align-self: stretch;
    margin: 12px 0;
}
.search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 24px;
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: background 0.2s;
}
.search-btn:hover { background: var(--primary-dark); }

/* ========== Apartments Section ========== */
.apartments-section {
    padding: 48px 0 64px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}
.section-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    letter-spacing: -0.01em;
}

/* Filter Chips */
.filter-chips {
    display: flex;
    gap: 8px;
}
.chip {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    transition: all 0.2s;
}
.chip:hover { border-color: var(--text); }
.chip.active {
    background: var(--text);
    color: white;
    border-color: var(--text);
}

/* Apartments Grid */
.apartments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

/* Apartment Card */
.card {
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s var(--ease), box-shadow 0.3s;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}
.card-img {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    border-radius: var(--radius);
}
.card-img-placeholder {
    width: 100%;
    aspect-ratio: 3 / 2;
    background: linear-gradient(135deg, var(--bg-warm), #ffe8e6);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.5;
}
.card-body {
    padding: 12px 2px 8px;
}
.card-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}
.card-name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
}
.card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}
.card-address {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.card-features {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.card-feature {
    display: flex;
    align-items: center;
    gap: 4px;
}
.card-price {
    font-weight: 700;
    font-size: 0.95rem;
}
.card-price span {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ========== Skeleton ========== */
.skeleton { pointer-events: none; }
.skeleton-img {
    width: 100%;
    aspect-ratio: 3 / 2;
    border-radius: var(--radius);
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s infinite;
}
.skeleton-text {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s infinite;
    margin-top: 12px;
    width: 80%;
}
.skeleton-text.short { width: 50%; }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== Detail Overlay ========== */
.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}
.detail-overlay.open {
    display: flex;
    opacity: 1;
}
.detail-panel {
    width: 100%;
    max-width: 1024px;
    max-height: 95vh;
    background: var(--bg);
    border-radius: 16px 16px 0 0;
    position: relative;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s var(--ease);
}
.detail-overlay.open .detail-panel {
    transform: translateY(0);
}
.detail-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: transform 0.15s;
}
.detail-close:hover { transform: scale(1.1); }
.detail-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

/* Gallery */
.detail-gallery {
    background: var(--surface);
}
.gallery-main {
    width: 100%;
}
.gallery-main > img,
.gallery-main > #galleryMainImg {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}
.gallery-thumbs {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
}
.gallery-thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
}
.gallery-thumb:hover { opacity: 0.9; }
.gallery-thumb.active { opacity: 1; border-color: var(--text); }

.gallery-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--primary);
    opacity: 0.3;
    background: linear-gradient(135deg, var(--bg-warm), #ffe8e6);
}

/* Detail Body */
.detail-body {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 48px;
    padding: 32px 32px 120px;
}
.detail-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    margin-bottom: 4px;
}
.detail-address {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 16px;
}
.detail-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 0.8rem;
    font-weight: 500;
}
.detail-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 24px;
}
.detail-features h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
}
.features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text);
}
.feature-item i { color: var(--text-secondary); }

/* Booking Card (sidebar) */
.booking-card {
    position: sticky;
    top: 80px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    height: fit-content;
}
.booking-price {
    margin-bottom: 20px;
}
.price-amount {
    font-size: 1.5rem;
    font-weight: 700;
}
.price-per {
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.booking-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 12px;
}
.booking-dates .booking-field:first-child {
    border-right: 1px solid var(--border);
}
.booking-field {
    padding: 10px 12px;
}
.booking-field label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}
.booking-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.875rem;
    color: var(--text);
    padding: 2px 0;
}
.booking-field:not(.booking-dates .booking-field) {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.price-breakdown {
    padding: 12px 0;
    margin-bottom: 12px;
}
.pb-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.9rem;
}
.pb-row.total {
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
    font-weight: 700;
}
.pb-row .underline {
    text-decoration: underline;
    color: var(--text);
}

.book-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s, transform 0.15s;
}
.book-btn:hover { background: var(--primary-dark); }
.book-btn:active { transform: scale(0.98); }
.book-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}
.modal-overlay.open { display: flex; opacity: 1; }
.modal-panel {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    background: var(--bg);
    border-radius: var(--radius-lg);
    position: relative;
    display: flex;
    flex-direction: column;
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.modal-close:hover { background: var(--border); }
.modal-scroll {
    overflow-y: auto;
    padding: 32px;
}
.modal-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 16px;
}
.modal-success {
    max-width: 480px;
    text-align: center;
}

/* Booking Form */
.booking-summary-mini {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}
.bsm-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}
.bsm-row strong { font-weight: 600; }

.form-section-label {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 24px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}
.form-section-label:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.optional {
    font-weight: 400;
    color: var(--text-secondary);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--text);
    box-shadow: 0 0 0 1px var(--text);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.payment-summary {
    background: #FEF7E0;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}
.ps-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.9rem;
}
.ps-row.accent { color: var(--accent); font-weight: 600; }

.terms-check {
    margin-bottom: 20px;
}
.terms-check label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    cursor: pointer;
    font-size: 0.85rem;
}
.terms-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
}

.submit-booking-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.15s;
}
.submit-booking-btn:hover { background: var(--primary-dark); }
.submit-booking-btn:active { transform: scale(0.98); }

/* Success */
.success-content { padding: 48px 32px; }
.success-check { margin-bottom: 16px; }
.success-content h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 8px;
}
.success-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}
.success-ref {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 24px;
}
.btn-outline {
    padding: 12px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-outline:hover { background: var(--surface); }

/* ========== Mobile Bottom Bar ========== */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 250;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    justify-content: space-between;
    align-items: center;
}
.mobile-bottom-bar.visible { display: flex; }
.mobile-price-amount { font-weight: 700; font-size: 1.1rem; }
.mobile-price-per { color: var(--text-secondary); font-size: 0.85rem; }
.mobile-book-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
}

/* ========== Footer ========== */
.site-footer {
    background: var(--surface);
    padding: 48px 0 32px;
    margin-top: 48px;
}
.footer-content {
    text-align: center;
}
.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    font-weight: 600;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 16px;
}
.footer-links a {
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--text); }
.footer-copy {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-hover);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: all;
}

/* ========== Responsive ========== */

/* Tablet */
@media (max-width: 960px) {
    .detail-body {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 24px;
    }
    .booking-card {
        position: static;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .hero { padding: 40px 0 32px; }
    .hero-title { font-size: 2rem; }
    .hero-subtitle { font-size: 1rem; }

    .search-bar {
        flex-direction: column;
        border-radius: var(--radius);
        overflow: visible;
    }
    .search-field { padding: 10px 16px; }
    .search-divider {
        width: 100%;
        height: 1px;
        margin: 0;
    }
    .search-btn {
        justify-content: center;
        padding: 14px;
        border-radius: 0 0 var(--radius) var(--radius);
    }
    .search-input { font-size: 16px; } /* prevent iOS zoom on focus */

    .apartments-grid {
        grid-template-columns: 1fr;
    }

    .section-header { flex-direction: column; align-items: flex-start; }
    .filter-chips { overflow-x: auto; width: 100%; }

    .header-nav .nav-link:first-child { display: none; }

    /* Detail panel fullscreen on mobile */
    .detail-overlay {
        align-items: stretch;
    }
    .detail-panel {
        max-height: 100vh;
        max-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }
    .detail-scroll {
        padding-bottom: 80px; /* space for mobile bar */
    }
    .detail-body {
        padding: 20px 16px 20px;
    }
    .features-grid { grid-template-columns: 1fr; }

    /* Show booking dates/guests inline on mobile (simplified) */
    .booking-card {
        display: block;
        position: static;
        border: none;
        box-shadow: none;
        padding: 16px 0;
        background: transparent;
    }
    .booking-card .booking-price { display: none; } /* shown in mobile bar */
    .booking-card .book-btn { display: none; }      /* shown in mobile bar */
    .booking-card .book-note { display: none; }

    .detail-overlay.open ~ .mobile-bottom-bar,
    .mobile-bottom-bar.visible { display: flex; }

    .modal-panel {
        max-width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .modal-scroll { padding: 24px 16px; }

    .form-row { grid-template-columns: 1fr; }
}

/* ========== Desktop hover image zoom ========== */
@media (hover: hover) {
    .card:hover .card-img {
        transform: scale(1.03);
    }
    .card .card-img {
        transition: transform 0.4s var(--ease);
    }
}
