/*
Theme Name:   Mafrosha
Theme URI:    https://mafrosha.com/
Author:       Mafrosha Team
Author URI:   https://mafrosha.com/
Description:  قالب ووردبريس احترافي لمنصات العقارات المفروشة في الشرق الأوسط. مدمج بالكامل مع Elementor + نظام Brokerage Shield لحماية بيانات المالكين. يدعم RTL، ثنائي اللغة (عربي/إنجليزي)، وجاهز للحجوزات.
Version:      1.1.5
Requires at least: 6.0
Requires PHP: 7.4
License:      GNU General Public License v2 or later
License URI:  http://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  mafrosha
Domain Path:  /languages/
Tags:         real-estate, rtl-language-support, elementor, custom-colors, custom-header, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready, accessibility-ready, block-styles

This theme, like WordPress, is licensed under the GPL.
*/

/* ==========================================================================
   0. Variables (المتغيرات لتسهيل الصيانة والتحكم الديناميكي بالألوان)
   ========================================================================== */
:root {
    --mfr-primary: #7c3aed;
    --mfr-primary-dark: #6d28d9;
    --mfr-secondary: #ec4899;
    
    --mfr-text-main: #1f2937;
    --mfr-text-muted: #6b7280;
    --mfr-bg-body: #ffffff;
    --mfr-bg-alt: #f9fafb;
    --mfr-border: #e5e7eb;

    --mfr-font-main: 'Tajawal', 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    
    --mfr-border-radius: 12px;
    --mfr-transition: all 0.3s ease;
}

/* 🚀 دعم الوضع الليلي التلقائي بناءً على إعدادات جهاز الزائر */
@media (prefers-color-scheme: dark) {
    :root {
        --mfr-text-main: #f3f4f6;
        --mfr-text-muted: #9ca3af;
        --mfr-bg-body: #111827;
        --mfr-bg-alt: #1f2937;
        --mfr-border: #374151;
    }
}

/* ==========================================================================
   1. Base & Reset
   ========================================================================== */
html {
    box-sizing: border-box;
    scroll-behavior: smooth; 
    scroll-padding-top: 100px; 
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; animation: none !important; }
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    font-family: var(--mfr-font-main);
    line-height: 1.7;
    color: var(--mfr-text-main);
    background-color: var(--mfr-bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; 
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--mfr-text-main);
    text-wrap: balance; 
}

p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-wrap: pretty;
}

img, video, iframe, embed, object, canvas, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

p img, span img, a img {
    display: inline-block;
}

a {
    text-decoration: none;
    color: var(--mfr-primary);
    transition: var(--mfr-transition);
}

a:hover, a:focus {
    color: var(--mfr-primary-dark);
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px dashed var(--mfr-primary);
    outline-offset: 4px;
    border-radius: 4px;
}

input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], input[type="number"], input[type="tel"], textarea, select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--mfr-border);
    border-radius: 8px;
    background-color: var(--mfr-bg-body);
    color: var(--mfr-text-main);
    font-family: inherit;
    transition: var(--mfr-transition);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--mfr-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   2. Layout & Grid
   ========================================================================== */
.container {
    max-width: 1280px;
    margin-inline: auto;
    padding-inline: 20px;
    width: 100%;
}

.site-content {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    padding-block: 60px;
}

.site-content.has-sidebar .content-area {
    width: calc(70% - 15px);
}

.site-content.has-sidebar .sidebar {
    width: calc(30% - 15px);
}

.site-content.no-sidebar .content-area {
    width: 100%;
}

@media (max-width: 991px) {
    .site-content.has-sidebar .content-area,
    .site-content.has-sidebar .sidebar {
        width: 100%;
    }
}

/* ==========================================================================
   3. WordPress Required Classes
   ========================================================================== */
.alignleft { float: inline-start; margin-block-end: 1.5em; margin-inline-end: 1.5em; }
.alignright { float: inline-end; margin-block-end: 1.5em; margin-inline-start: 1.5em; }
.aligncenter { display: block; margin-inline: auto; margin-block-end: 1.5em; clear: both; }

.alignwide {
    margin-inline: auto;
    max-width: 100%; 
    width: 100%;
}
@media (min-width: 800px) {
    .alignwide { max-width: min(calc(100vw - 40px), 1200px); }
}

.alignfull {
    margin-inline-start: calc(50% - 50vw);
    margin-inline-end: calc(50% - 50vw);
    max-width: 100vw;
    width: 100vw;
}

.wp-caption { max-width: 100%; margin-bottom: 1.5em; }
.wp-caption img { display: block; margin-inline: auto; }
.wp-caption-text, .gallery-caption, figcaption {
    text-align: center; font-size: 0.875rem; color: var(--mfr-text-muted); margin-top: 0.5rem; font-style: italic;
}

.screen-reader-text {
    border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%);
    height: 1px; margin: -1px; overflow: hidden; padding: 0;
    position: absolute !important; width: 1px; word-wrap: normal !important;
}

.screen-reader-text:focus {
    background-color: var(--mfr-bg-body); border-radius: 4px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    clip: auto !important; clip-path: none; color: var(--mfr-primary); display: block;
    font-size: 1rem; font-weight: 700; height: auto; inset-inline-start: 10px; top: 10px;
    padding: 12px 20px; z-index: 100000;
}

.sticky { display: block; }
.bypostauthor { display: block; }

/* ==========================================================================
   4. Theme Components & Utilities
   ========================================================================== */
.responsive-video-wrapper {
    position: relative;
    padding-bottom: 56.25%; 
    height: 0;
    overflow: hidden;
    max-width: 100%;
    border-radius: var(--mfr-border-radius);
    background: var(--mfr-bg-alt);
    margin-block: 20px;
}
.responsive-video-wrapper iframe, 
.responsive-video-wrapper object, 
.responsive-video-wrapper embed {
    position: absolute;
    inset: 0; 
    width: 100%;
    height: 100%;
    border: 0;
}

.page-featured-image {
    margin-block: 30px;
    border-radius: var(--mfr-border-radius);
    overflow: hidden;
    background: var(--mfr-bg-alt);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.page-featured-image img {
    width: 100%; height: auto; object-fit: cover; max-height: 600px;
}

.page-comments-section, .post-comments-section {
    margin-top: 50px; padding-top: 30px; border-top: 1px solid var(--mfr-border);
}

.page-links {
    margin-block: 30px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.page-links .page-number {
    display: inline-flex; align-items: center; justify-content: center; min-width: 35px; height: 35px;
    padding: 0 10px; background-color: var(--mfr-bg-alt); border: 1px solid var(--mfr-border);
    border-radius: 6px; color: var(--mfr-text-main); font-weight: bold; transition: var(--mfr-transition);
}
.page-links a .page-number:hover {
    background-color: var(--mfr-primary); border-color: var(--mfr-primary); color: #ffffff;
}

.search-highlight {
    background-color: rgba(236, 72, 153, 0.15);
    color: var(--mfr-secondary);
    border-radius: 4px;
    padding: 0 4px;
}

/* ==========================================================================
   5. Cards (Property, Blog) 
   ========================================================================== */
.mafrosha-card, .property-card, .blog-card {
    background: var(--mfr-bg-body); border: 1px solid var(--mfr-border);
    border-radius: var(--mfr-border-radius); overflow: hidden; transition: var(--mfr-transition);
    display: flex; flex-direction: column;
}
.mafrosha-card:hover, .property-card:hover, .blog-card:hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.06); transform: translateY(-3px);
}

/* Property Card Specifics */
.property-card .card-image { position: relative; aspect-ratio: 4/3; overflow: hidden; }
.property-card .card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.property-card:hover .card-image img { transform: scale(1.05); }
.property-card .card-badges { position: absolute; top: 15px; inset-inline-start: 15px; display: flex; flex-direction: column; gap: 8px; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; display: inline-flex; align-items: center; gap: 4px; }
.badge-verified { background: #d1fae5; color: #065f46; }
.badge-featured { background: #fef3c7; color: #92400e; }
.property-card .card-wishlist {
    position: absolute; top: 15px; inset-inline-end: 15px; background: #fff; border: none; width: 36px; height: 36px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: var(--mfr-transition);
}
.property-card .card-wishlist:hover { background: #fee2e2; color: #ef4444; }
.property-card .card-body { padding: 20px; display: flex; flex-direction: column; flex-grow: 1; }
.property-card .card-location { font-size: 0.85rem; color: var(--mfr-text-muted); margin-bottom: 8px; }
.property-card .card-title { font-size: 1.2rem; margin-bottom: 15px; }
.property-card .card-features { display: flex; gap: 15px; margin-bottom: 20px; border-bottom: 1px solid var(--mfr-border); padding-bottom: 15px; }
.property-card .feature { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--mfr-text-muted); }
.property-card .card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.property-card .price-amount { font-size: 1.25rem; font-weight: 800; color: var(--mfr-primary); }
.property-card .price-currency, .property-card .price-duration { font-size: 0.85rem; color: var(--mfr-text-muted); }
.property-card .card-btn { font-weight: bold; display: flex; align-items: center; }

/* Blog Card Specifics */
.blog-image-link { display: block; aspect-ratio: 16/9; overflow: hidden; }
.blog-image-link img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.blog-card:hover .blog-image-link img { transform: scale(1.05); }
.blog-category { background: var(--mfr-primary); color: #fff; padding: 4px 12px; border-radius: 6px; font-size: 0.8rem; font-weight: bold; }
.blog-category:hover { background: var(--mfr-primary-dark); color: #fff; }
.btn-read-more { display: inline-flex; align-items: center; font-weight: 700; color: var(--mfr-primary); }
.btn-read-more:hover { gap: 8px; }

/* ==========================================================================
   6. Single Property & Single Post Details
   ========================================================================== */
.post-tags .tag { display: inline-block; padding: 4px 12px; background: var(--mfr-bg-alt); border: 1px solid var(--mfr-border); border-radius: 20px; font-size: 0.85rem; margin-inline-end: 5px; color: var(--mfr-text-muted); transition: var(--mfr-transition); }
.post-tags .tag:hover { background: var(--mfr-primary); color: #fff; border-color: var(--mfr-primary); }

.share-btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 15px; border-radius: 6px; color: #fff !important; font-size: 0.9rem; font-weight: 600; transition: var(--mfr-transition); }
.share-btn.whatsapp { background: #25D366; }
.share-btn.facebook { background: #1877f2; }
.share-btn.twitter { background: #1da1f2; }
.share-btn.linkedin { background: #0a66c2; }
.share-btn:hover { opacity: 0.9; transform: translateY(-2px); }

/* Sidebar Widgets */
.widget { background: var(--mfr-bg-body); border: 1px solid var(--mfr-border); border-radius: var(--mfr-border-radius); padding: 25px; margin-bottom: 30px; }
.widget h3 { font-size: 1.2rem; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--mfr-border); }
.cta-widget { text-align: center; background: linear-gradient(135deg, var(--mfr-primary), var(--mfr-secondary)); color: #fff; border: none; }
.cta-widget h3 { color: #fff; border-color: rgba(255,255,255,0.2); }
.cta-widget .widget-btn { display: inline-block; background: #fff; color: var(--mfr-primary); padding: 10px 20px; border-radius: 8px; font-weight: 700; margin-top: 15px; transition: var(--mfr-transition); }
.cta-widget .widget-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }

/* Empty States */
.mafrosha-empty-state { background: var(--mfr-bg-alt); border-radius: var(--mfr-border-radius); border: 1px dashed var(--mfr-border); }

/* ==========================================================================
   7. Print Styles (تنسيقات الطباعة وحفظ كملف PDF)
   ========================================================================== */
@media print {
    body { background-color: #ffffff !important; color: #000000 !important; }
    
    button, .sidebar, .mafrosha-header, .mafrosha-footer, .floating-whatsapp, .scroll-to-top, .responsive-video-wrapper, .share-box, .post-share, .page-links, .header-actions {
        display: none !important;
    }
    
    .site-content.has-sidebar .content-area { width: 100% !important; }
    
    a { text-decoration: none; color: #000000 !important; }
    .entry-content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #555555; }
    
    img, table, figure, .card-image { page-break-inside: avoid; max-width: 100% !important; }
}

/* ==========================================================================
   8. [تم الإصلاح] التخطيط العمودي وضبط عرض البطاقات ليكون 100% (بطاقة واحدة في الصف)
   ========================================================================== */

/* إعداد حاوية الشبكة لدعم التقسيم بجوار بعضها */
.elementor-widget .elementor-posts-container,
.mafrosha-properties-grid,
.site-content .properties-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    justify-content: flex-start !important;
}

/* إجبار البطاقات على التخطيط العمودي وتحديد العرض بـ 100% (بطاقة واحدة) */
.elementor-widget .search-result-item.mafrosha-card,
.elementor-widget .mafrosha-card,
.property-card,
.mafrosha-card {
    display: flex !important;
    flex-direction: column !important; /* التوجيه العمودي الإجباري */
    
    /* 🌟 التعديل الجديد: مقاس العرض 100% لجميع الشاشات */
    width: 100% !important; 
    max-width: 100% !important;
    flex: 0 0 100% !important;
    
    height: auto !important;
    min-height: 100% !important;
    background: #fff !important;
    border-radius: 12px !important;
    overflow: hidden !important; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
    border: 1px solid #e5e7eb !important;
    margin: 0 !important;
}

/* حجز مساحة عرضية كاملة للصورة في الأعلى، ومنع انضغاطها تماماً */
.elementor-widget .search-result-item .search-image-wrapper,
.elementor-widget .search-result-item .search-image,
.elementor-widget .mafrosha-card .card-image,
.property-card .card-image,
.mafrosha-card .card-image {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 400px !important;     /* رفعنا طول الصورة بشكل ملحوظ لتناسب العرض الكامل (100%) */
    min-height: 400px !important; 
    flex: 0 0 400px !important;   
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.elementor-widget .search-result-item .search-image img,
.elementor-widget .search-result-item .search-image-wrapper img,
.elementor-widget .mafrosha-card .card-image img,
.property-card .card-image img,
.mafrosha-card .card-image img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    object-fit: cover !important;
    border-radius: 12px 12px 0 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* حجز مساحة للنصوص في الأسفل لتأخذ راحتها */
.elementor-widget .search-result-item .search-content,
.elementor-widget .mafrosha-card .card-body,
.property-card .card-body,
.mafrosha-card .card-body {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important; 
    width: 100% !important;
    max-width: 100% !important;
    padding: 30px !important; /* زدنا الحواف الداخلية قليلاً لتبدو أفضل على العرض الكامل */
    box-sizing: border-box !important;
    flex: 1 1 auto !important; 
    background: #fff !important;
    overflow: visible !important;
}

.elementor-widget .search-result-item .search-title,
.elementor-widget .mafrosha-card .card-title,
.property-card .card-title,
.mafrosha-card .card-title {
    font-size: 1.5rem !important; /* تكبير الخط ليتناسب مع البطاقة الكبيرة */
    margin-bottom: 12px !important;
    white-space: normal !important; 
    line-height: 1.5 !important;
    color: #1f2937 !important;
}

.elementor-widget .search-result-item .search-excerpt {
    margin-bottom: 15px !important;
    color: #6b7280 !important;
    font-size: 1.1rem !important;
}

/* دفع منطقة السعر (الفوتر) إلى الأسفل دائماً */
.elementor-widget .search-result-item .search-price,
.elementor-widget .search-result-item .btn-read-more,
.elementor-widget .mafrosha-card .card-footer,
.property-card .card-footer,
.mafrosha-card .card-footer {
    margin-top: auto !important; 
    padding-top: 20px !important;
    width: 100% !important;
}

/* ==========================================================================
   9. حماية تصميم نتائج البحث الفعلية (لتبقى أفقية خارج المنتور فقط)
   ========================================================================== */
body:not(.elementor-page) .search-result-item {
    display: flex !important;
    flex-direction: row !important; /* إجبار التخطيط ليكون أفقياً */
    gap: 20px;
    padding: 20px;
    margin-bottom: 20px;
    background: var(--mfr-bg-body) !important;
    border: 1px solid var(--mfr-border) !important;
    border-radius: var(--mfr-border-radius) !important;
    overflow: hidden !important;
    align-items: center !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
}

body:not(.elementor-page) .search-result-item .search-image-wrapper {
    width: 250px !important; 
    height: 180px !important;
    min-height: 180px !important;
    flex: 0 0 250px !important; /* منع الصورة من الانضغاط أفقياً */
    border-radius: 8px !important;
    overflow: hidden !important;
    margin: 0 !important;
}

body:not(.elementor-page) .search-result-item .search-image-wrapper img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    margin: 0 !important;
    border-radius: 8px !important;
}

body:not(.elementor-page) .search-result-item .search-content {
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    padding: 0 !important;
}

/* في شاشات الجوال، نجعل نتائج البحث عمودية لتناسب حجم الشاشة الصغير */
@media (max-width: 768px) {
    body:not(.elementor-page) .search-result-item {
        flex-direction: column !important;
    }
    body:not(.elementor-page) .search-result-item .search-image-wrapper {
        width: 100% !important;
        height: 200px !important;
        flex: 0 0 200px !important;
    }
}