/* public/css/sales.css */

/* ------------ General reset & base ------------ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ------------ Search Header Section ------------ */
.search-header-section {
    background: linear-gradient(to bottom, rgba(244, 245, 247, 0.85) 0%, rgba(240, 242, 244, 0.85) 100%),
                url('../images/sales/headsls.jpg') center center;
    background-size: cover;
    background-position: center;
    padding: 50px 0;
    position: relative;
}

.search-header-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 20px;
}

/* updated: make wrapper flexible and avoid clipping of native selects on iOS/Android and foldables */
.search-wrapper {
    background-color: #183B4E;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;

    /* Responsive safety defaults */
    overflow: visible;        /* allow native select dropdowns to render outside */
    flex-wrap: nowrap;        /* prefer single row, but change in breakpoints below */
}

/* Make the input flexible but bounded so that on medium widths it shrinks instead of forcing overflow */
.main-search-input {
    flex: 1 1 40%;
    background-color: #ffffff;
    border: 1px solid #ddd;
    padding: 12px 18px;
    font-size: 14px;
    border-radius: 5px;
    outline: none;
    min-width: 180px;         /* lowered from 250 to avoid overflow on tablets */
    max-width: 65%;
    box-sizing: border-box;
}

.main-search-input::placeholder {
    color: #999;
}

/* Dropdown group behaves as flex; will wrap on medium devices */
.search-dropdown-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 0 1 auto;
    overflow: visible;        /* ensure select dropdowns can overlay */
}

/* dropdown - flexible / bounded */
.header-dropdown {
    background-color: #183B4E;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 12px 18px;
    font-size: 14px;
    border-radius: 5px;
    cursor: pointer;
    outline: none;

    /* flexible sizing to avoid forcing overflow */
    flex: 0 1 160px;
    min-width: 110px;
    max-width: 240px;

    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 35px;

    /* stacking context safety so the select and button stay above image overlays */
    position: relative;
    z-index: 20;
}

.header-dropdown option {
    background-color: #fff;
    color: #333;
}

/* Ensure search button doesn't get clipped and stays visible */
.header-search-button {
    background-color: #854836;
    color: #fff;
    border: none;
    padding: 12px 35px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;

    position: relative;
    z-index: 25;
}

.header-search-button:hover {
    background-color: #183B4E;
}

/* ------------ Breadcrumb ------------ */
.breadcrumb-section {
    background-color: #fff;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.breadcrumb-link {
    color: #0e0e0e;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

/* ------------ Page Header ------------ */
.page-header {
    background-color: #fff;
    padding: 20px 0;
    border-bottom: 1px solid #e0e0e0;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

/* ------------ Content Wrapper ------------ */
.content-wrapper {
    display: flex;
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 40px;
}

/* ------------ Sidebar ------------ */
.sidebar-filter {
    width: 300px;
    background-color: #183B4E;
    border-radius: 8px;
    padding: 10px;
    height: fit-content;
    position: sticky;
    top: 20px;
    margin-left: -10px;
}

.filter-header {
    background-color: #183B4E;
    padding: 15px 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-header h3 {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.filter-group {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-item {
    color: #fff;
    font-size: 14px;
    padding: 8px 12px;
    margin-bottom: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.filter-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.filter-item.active {
     background-color: #183B4E;
    font-weight: 600;
}

.filter-section {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-section-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.filter-list {
    max-height: 300px;
    overflow-y: auto;
}

.filter-list::-webkit-scrollbar {
    width: 6px;
}

.filter-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.filter-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* ------------ Main Content ------------ */
.main-content {
    flex: 1;
}

/* ------------ Properties Grid ------------ */
.properties-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

/* ------------ Property Card ------------ */
.property-card {
    background-color: #c5d9f0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.property-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* Hot Deal Cards - Special Styling */
.property-card[data-hot-deal="true"] {
    background: linear-gradient(135deg, #fff5e6 0%, #ffe6cc 100%);
    border: 2px solid #ff6b00;
    position: relative;
}

.property-card[data-hot-deal="true"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ff6b00, #ff8c00, #ff6b00);
    animation: hotDealGlow 2s ease-in-out infinite;
}

@keyframes hotDealGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Trending Cards - Special Styling */
.property-card[data-trending="true"] {
    background: linear-gradient(135deg, #e6f7ff 0%, #d1f0ff 100%);
    border: 2px solid #1890ff;
    position: relative;
}

.property-card[data-trending="true"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #1890ff, #40a9ff, #1890ff);
    animation: trendingGlow 2s ease-in-out infinite;
}

@keyframes trendingGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ------------ Property Image ------------ */
.property-image-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
}

.property-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ------------ Badges ------------ */
.badge-hot-deal {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #ff6b00 0%, #ff8c00 100%);
    color: #fff;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

.badge-hot-deal::before {
    content: '🔥 ';
    font-size: 13px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.badge-trending {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #1890ff 0%, #40a9ff 100%);
    color: #fff;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
    animation: trendingPulse 2s ease-in-out infinite;
}

.badge-trending::before {
    content: '📈 ';
    font-size: 13px;
}

@keyframes trendingPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.badge-urgent {
    position: absolute;
    top: 12px;
    left: 12px;
    background-color: #350707;
    color: #fff;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-location {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background-color: #f4f7f4;
    color: #100f0f;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

/* ------------ Property Content ------------ */
.property-content {
    padding: 16px;
}

.property-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.meta-badge {
    background-color: #f0f0f0;
    color: #333;
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 4px;
    font-weight: 500;
    border: none;
    cursor: default;
}

.btn-favorite {
    margin-left: auto;
    background: none;
    border: 1px solid #ddd;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-favorite:hover {
    background-color: #ff6b6b;
    color: #fff;
    border-color: #ff6b6b;
}

.property-price-section {
    margin-bottom: 10px;
}

.property-price {
    color: #97520c;
    font-size: 22px;
    font-weight: 700;
    margin-right: 8px;
}

.property-price-unit {
    color: #666;
    font-size: 13px;
}

/* Price Discount Section - For Hot Deals */
.price-discount {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.original-price {
    color: #999;
    font-size: 14px;
    text-decoration: line-through;
    font-weight: 500;
}

.discount-badge {
    background: linear-gradient(135deg, #ff6b00 0%, #ff8c00 100%);
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.property-description {
    color: #555;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 12px;
    min-height: 42px;
}

.property-footer {
    display: flex;
    gap: 15px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.property-icon {
    color: #0066cc;
    font-size: 12px;
    display: flex;
    align-items: center;
}

/* ------------ Pagination ------------ */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
    padding: 20px 0;
}

.pagination-arrow,
.pagination-number {
    background-color: #fff;
    border: 1px solid #ddd;
    color: #333;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination-arrow:hover,
.pagination-number:hover {
    background-color: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

.pagination-number.active {
    background-color: #ffc107;
    color: #333;
    border-color: #ffc107;
    font-weight: 700;
}

.pagination-text {
    color: #666;
    font-size: 13px;
    margin-left: 15px;
}

/* ------------ Description Section ------------ */
.description-section {
    background-color: #fff;
    padding: 40px 0;
    margin-top: 40px;
    border-top: 1px solid #e0e0e0;
}

.description-title {
    font-size: 22px;
    font-weight: 600;
    color: #183B4E;
    margin-bottom: 20px;
    text-align: center;
}

.description-text {
    color: #555;
    font-size: 14px;
    line-height: 1.8;
    text-align: justify;
}

/* ------------ Responsive Design & Fixes for tablets / foldables (iPad Air, Asus Zenbook Fold etc.) ------------ */

/* Large tablets / small desktops */
@media screen and (max-width: 1200px) {
    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium devices (include iPad landscape/portrait and foldable mid ranges).
   Important: switch wrapper to wrap to avoid horizontal overflow and let inputs/dropdowns stack cleanly. */
@media screen and (max-width: 1024px) {
    .search-header-section {
        padding: 28px 0; /* reduce padding for medium devices */
    }

    .search-header-container {
        padding: 0 12px;
    }

    .search-wrapper {
        /* let children wrap to next line when space tight */
        flex-wrap: wrap;
        padding: 10px;
        gap: 8px;
    }

    .main-search-input {
        flex-basis: 100%;
        max-width: 100%;
        min-width: 220px;
    }

    .search-dropdown-group {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .header-dropdown {
        flex: 1 1 30%;
        min-width: 120px;
        max-width: 33%;
    }

    .header-search-button {
        align-self: stretch;
        flex-basis: auto;
    }

    /* Make sidebar full width / static under content on medium screens */
    .content-wrapper {
        flex-direction: column;
    }

    .sidebar-filter {
        width: 100%;
        position: static;
        margin-left: 0;
    }

    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Specific small-tablet / large-phone sizes (handles iPad Air portrait ~820px width) */
@media screen and (max-width: 880px) and (min-width: 720px) {
    .main-search-input {
        flex-basis: 60%;
        min-width: 200px;
    }
    .header-dropdown {
        flex-basis: 36%;
        min-width: 120px;
    }
    .search-dropdown-group {
        gap: 6px;
    }
}

/* For foldable devices and narrow landscape windows (e.g. folded screens that report larger device widths but limited content width) */
@media screen and (max-width: 1366px) and (min-width: 1025px) {
    .main-search-input {
        flex: 1 1 45%;
        max-width: 60%;
    }
    .header-dropdown {
        flex: 0 1 140px;
        min-width: 110px;
    }
}

/* Mobile */
@media screen and (max-width: 768px) {
    .properties-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .page-title {
        font-size: 20px;
    }

    .container {
        padding: 0 15px;
    }

    .pagination-wrapper {
        flex-wrap: wrap;
    }

    .pagination-text {
        width: 100%;
        text-align: center;
        margin-top: 10px;
        margin-left: 0;
    }

    /* stack search controls on small screens */
    .search-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .search-dropdown-group {
        flex-direction: column;
        width: 100%;
    }

    .header-dropdown {
        width: 100%;
        max-width: 100%;
    }

    .property-image-wrapper {
        height: 200px;
    }

    .price-discount {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .badge-trending::before,
    .badge-hot-deal::before {
        font-size: 11px;
    }
    
    .badge-hot-deal,
    .badge-trending,
    .badge-urgent {
        padding: 6px 10px;
        font-size: 10px;
    }
}

/* Small phones */
@media screen and (max-width: 480px) {
    .property-meta {
        flex-wrap: wrap;
    }

    .property-footer {
        flex-direction: column;
        gap: 8px;
    }

    .property-image-wrapper {
        height: 180px;
    }
    
    .filter-item {
        font-size: 13px;
        padding: 10px;
    }
}

/* ensure selects and button are above other content (safety for z-index stacking contexts) */
.header-search-button .search-icon {
    margin-left: 8px;
    vertical-align: middle;
}

.header-dropdown,
.header-search-button {
    position: relative;
    z-index: 20;
}

/* final safety for very tight viewports: allow stacking vertically */
@media screen and (max-width: 660px) {
    .search-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .main-search-input,
    .search-dropdown-group,
    .header-search-button {
        width: 100%;
        max-width: 100%;
    }

    .search-dropdown-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .header-dropdown {
        width: 100%;
    }
}