/* ========================================
   TRỌ CẦN THƠ - Mobile-First CSS
   Premium Design System
   ======================================== */

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Colors */
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: rgba(79, 70, 229, 0.08);
    --accent: #ef4444;
    --accent-soft: #fca5a5;
    --green: #10b981;
    --green-soft: #d1fae5;
    --green-bg: rgba(16, 185, 129, 0.08);
    --purple: #8b5cf6;
    --purple-bg: rgba(139, 92, 246, 0.1);
    --orange: #f97316;

    /* Neutrals */
    --bg: #f0f4f8;
    --card: #ffffff;
    --text: #1e293b;
    --text-sec: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.04);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);

    /* Radii */
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --radius-full: 9999px;

    /* Typography */
    --font: 'Be Vietnam Pro', 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Inter', 'Be Vietnam Pro', system-ui, sans-serif;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 0.2s var(--ease);
    --transition-slow: 0.35s var(--ease);
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    overflow-x: hidden;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

/* === HEADER === */
.app-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
    padding: 24px 20px 36px;
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -25%;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.app-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -15%;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, rgba(129,140,248,0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.header-content {
    position: relative;
    z-index: 1;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: #fff;
}

.header-title h1 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
    font-weight: 400;
    margin-top: 3px;
    letter-spacing: 0.02em;
}

.header-wave {
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    line-height: 0;
}

.header-wave svg {
    width: 100%;
    height: 28px;
    display: block;
}

/* === SEARCH === */
.search-section {
    padding: 0 16px;
    margin-top: -16px;
    position: relative;
    z-index: 5;
}

.search-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    padding: 0 16px;
    border: 1.5px solid transparent;
    transition: all var(--transition);
}

.search-wrapper:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(79,70,229,0.1), var(--shadow-lg);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

#searchInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 15px 12px;
    font-family: var(--font);
    font-size: 0.93rem;
    color: var(--text);
    background: transparent;
    min-width: 0;
}

#searchInput::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.clear-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.clear-btn:active {
    background: var(--border);
    color: var(--text-sec);
}

.clear-btn svg {
    width: 18px;
    height: 18px;
}

.clear-btn.visible {
    display: flex;
}

/* === FILTERS === */
.filters-section {
    padding: 18px 0 6px;
}

.filter-group {
    margin-bottom: 12px;
}

.filter-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-sec);
    padding: 0 18px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 16px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex-shrink: 0;
    padding: 9px 16px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--border);
    background: white;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-sec);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    scroll-snap-align: start;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.chip::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.04);
    opacity: 0;
    transition: opacity var(--transition);
}

.chip:active::before {
    opacity: 1;
}

.chip:active {
    transform: scale(0.95);
}

/* Price chips active */
.chip-price.active {
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(239, 68, 68, 0.35);
    font-weight: 600;
}

/* School chips active */
.chip-school.active {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(139, 92, 246, 0.35);
    font-weight: 600;
}

/* Amenity chips active */
.chip-amenity.active {
    background: linear-gradient(135deg, #10b981, #14b8a6);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.35);
    font-weight: 600;
}

/* === TOOLBAR === */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px 14px;
    position: sticky;
    top: 0;
    background: rgba(240, 244, 248, 0.85);
    z-index: 10;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.results-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.results-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sec);
    white-space: nowrap;
}

.clear-all-btn {
    font-size: 0.72rem;
    color: var(--accent);
    background: rgba(239, 68, 68, 0.08);
    border: none;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.clear-all-btn:active {
    background: rgba(239, 68, 68, 0.18);
    transform: scale(0.95);
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--border-light);
    padding: 3px;
    border-radius: var(--radius-sm);
}

.view-btn {
    width: 36px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.view-btn svg {
    width: 17px;
    height: 17px;
}

.view-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.view-btn:not(.active):active {
    background: rgba(0,0,0,0.04);
}

/* === LISTINGS CONTAINER === */
.listings-container {
    padding: 0 12px 24px;
    min-height: 200px;
}

/* Grid View */
.listings-container.grid-view {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* List View */
.listings-container.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === CARDS BASE === */
.listing-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    animation: fadeInUp 0.45s var(--ease) both;
}

.listing-card:active {
    transform: scale(0.97);
}

/* Staggered animation */
.listing-card:nth-child(1) { animation-delay: 0.00s; }
.listing-card:nth-child(2) { animation-delay: 0.04s; }
.listing-card:nth-child(3) { animation-delay: 0.08s; }
.listing-card:nth-child(4) { animation-delay: 0.12s; }
.listing-card:nth-child(5) { animation-delay: 0.16s; }
.listing-card:nth-child(6) { animation-delay: 0.20s; }
.listing-card:nth-child(7) { animation-delay: 0.24s; }
.listing-card:nth-child(8) { animation-delay: 0.28s; }
.listing-card:nth-child(n+9) { animation-delay: 0.30s; }

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

/* === GRID CARD === */
.grid-view .listing-card {
    display: flex;
    flex-direction: column;
}

.grid-view .card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.grid-view .card-body {
    padding: 10px 10px 12px;
}

/* Hide extras in grid view */
.grid-view .card-summary,
.grid-view .card-meta,
.grid-view .card-links {
    display: none;
}

.grid-view .card-tags {
    max-height: 24px;
    overflow: hidden;
}

/* === LIST CARD === */
.list-view .listing-card {
    display: flex;
    flex-direction: row;
}

.list-view .card-image {
    position: relative;
    width: 120px;
    flex-shrink: 0;
    aspect-ratio: 9 / 16;
    overflow: hidden;
}

.list-view .card-body {
    flex: 1;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

/* === IMAGE PLACEHOLDER === */
.card-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Decorative pattern */
.card-image-placeholder::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(255,255,255,0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 50%);
    pointer-events: none;
}

.placeholder-icon {
    font-size: 2.4rem;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.15));
    z-index: 1;
}

.list-view .placeholder-icon {
    font-size: 1.8rem;
}

/* Real image loaded from Facebook */
.card-image-real {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    animation: fadeInImg 0.4s ease;
}

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

/* Gradient themes */
.grad-green  { background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%); }
.grad-teal   { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.grad-blue   { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.grad-purple { background: linear-gradient(135deg, #c471f5 0%, #fa71cd 100%); }
.grad-pink   { background: linear-gradient(135deg, #f5576c 0%, #ff8a5c 100%); }
.grad-orange { background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); }
.grad-coral  { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); }
.grad-sky    { background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%); }

/* Badges */
.badge-available {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(16, 185, 129, 0.92);
    color: white;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    z-index: 2;
}

.badge-commission-img {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.95), rgba(245, 158, 11, 0.9));
    color: #78350f;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    z-index: 2;
}

/* === CARD BODY === */
.card-title {
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.grid-view .card-title {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
}

.card-summary {
    font-size: 0.75rem;
    color: var(--text-sec);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.card-price-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px;
    margin-bottom: 3px;
}

.card-price {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.95rem;
    line-height: 1.3;
}

.grid-view .card-price {
    font-size: 0.85rem;
}

.card-price-suffix {
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--text-muted);
}

.card-area {
    font-size: 0.73rem;
    color: var(--text-sec);
    margin-left: 6px;
    font-weight: 500;
}

.card-location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.card-location svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: var(--accent);
}

.grid-view .card-location {
    font-size: 0.68rem;
}

/* Tags */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 7px;
}

.card-tag {
    font-size: 0.6rem;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.5;
}

.tag-school {
    background: var(--purple-bg);
    color: #7c3aed;
}

.tag-amenity {
    background: var(--green-bg);
    color: #059669;
}

/* Meta info */
.card-meta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.card-meta-item {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
}

/* Links */
.card-links {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.card-link {
    font-size: 0.7rem;
    padding: 5px 10px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.card-link:active {
    transform: scale(0.95);
}

.external-link-btn:active {
    transform: scale(0.95);
}

.copy-desc-btn {
    background: var(--bg);
    border: 1px solid var(--border-light);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.copy-desc-btn:active {
    transform: scale(0.95);
    background: #e0e7ff;
}

.detail-map-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #d1d5db;
    color: var(--text);
    text-decoration: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    transition: transform 0.2s;
}

.detail-map-btn:active {
    transform: scale(0.96);
    background: #f9fafb;
}

.card-link-detail {
    background: var(--primary-bg);
    color: var(--primary);
}

.card-link-map {
    background: var(--green-bg);
    color: var(--green);
}

.card-link-photo {
    background: rgba(249, 115, 22, 0.08);
    color: var(--orange);
}


/* Share button */
.share-btn {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(79, 70, 229, 0.08));
    color: var(--primary) !important;
    border: none;
    cursor: pointer;
    font-family: var(--font);
}

.share-btn:active {
    transform: scale(0.92);
}

.share-copied {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.10)) !important;
    color: var(--green) !important;
}

/* === LOADING SKELETON === */
.loading-state {
    padding: 0 12px;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.skeleton-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.skeleton-img {
    aspect-ratio: 1;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: shimmer 1.8s infinite ease-in-out;
}

.skeleton-body {
    padding: 12px;
}

.skeleton-text {
    height: 11px;
    margin-bottom: 8px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: shimmer 1.8s infinite ease-in-out;
}

.skeleton-text.short {
    width: 70%;
}

.skeleton-text.shorter {
    width: 45%;
    margin-bottom: 0;
}

@keyframes shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* === NO RESULTS === */
.no-results {
    text-align: center;
    padding: 60px 24px;
}

.no-results-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    display: block;
}

.no-results h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.no-results p {
    font-size: 0.85rem;
    color: var(--text-sec);
    line-height: 1.5;
}

/* === ERROR STATE === */
.error-state {
    text-align: center;
    padding: 60px 24px;
}

.error-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    display: block;
}

.error-state h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.error-state p {
    font-size: 0.85rem;
    color: var(--text-sec);
    margin-bottom: 20px;
    line-height: 1.5;
}

.retry-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius-full);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    -webkit-tap-highlight-color: transparent;
}

.retry-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* === FOOTER === */
.app-footer {
    text-align: center;
    padding: 24px 16px 36px;
}

.app-footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.footer-sub {
    font-size: 0.68rem !important;
    margin-top: 4px;
    font-weight: 400 !important;
    opacity: 0.7;
}

/* === RESPONSIVE === */

/* Larger phones */
@media (min-width: 400px) {
    .grid-view {
        gap: 12px;
    }

    .card-title {
        font-size: 0.9rem;
    }

    .grid-view .card-title {
        font-size: 0.84rem;
    }

    .list-view .card-image {
        width: 130px;
    }
}

/* Tablet */
@media (min-width: 768px) {
    html {
        font-size: 16px;
    }

    .listings-container.grid-view {
        grid-template-columns: repeat(3, 1fr);
    }

    .listing-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-lg);
    }

    .chip:hover {
        border-color: var(--text-muted);
        background: var(--border-light);
    }

    .chip-price.active:hover,
    .chip-school.active:hover,
    .chip-amenity.active:hover {
        border-color: transparent;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    #app {
        max-width: 600px;
    }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .app-footer {
        padding-bottom: calc(36px + env(safe-area-inset-bottom));
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* === DETAIL MODAL === */
.detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
}

.detail-modal.active {
    transform: translateX(0);
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 2;
}

.close-detail-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--primary);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 8px 0;
    width: 80px;
    -webkit-tap-highlight-color: transparent;
}

.close-detail-btn svg {
    width: 20px;
    height: 20px;
}

.detail-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #e9ebee; /* Facebook background color */
    position: relative;
}

.detail-iframe-container {
    width: 100%;
    height: 100%;
}

.detail-view-scroll {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    min-height: 100%;
    padding-bottom: 80px;
}

.detail-hero {
    width: 100%;
    max-height: 65vh;
    aspect-ratio: 9/16;
    position: relative;
    background: #000; /* Black background for letterboxing portrait images */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* CAROUSEL */
.carousel-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    height: 100%;
    scrollbar-width: none; /* Firefox */
}

.carousel-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.carousel-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    position: relative;
}

.carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 6px;
    z-index: 2;
    pointer-events: none;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: background 0.3s, transform 0.3s;
}

.carousel-dot.active {
    background: white;
    transform: scale(1.2);
}

.download-img-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2);
    z-index: 2;
}

.detail-full-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    background: linear-gradient(135deg, var(--indigo) 0%, var(--primary) 100%);
    color: white;
}

.detail-price-badge {
    position: absolute;
    bottom: 12px;
    left: 16px;
    background: rgba(16, 185, 129, 0.95);
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-weight: 800;
    font-size: 1.1rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.detail-body {
    padding: 20px 16px;
}

.detail-title-text {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.3;
}

.detail-commission {
    display: inline-flex;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #b45309;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.detail-commission strong {
    color: #92400e;
    margin-left: 6px;
}

.detail-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.spec-item {
    background: var(--bg);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-location {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 20px;
}

.detail-desc {
    margin-bottom: 24px;
}

.detail-desc h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text);
}

.detail-desc p {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.95rem;
}

.detail-actions {
    padding: 0 16px 20px;
}

.detail-fb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #1877F2; /* Facebook Blue */
    color: white;
    text-decoration: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 4px 12px rgba(24, 119, 242, 0.3);
    transition: transform 0.2s;
}

.detail-fb-btn:active {
    transform: scale(0.96);
}
