/* client/css/listing_detail_style.css */

:root {
    --primary-color: #2563eb; /* Deep blue for buttons and accents */
    --secondary-color: #64748b; /* Gray for secondary elements */
    --text-color: #1e293b; /* Dark gray for text */
    --light-text-color: #64748b; /* Light gray for secondary text */
    --border-color: #e2e8f0; /* Soft gray border */
    --background-light: #f1f5f9; /* Light gray background */
    --white-color: #ffffff; /* White for cards */
    --card-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); /* Card shadow */
    --border-radius: 0.5rem; /* 8px */
    --error-color: #dc2626; /* Red for errors */
    --success-color: #16a34a; /* Green for success */
}




/* Loading and Error Messages */
#loadingIndicator,
.error-message {
    text-align: center;
    font-size: 1.1rem;
    padding: 2rem;
    margin: 1rem 0;
    border-radius: var(--border-radius);
}
#loadingIndicator {
    color: var(--light-text-color);
    background-color: var(--white-color);
    border: 1px dashed var(--border-color);
}
.error-message {
    color: var(--error-color);
    background-color: #fee2e2;
    border: 1px solid #fecaca;
}

/* --- Main Grid Layout --- */
.listing-main-grid {
    display: grid;
    grid-template-columns: 3fr 1fr; /* Adjusted: wider main content */
    gap: 1.5rem;
    margin-top: 1rem;
}

/* --- Listing Container --- */
.listing-detail-container {
    background-color: var(--white-color);
    padding: 1rem;
    margin: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    max-width: 100%;
}

/* --- Meta Information --- */
.listing-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    font-size: 0.95rem;
    color: var(--light-text-color);
    margin-bottom: 2rem;
}
.listing-meta div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.listing-meta dt {
    font-weight: 600;
    color: var(--text-color);
    min-width: 80px;
}
.listing-meta dd {
    margin: 0;
}

/* --- Image Gallery --- */
.listing-images {
    margin-bottom: 2rem;
}
.main-image-wrapper {
    width: 100%;
    padding-bottom: 60%; /* ~16:9 aspect ratio */
    position: relative;
    background-color: var(--background-light);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}
.main-image-wrapper:hover {
    transform: scale(1.02);
}
.main-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.thumbnail-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.thumbnail-wrapper img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.25rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s ease, opacity 0.2s ease;
}
.thumbnail-wrapper img:hover {
    border-color: var(--primary-color);
    opacity: 0.9;
}
.thumbnail-wrapper img.active-thumbnail {
    border-color: var(--primary-color);
    opacity: 1;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.3);
}

/* --- Listing Header --- */
.listing-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

h1.listing-title {
    font-size: 2rem;
    line-height: 1.3;
    color: var(--text-color);
    font-weight: 700;
    margin: 0;
    flex: 1;
}

.favorite-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.8rem;
    color: #d1d5db; /* Gray when not favorited */
    padding: 0.5rem;
    transition: color 0.2s ease, transform 0.2s ease;
}
.favorite-btn:hover {
    color: var(--error-color);
    transform: scale(1.1);
}
.favorite-btn.active i.fas.fa-heart {
    color: var(--error-color);
}

/* --- Lightbox --- */
.image-lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
}
.image-lightbox img {
    max-width: 90%;
    max-height: 80vh;
    border-radius: 0.5rem;
    animation: lightboxZoom 0.3s ease;
}
@keyframes lightboxZoom {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.image-lightbox .close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}
.image-lightbox .close-lightbox:hover {
    color: #d1d5db;
}

/* --- Content Sections --- */
.listing-section {
    margin-bottom: 2rem;
}
.listing-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.listing-text-content {
    line-height: 1.8;
    color: var(--text-color);
    white-space: pre-wrap;
    font-size: 1rem;
    white-space: pre-wrap;       /* Это свойство сохраняет переносы строк и пробелы */
    word-wrap: break-word;      /* Чтобы очень длинные слова не "разрывали" блок */
    overflow-wrap: break-word;
}

/* --- Services --- */
#listingServices .service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}
#listingServices .service-item:last-child {
    border-bottom: none;
}
#listingServices .service-name {
    color: var(--text-color);
    flex: 1;
}
#listingServices .service-price {
    font-weight: 600;
    color: var(--success-color);
    white-space: nowrap;
}

/* --- Contact Info --- */
.contact-info {
    font-size: 0.95rem;
    color: var(--text-color);
}
.contact-info p {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.contact-info p strong {
    min-width: 120px;
    font-weight: 600;
    color: var(--text-color);
}
.contact-info a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}
.contact-info a:hover {
    color: #1e40af;
}

/* --- Map --- */
#listingMap {
    height: 200px; /* Smaller height for sidebar */
    background-color: var(--background-light);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--light-text-color);
    font-style: italic;
}

/* --- Reviews --- */
.reviews-section {
    background-color: var(--white-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin: 1.5rem 0; /* Adjusted for sidebar */
}
.reviews-section h2 {
    font-size: 1.25rem; /* Slightly smaller in sidebar */
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
#reviewsList .review-item {
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    background-color: var(--white-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#reviewsList .review-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
#reviewsList .review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
#reviewsList .review-author {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}
#reviewsList .review-date {
    font-size: 0.8rem;
    color: var(--light-text-color);
}
#reviewsList .review-rating .fa-star {
    color: #f59e0b;
    font-size: 0.85rem;
}
#reviewsList .review-comment {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
}
#reviewsList .review-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

/* --- Review Form --- */
#addReviewSection {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
#addReviewSection h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}
.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
.form-control textarea {
    resize: vertical;
    min-height: 80px;
}

/* --- Sidebar --- */
.listing-sidebar-column .sidebar-block {
    background-color: var(--white-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}
.sidebar-block h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* --- Sidebar Meta Info --- */
.listing-meta-info p {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.listing-meta-info p i {
    margin-right: 0.5rem;
    color: #6b7280;
}
.listing-meta-info p a {
    color: var(--primary-color);
    text-decoration: none;
}
.listing-meta-info p a:hover {
    color: #1e40af;
}

/* --- Responsive Design --- */
@media (max-width: 992px) {
    .listing-main-grid {
        grid-template-columns: 1fr; /* Stack columns on smaller screens */
    }
    .listing-sidebar-column {
        margin-top: 1rem;
    }
    #listingMap {
        height: 250px; /* Larger map height when stacked */
    }
    .reviews-section {
        margin: 1rem 0;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1.5rem 0.75rem;
    }
    .listing-detail-container {
        padding: 1.5rem;
        margin: 1.5rem 0.5rem;
    }
    h1.listing-title {
        font-size: 1.75rem;
    }
    .main-image-wrapper {
        padding-bottom: 65%;
    }
    .thumbnail-wrapper img {
        width: 70px;
        height: 50px;
    }
    .listing-section h2 {
        font-size: 1.3rem;
    }
    .reviews-section h2 {
        font-size: 1.2rem;
    }
    #reviewsList .review-item {
        padding: 0.75rem;
    }
    #reviewsList .review-author {
        font-size: 0.9rem;
    }
    #reviewsList .review-comment {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem 0.5rem;
    }
    .listing-detail-container {
        padding: 1rem;
        margin: 1rem 0.25rem;
    }
    h1.listing-title {
        font-size: 1.3rem;
    }
    .thumbnail-wrapper img {
        width: 60px;
        height: 45px;
    }
    #listingMap {
        height: 200px;
    }
    .listing-meta {
        grid-template-columns: 1fr;
    }
    .reviews-section {
        padding: 1rem;
    }
    .form-group label {
        font-size: 0.85rem;
    }
    .form-control {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

}