/**
 * Featured Listing Frontend CSS
 * 
 * Styles for the auto-generated featured listing pages.
 * Designed to work within Divi and standard WordPress themes.
 * 
 * @package SCP_Listings
 * @since 1.1.0
 */

/* ─── Container ─── */
.scp-featured-listing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #333;
    line-height: 1.6;
    position: relative;
    z-index: 1;
    background: #fff;
}

/* ─── Divi compatibility ─── */
/* Fix 1: Divi Theme Builder sets negative z-index on body sections, which pushes
   our content behind #main-content's white background when sticky JS activates.
   Override to auto so content paints in normal stacking order. */
.et_pb_section:has(.scp-featured-listing),
.et_pb_fullwidth_section:has(.scp-featured-listing) {
    z-index: auto !important;
}

/* Fix 2: Give the post content wrapper its own stacking context so our content
   always renders above parent backgrounds. */
.et_pb_post_content:has(.scp-featured-listing) {
    position: relative !important;
    z-index: 1 !important;
}

/* Fix 3: Prevent overflow clipping on Divi wrapper elements. */
body.page-template-blank #page-container,
body.page-template-blank #et-main-area,
body.et-pb-page-template-blank #page-container,
body.et-pb-page-template-blank #et-main-area,
body.et_full_width_page #page-container,
body.et_full_width_page #et-main-area,
body.et_full_width_page .container,
body.et_full_width_page #content-area,
body.et_full_width_page #main-content,
body.et-db #page-container,
body.et-db #et-main-area,
body.et-db .container,
body.et-db #content-area,
body.et-db #main-content {
    overflow: visible !important;
}

/* ─── Gallery (4×2 grid) ─── */
.scp-featured-gallery {
    margin-bottom: 30px;
}

.scp-featured-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    border-radius: 10px;
    overflow: hidden;
}

.scp-featured-thumb {
    overflow: hidden;
    position: relative;
    aspect-ratio: 4 / 3;
}

.scp-featured-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.scp-featured-thumb:hover img {
    transform: scale(1.05);
}

.scp-featured-more-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    pointer-events: none;
}

.scp-featured-thumb-tour {
    background: #1a1a2e;
}

.scp-featured-tour-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #fff;
    gap: 6px;
    padding: 10px;
    text-align: center;
}

.scp-featured-tour-placeholder .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}

/* ─── Layout (Content + Sidebar) ─── */
.scp-featured-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 40px;
    align-items: start;
}

/* ─── Address Header ─── */
.scp-featured-address {
    margin-bottom: 20px;
}

.scp-featured-address h2 {
    font-size: 2em;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.2;
    color: #1a1a2e;
}

/* ─── Stats Bar ─── */
.scp-featured-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 24px;
    border: 1px solid #e9ecef;
}

.scp-featured-stat {
    display: flex;
    flex-direction: column;
    min-width: 80px;
}

.scp-featured-stat .stat-value {
    font-size: 1.2em;
    font-weight: 700;
    color: #1a1a2e;
}

.scp-featured-stat .stat-label {
    font-size: 0.8em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scp-featured-stat-price .stat-value {
    font-size: 1.5em;
    color: #2271b1;
}

.scp-status-active {
    color: #28a745 !important;
}

.scp-status-pending,
.scp-status-pending-with-showings {
    color: #ffc107 !important;
}

.scp-status-closed {
    color: #dc3545 !important;
}

/* ─── Sections ─── */
.scp-featured-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e9ecef;
}

.scp-featured-section:last-child {
    border-bottom: none;
}

.scp-featured-section h3 {
    font-size: 1.2em;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.scp-featured-description p {
    font-size: 1em;
    line-height: 1.7;
    color: #444;
}

/* ─── Details Grid ─── */
.scp-featured-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.scp-featured-detail-row {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.scp-featured-detail-row:nth-child(odd) {
    background: #fafafa;
}

.scp-featured-detail-label {
    font-weight: 600;
    color: #555;
    min-width: 140px;
    flex-shrink: 0;
}

.scp-featured-detail-value {
    color: #333;
}

/* ─── Tag Lists (features, appliances, etc) ─── */
.scp-featured-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scp-featured-tag {
    background: #e8f4fd;
    color: #1a5276;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.9em;
    white-space: nowrap;
}

.scp-featured-tag-group {
    margin-bottom: 12px;
}

.scp-featured-tag-group:last-child {
    margin-bottom: 0;
}

.scp-tag-group-label {
    display: block;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin-bottom: 6px;
}

/* ─── Brochure Link ─── */
.scp-featured-brochure {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 16px;
}

.scp-brochure-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #2271b1;
    color: #fff !important;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none !important;
    font-weight: 600;
    transition: background 0.2s ease;
}

.scp-brochure-link:hover {
    background: #135e96;
    color: #fff !important;
}

.scp-brochure-link .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ─── Virtual Tour ─── */
.scp-featured-virtual-tour {
    margin-top: 10px;
}

.scp-virtual-tour-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #2271b1;
    color: #fff !important;
    text-decoration: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s ease;
}

.scp-virtual-tour-link:hover {
    background: #135e96;
    color: #fff !important;
}

.scp-virtual-tour-link .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ─── Video Section ─── */
.scp-featured-video {
    margin-top: 10px;
}

.scp-featured-video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

.scp-featured-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.scp-featured-video-player {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    display: block;
}

/* ─── Sidebar ─── */
.scp-featured-sidebar {
    position: sticky;
    top: 80px;
}

.scp-featured-contact-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-top: 20px;
}

.scp-featured-contact-card h3 {
    margin: 0 0 4px;
    font-size: 1.2em;
    color: #1a1a2e;
}

.scp-featured-contact-subtitle {
    color: #888;
    font-size: 0.9em;
    margin: 0 0 16px;
}

/* ─── Form ─── */
.scp-featured-form .scp-form-row {
    margin-bottom: 12px;
}

.scp-featured-form .scp-form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.scp-featured-form label {
    display: block;
    font-weight: 500;
    font-size: 0.85em;
    margin-bottom: 4px;
    color: #555;
}

.scp-featured-form input[type="text"],
.scp-featured-form input[type="email"],
.scp-featured-form input[type="tel"],
.scp-featured-form input[type="url"],
.scp-featured-form select,
.scp-featured-form textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.scp-featured-form input:focus,
.scp-featured-form select:focus,
.scp-featured-form textarea:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(34,113,177,0.15);
}

.scp-featured-submit-btn {
    width: 100%;
    padding: 12px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.scp-featured-submit-btn:hover {
    background: #135e96;
}

.scp-form-success {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
}

.scp-form-error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
}

/* ─── Map ─── */
.scp-featured-map-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.scp-featured-map-card h3 {
    margin: 0 0 10px;
    font-size: 1em;
}

.scp-featured-map-container {
    border-radius: 8px;
    overflow: hidden;
}

/* ─── Quick Facts ─── */
.scp-featured-quick-facts {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.scp-featured-quick-facts h3 {
    margin: 0 0 10px;
    font-size: 1em;
    color: #1a1a2e;
}

.scp-featured-quick-facts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.scp-featured-quick-facts li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}

.scp-featured-quick-facts li:last-child {
    border-bottom: none;
}

/* ─── Attribution ─── */
.scp-featured-attribution {
    margin-top: 30px;
    padding: 16px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.scp-featured-attribution p {
    font-size: 11px;
    color: #888;
    line-height: 1.5;
    margin: 0;
}

/* ─── Error ─── */
.scp-featured-error {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .scp-featured-layout {
        grid-template-columns: 1fr;
    }
    
    .scp-featured-sidebar {
        position: static;
    }
}

@media (max-width: 768px) {
    .scp-featured-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .scp-featured-stats {
        gap: 10px;
    }
    
    .scp-featured-stat .stat-value {
        font-size: 1em;
    }
    
    .scp-featured-address h2 {
        font-size: 1.5em;
    }
    
    .scp-featured-details-grid {
        grid-template-columns: 1fr;
    }
    
    .scp-featured-form .scp-form-row-2col {
        grid-template-columns: 1fr;
    }
    
    .scp-featured-tour-embed iframe {
        height: 300px !important;
    }
}

@media (max-width: 480px) {
    .scp-featured-listing {
        padding: 0 12px;
    }
    
    .scp-featured-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .scp-featured-stat-price .stat-value {
        font-size: 1.2em;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   "New Listing" card layout  (scp-featured-layout-new_listing)
   ══════════════════════════════════════════════════════════════════════ */
.scp-featured-layout-new_listing {
    max-width: 1080px;
    margin: 0 auto;
}
.scp-nl-card {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Section 1 — Status / Type / Subtype strip */
.scp-nl-metastrip {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.scp-nl-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 18px;
    background: #f5f7f9;
    border-radius: 8px;
    min-width: 120px;
}
.scp-nl-meta-label {
    font-size: 0.72em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7783;
    font-weight: 600;
}
.scp-nl-meta-value {
    font-size: 1.05em;
    font-weight: 600;
    color: #1f2a33;
}
.scp-nl-meta-value.scp-status-active,
.scp-nl-meta-value.scp-status-coming-soon {
    color: #2e7d32;
}
.scp-nl-meta-value.scp-status-active-under-contract,
.scp-nl-meta-value.scp-status-pending {
    color: #c77700;
}

/* Section 2 — Address + key facts */
.scp-nl-address {
    margin: 0;
    font-size: 1.9em;
    line-height: 1.2;
    color: #1f2a33;
}
.scp-nl-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.scp-nl-fact {
    flex: 1 1 120px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    text-align: center;
}
.scp-nl-fact-value {
    font-size: 1.35em;
    font-weight: 700;
    color: #1f2a33;
}
.scp-nl-fact-label {
    font-size: 0.75em;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6b7783;
}
.scp-nl-fact-price {
    background: #1f2a33;
    border-color: #1f2a33;
}
.scp-nl-fact-price .scp-nl-fact-value { color: #fff; font-size: 1.5em; }
.scp-nl-fact-price .scp-nl-fact-label { color: #b9c4cd; }

/* Price change badge (down = red, up = green), shown when the sync detects a change */
.scp-nl-price-badge {
    align-self: center;
    margin-bottom: 6px;
    padding: 2px 12px;
    color: #fff;
    font-size: 0.62em;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    border-radius: 20px;
    white-space: nowrap;
}
.scp-nl-price-down { background: #d64545; }
.scp-nl-price-up   { background: #2e9e5b; }

/* SOLD ribbon */
.scp-nl-sold-ribbon {
    align-self: flex-start;
    padding: 6px 22px;
    background: #d02525;
    color: #fff;
    font-size: 1em;
    font-weight: 800;
    letter-spacing: 0.14em;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(208,37,37,0.35);
}

/* "New Listing" ribbon (Active, < 4 days on market) */
.scp-nl-new-ribbon {
    align-self: flex-start;
    padding: 6px 20px;
    background: linear-gradient(135deg, #ff7a18, #e23744);
    color: #fff;
    font-size: 0.95em;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(226,55,68,0.35);
}
.scp-nl-old-price {
    color: #9aa7b1;
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: line-through;
}

/* Section 3 — description excerpt */
.scp-nl-description {
    font-size: 1.02em;
    line-height: 1.7;
    color: #3c4750;
}
.scp-nl-description p { margin: 0; }

/* Section 4 — main image + 8-photo grid */
.scp-nl-gallery {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.scp-nl-main {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}
.scp-nl-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}
.scp-nl-main:hover img { transform: scale(1.03); }
.scp-nl-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.scp-nl-tile {
    position: relative;
    display: block;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
}
.scp-nl-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}
.scp-nl-tile:hover img { transform: scale(1.05); }
.scp-nl-more-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 22, 28, 0.55);
    color: #fff;
    font-weight: 700;
    font-size: 1.05em;
    letter-spacing: 0.02em;
}

/* View Details button */
.scp-nl-actions {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}
.scp-nl-details-btn {
    display: inline-block;
    padding: 14px 42px;
    background: #1f2a33;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease, transform 0.2s ease;
}
.scp-nl-details-btn:hover {
    background: #33424e;
    color: #fff;
    transform: translateY(-1px);
}

@media (max-width: 640px) {
    .scp-nl-grid { grid-template-columns: repeat(2, 1fr); }
    .scp-nl-address { font-size: 1.45em; }
    .scp-nl-fact { flex-basis: 45%; }
    .scp-nl-details-btn { width: 100%; text-align: center; }
}
