/* ===================================================
   سوق الحي - الصفحة الرئيسية + الخريطة
   =================================================== */

body.home-page {
    background: #FAFAF9;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Header ===== */
.home-header {
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 0;
}

.home-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.home-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
    text-decoration: none;
}

.home-logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 10px rgba(4, 120, 87, 0.25);
}

.home-logo-text {
    font-size: 18px;
    font-weight: 800;
    color: #1C1917;
    line-height: 1;
}

.home-logo-tagline {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}

.home-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-publish {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(234, 88, 12, 0.25);
}

.btn-publish:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(234, 88, 12, 0.35);
    color: white;
}

.btn-login {
    background: transparent;
    color: var(--primary);
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.btn-login:hover { background: var(--primary-pale); color: var(--primary); }

.btn-register {
    background: var(--primary);
    color: white;
    padding: 10px 18px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.btn-register:hover {
    background: var(--primary-dark);
    color: white;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    padding: 6px 14px 6px 6px;
    border-radius: 50px;
    text-decoration: none;
    color: #1C1917;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.user-chip:hover { background: var(--gray-200); color: #1C1917; }

.user-chip-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* ===== Filter Bar ===== */
.filter-bar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 12px 0;
    position: sticky;
    top: 68px;
    z-index: 90;
}

.filter-bar-inner {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
}

.search-field {
    width: 100%;
    padding: 11px 42px 11px 36px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 14px;
    background: var(--gray-50);
    transition: all 0.2s;
}

.search-field:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.search-clear {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-200);
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    font-size: 11px;
}

.filter-select {
    padding: 11px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    background: white;
    font-size: 13px;
    color: #1C1917;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Categories Bar ===== */
.categories-bar {
    margin-top: 12px;
    overflow: hidden;
}

.categories-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.categories-scroll::-webkit-scrollbar { height: 4px; }
.categories-scroll::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--gray-100);
    border: 2px solid transparent;
    border-radius: 50px;
    color: var(--gray-700);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-chip:hover {
    background: var(--gray-200);
}

.category-chip.active {
    background: var(--cat-color, var(--primary));
    color: white;
    border-color: var(--cat-color, var(--primary));
}

.category-chip-icon {
    font-size: 16px;
}

/* ===== Main Content ===== */
.home-main {
    padding: 20px 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    height: calc(100vh - 220px);
    min-height: 600px;
}

/* ===== Listings Panel ===== */
.listings-panel {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: #1C1917;
}

.panel-title #resultsCount {
    color: var(--primary);
    font-weight: 800;
}

.view-toggle {
    background: var(--gray-100);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    color: var(--gray-600);
}

.listings-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* بطاقة المنتج */
.listing-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    border: 2px solid transparent;
}

.listing-card:hover {
    background: var(--gray-50);
    border-color: var(--primary-pale);
}

.listing-card.highlighted {
    background: var(--primary-pale);
    border-color: var(--primary);
}

.listing-image {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.listing-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.listing-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    opacity: 0.5;
}

.listing-info {
    flex: 1;
    min-width: 0;
}

.listing-title {
    font-size: 14px;
    font-weight: 700;
    color: #1C1917;
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listing-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.listing-price.free {
    color: var(--accent);
}

.listing-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--gray-500);
    flex-wrap: wrap;
}

.listing-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* ===== Map Panel ===== */
.map-panel {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.map-container {
    width: 100%;
    height: 100%;
}

.map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
}

.map-control-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.map-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.legend-item:last-child { margin-bottom: 0; }

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px white, 0 0 0 3px rgba(0,0,0,0.1);
}

/* Custom Leaflet Markers */
.custom-marker {
    background: var(--primary);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.custom-marker.deal {
    background: var(--accent);
}

.custom-marker:hover {
    transform: scale(1.15);
}

/* Popup */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    width: 240px !important;
}

.popup-content {
    padding: 12px;
}

.popup-image {
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
    border-radius: 8px;
    margin-bottom: 10px;
    object-fit: cover;
}

.popup-title {
    font-size: 14px;
    font-weight: 700;
    color: #1C1917;
    margin-bottom: 4px;
}

.popup-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.popup-btn {
    display: block;
    width: 100%;
    background: var(--primary);
    color: white;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}

/* ===== Loading & Empty States ===== */
.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-listings {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-listings-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-listings-title {
    font-size: 16px;
    color: var(--gray-700);
    font-weight: 700;
    margin-bottom: 4px;
}

.empty-listings-cta {
    margin-top: 16px;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

.modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* ===== Responsive ===== */
@media (max-width: 968px) {
    .content-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .listings-panel { max-height: 50vh; }
    .map-panel { height: 60vh; }
}

@media (max-width: 640px) {
    .home-logo-tagline { display: none; }
    .home-logo-text { font-size: 16px; }
    .filter-bar { padding: 10px 0; }
    .filter-bar-inner { flex-direction: column; align-items: stretch; }
    .search-wrapper { max-width: none; }
    .filter-select { width: 100%; }
    .panel-title { font-size: 14px; }
}
