/* Ad Detail Page Re-design - Casinuevo Modern Aesthetic */

:root {
    --brand-orange: #FF6600;
    --brand-orange-hover: #E55A00;
    --brand-green: #059669;
    --brand-green-hover: #047857;
    --surface-white: #FFFFFF;
    --bg-gray: #F9FAFB;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-gray: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-lg: 16px;
    --radius-md: 12px;
}

/* Prevent horizontal scroll on page */
.main-content,
.ad-layout,
.image-gallery,
.main-image-container {
    max-width: 100%;
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
}

/* Base Layout */
body {
    background-color: var(--bg-gray);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.main-content {
    max-width: 1200px !important;
    margin: 0 auto;
    padding: 24px 15px !important;
}

.ad-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 32px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .ad-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* Gallery Refresh */
.image-gallery {
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
    position: relative;
}

.main-image-container {
    background: #f8fafc;
    height: 600px !important;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

@media (max-width: 768px) {
    .main-image-container {
        height: 400px !important;
    }
}

.main-image {
    max-width: 100%;
    max-height: 100%;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block;
}

.thumbnail-grid {
    padding: 12px;
    gap: 8px !important;
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}

.thumbnail-grid::-webkit-scrollbar {
    display: none;
}

.thumbnail-item {
    width: 80px !important;
    height: 80px !important;
    border-radius: 8px !important;
    border: 2px solid transparent !important;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-item.active {
    border-color: var(--brand-orange) !important;
}

/* Sidebar Styling */
.ad-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 100px;
}

@media (max-width: 1024px) {
    .ad-sidebar {
        position: static;
    }
}

.sidebar-card {
    background: var(--surface-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    border: none !important;
}

.sidebar-price {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 16px;
}

.btn-chat,
.btn-favorite {
    width: 100%;
    border-radius: 9999px !important;
    padding: 14px 20px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    text-transform: none !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none !important;
}

.btn-chat {
    background: var(--brand-orange) !important;
    color: white !important;
}

.btn-chat:hover {
    background: var(--brand-orange-hover) !important;
}

.btn-favorite {
    background: #f1f5f9 !important;
    color: #475569 !important;
    margin-top: 12px;
}

.btn-chat:hover,
.btn-favorite:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Main Column Typography */
.ad-main-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ad-title-block h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    line-height: 1.2;
}

/* Section Styling */
.product-description,
.basic-data-section,
.duplicate-ads-section,
.related-ads,
.valuation-section {
    background: var(--surface-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    border: none !important;
    margin-bottom: 24px;
}

.description-title,
.basic-data-title,
.related-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px !important;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.description-title::before,
.basic-data-title::before {
    content: '';
    display: block;
    width: 4px;
    height: 24px;
    background: var(--brand-orange);
    border-radius: 2px;
}

.description-content {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Grids and Items */
.basic-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.basic-data-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.basic-data-item:last-child {
    border-bottom: none;
}

.basic-data-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.basic-data-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Responsive Fixes */
@media (max-width: 640px) {
    .basic-data-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 16px 12px !important;
    }

    .ad-title-block h1 {
        font-size: 22px;
    }
}

/* Mobile Ad Header */
.mobile-ad-header {
    display: none;
    background: var(--surface-white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .mobile-ad-header {
        display: block;
    }
}

/* Ad Meta Info Styling */
.ad-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 14px;
    padding: 0 4px;
}

.ad-meta-info .meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ad-meta-info .meta-item i {
    color: var(--brand-orange);
    font-size: 16px;
}

/* Related Ads Slider */
.related-slider-container {
    position: relative;
    padding: 0 40px;
    margin-top: 24px;
    overflow: hidden;
}

.related-slider {
    display: flex;
    gap: 24px;
    transition: transform 0.3s ease;
    will-change: transform;
}

.related-slide {
    flex: 0 0 calc((100% - (3 * 24px)) / 4);
    min-width: 0;
}

.related-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    transition: all 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    border: 1px solid #f1f5f9;
}

.related-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: var(--brand-orange);
}

.related-image {
    height: 180px;
    background: #f8fafc;
    overflow: hidden;
    position: relative;
}

.related-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.related-card:hover .related-image img {
    transform: scale(1.05);
}

.related-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.related-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.8em;
}

.related-card-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--brand-orange);
}

.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: #ffffff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    color: #1e293b;
    transition: all 0.2s;
}

.slider-btn:hover {
    background: var(--brand-orange);
    color: #ffffff;
}

.slider-btn-prev {
    left: 0;
}

.slider-btn-next {
    right: 0;
}

.slider-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.slider-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.slider-dot.active {
    background: var(--brand-orange);
    width: 24px;
    border-radius: 4px;
}

@media (max-width: 1024px) {
    .related-slide {
        flex: 0 0 calc((100% - (2 * 24px)) / 3);
    }
}

@media (max-width: 768px) {
    .related-slider-container {
        padding: 0;
    }

    .slider-btn {
        display: none !important;
    }

    .related-slide {
        flex: 0 0 calc((100% - 16px) / 2);
    }

    .related-slider {
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .related-slide {
        flex: 0 0 100%;
    }
}

/* ===========================================
   PREMIUM MOBILE REDESIGN - Ad Detail Page
   =========================================== */

/* Default: Hide mobile-only elements on desktop */
.mobile-seller-card {
    display: none;
}

/* Mobile: Reset paddings for immersive experience */
@media (max-width: 768px) {

    /* Show mobile seller card */
    .mobile-seller-card {
        display: flex;
    }

    .main-content {
        padding: 0 !important;
        background: #f8fafc;
    }

    .ad-layout {
        gap: 0;
    }

    /* Hide desktop sidebar on mobile - will use floating bar instead */
    .ad-sidebar {
        display: none !important;
    }

    /* ==================
       GALLERY REDESIGN
       ================== */
    .image-gallery {
        border-radius: 0;
        margin-bottom: 0;
        box-shadow: none;
        position: relative;
    }

    .main-image-container {
        height: auto !important;
        aspect-ratio: 4 / 3;
        background: linear-gradient(135deg, #1e293b, #0f172a);
        min-height: 260px;
        max-height: 380px;
    }

    .main-image {
        width: 100% !important;
        height: 100% !important;
        max-width: 100%;
        object-fit: cover !important;
        object-position: center;
        display: block;
    }

    /* Overlay badges repositioning */
    .image-overlay-badges {
        position: absolute;
        top: 12px;
        left: 12px;
        z-index: 10;
    }

    .sold-badge {
        background: linear-gradient(135deg, #ef4444, #dc2626);
        color: white;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    }

    /* Favorite button on image */
    .image-fav-btn {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        background: rgba(255, 255, 255, 0.95);
        border: none;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
        transition: all 0.2s ease;
    }

    .image-fav-btn:active {
        transform: scale(0.95);
    }

    .image-fav-btn i {
        font-size: 20px;
        color: #64748b;
        transition: all 0.2s ease;
    }

    .image-fav-btn.active i,
    .image-fav-btn:hover i {
        color: #ef4444;
    }

    /* Image counter pill */
    .image-counter {
        position: absolute;
        bottom: 12px;
        right: 12px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 13px;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 6px;
        backdrop-filter: blur(8px);
        z-index: 10;
    }

    .image-counter i {
        font-size: 12px;
        opacity: 0.9;
    }

    /* Thumbnail strip - horizontal scroll */
    .thumbnail-grid {
        padding: 12px 16px;
        gap: 10px !important;
        background: #fff;
        border-top: none;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .thumbnail-item {
        width: 64px !important;
        height: 64px !important;
        border-radius: 10px !important;
        scroll-snap-align: start;
        border: 2px solid #e2e8f0 !important;
    }

    .thumbnail-item.active {
        border-color: #1877f2 !important;
        box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
    }

    /* ==================
       MOBILE AD HEADER
       ================== */
    .mobile-ad-header {
        display: block !important;
        background: #ffffff;
        padding: 20px 16px;
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 0;
        border-bottom: 1px solid #f1f5f9;
    }

    .mobile-ad-header h1 {
        font-size: 20px;
        font-weight: 700;
        color: #1e293b;
        line-height: 1.35;
        margin: 0 0 12px 0;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-ad-header .price {
        font-size: 26px;
        font-weight: 800;
        color: #1e293b;
        letter-spacing: -0.5px;
    }

    /* ==================
       AD META INFO - CHIPS STYLE
       ================== */
    .ad-meta-info {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 10px;
        padding: 16px;
        background: #ffffff;
        margin: 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-bottom: 1px solid #f1f5f9;
    }

    .ad-meta-info::-webkit-scrollbar {
        display: none;
    }

    .ad-meta-info .meta-item {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 6px;
        background: #f8fafc;
        padding: 10px 14px;
        border-radius: 10px;
        font-size: 13px;
        font-weight: 500;
        color: #475569;
        border: 1px solid #e2e8f0;
    }

    .ad-meta-info .meta-item i {
        font-size: 14px;
        color: #64748b;
    }

    /* ==================
       CONTENT SECTIONS
       ================== */
    .ad-main-column {
        gap: 0;
        padding: 0;
    }

    .product-description,
    .basic-data-section,
    .valuation-section,
    .property-details,
    .product-map,
    .category-location-tree,
    .duplicate-ads-section,
    .related-ads,
    .related-search-section {
        border-radius: 0 !important;
        margin-bottom: 0 !important;
        padding: 20px 16px !important;
        box-shadow: none !important;
        border: none !important;
        border-bottom: 8px solid #f1f5f9 !important;
    }

    .description-title,
    .basic-data-title,
    .related-title {
        font-size: 17px;
        margin-bottom: 16px !important;
    }

    .description-content {
        font-size: 15px;
        line-height: 1.6;
    }

    /* Truncated description */
    .description-content.truncated {
        max-height: 150px;
        overflow: hidden;
        position: relative;
    }

    .description-content.truncated::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: linear-gradient(transparent, white);
        pointer-events: none;
    }

    .description-read-more {
        display: inline-block;
        margin-top: 12px;
        color: #1877f2;
        font-weight: 600;
        font-size: 14px;
        text-decoration: none;
    }

    /* Basic data grid mobile */
    .basic-data-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
    }

    .basic-data-grid>div {
        display: contents;
    }

    .basic-data-item {
        padding: 14px 0;
        border-bottom: 1px solid #f1f5f9;
    }

    .basic-data-label {
        font-size: 11px;
        letter-spacing: 0.08em;
    }

    .basic-data-value {
        font-size: 15px;
    }

    /* Property features grid */
    .property-features-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    /* Related ads mobile */
    .related-ads {
        overflow: hidden;
    }

    .related-slider {
        gap: 12px !important;
        padding: 0 16px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .related-slide {
        flex: 0 0 calc(50% - 6px) !important;
        scroll-snap-align: start;
    }

    .related-image {
        height: 140px;
    }

    .related-content {
        padding: 12px;
    }

    .related-card-title {
        font-size: 13px;
        height: auto;
        -webkit-line-clamp: 2;
    }

    .related-card-price {
        font-size: 16px;
    }
}

/* ===========================================
   FLOATING ACTION BAR - MOBILE ONLY
   =========================================== */
.mobile-action-bar {
    display: none;
}

@media (max-width: 768px) {
    .mobile-action-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #ffffff;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        border-top: 1px solid #f1f5f9;
    }

    .mobile-action-bar .price-section {
        flex: 1;
        min-width: 0;
    }

    .mobile-action-bar .action-price {
        font-size: 20px;
        font-weight: 800;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-action-bar .action-label {
        font-size: 11px;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        font-weight: 600;
    }

    .mobile-action-bar .action-buttons {
        display: flex;
        gap: 10px;
        flex-shrink: 0;
    }

    .mobile-action-bar .btn-action-chat {
        background: linear-gradient(135deg, #1877f2, #0d65d9);
        color: white;
        border: none;
        padding: 14px 28px;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        box-shadow: 0 4px 12px rgba(24, 119, 242, 0.3);
        transition: all 0.2s ease;
    }

    .mobile-action-bar .btn-action-chat:active {
        transform: scale(0.98);
    }

    .mobile-action-bar .btn-action-secondary {
        width: 48px;
        height: 48px;
        background: #f8fafc;
        border: 1.5px solid #e2e8f0;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-action-bar .btn-action-secondary i {
        font-size: 18px;
        color: #64748b;
    }

    .mobile-action-bar .btn-action-secondary:active {
        background: #f1f5f9;
    }

    /* Ensure main content has bottom padding for action bar */
    .main-content {
        padding-bottom: 90px !important;
    }

    /* Hide fixed bottom nav bar if exists to avoid overlap */
    body.has-mobile-action-bar .bottom-nav {
        display: none !important;
    }
}

/* ===========================================
   TOUCH OPTIMIZATIONS
   =========================================== */
@media (max-width: 768px) {

    /* Ensure all interactive elements meet 44px minimum touch target */
    button,
    a,
    .thumbnail-item,
    .meta-item {
        min-height: 44px;
    }

    /* Smooth scroll behavior */
    .thumbnail-grid,
    .ad-meta-info,
    .related-slider {
        scroll-behavior: smooth;
    }

    /* Active states for touch feedback */
    .thumbnail-item:active {
        transform: scale(0.95);
    }

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

/* ===========================================
   RICH CARD PLACEHOLDER - MOBILE
   =========================================== */
@media (max-width: 768px) {
    .rich-card-fallback {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        background: linear-gradient(135deg, #f8fafc, #e2e8f0);
        color: #94a3b8;
        gap: 12px;
    }

    .rich-card-fallback i {
        font-size: 48px;
    }

    .rich-card-fallback p {
        font-size: 14px;
        margin: 0;
    }
}

/* ===========================================
   SELLER INLINE CARD - MOBILE
   =========================================== */
@media (max-width: 768px) {
    .mobile-seller-card {
        display: flex;
        align-items: center;
        gap: 14px;
        background: #ffffff;
        padding: 16px;
        border-bottom: 1px solid #f1f5f9;
    }

    .mobile-seller-card .seller-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: #f1f5f9;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        font-weight: 600;
        color: #64748b;
        overflow: hidden;
        flex-shrink: 0;
    }

    .mobile-seller-card .seller-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mobile-seller-card .seller-info {
        flex: 1;
        min-width: 0;
    }

    .mobile-seller-card .seller-name {
        font-size: 15px;
        font-weight: 600;
        color: #1e293b;
        margin: 0 0 4px 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-seller-card .seller-stats {
        font-size: 13px;
        color: #64748b;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-seller-card .seller-stats i {
        color: #fbbf24;
        font-size: 12px;
    }

    .mobile-seller-card .view-profile {
        color: #1877f2;
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        flex-shrink: 0;
    }
}
