/* ==========================================
   BatDongSan - Real Estate Platform Styles
   ========================================== */

/* --- Root Variables --- */
:root {
  --primary: #e03c31;
  --primary-dark: #c41e1e;
  --primary-light: #fff0ef;
  --secondary: #2c3e50;
  --accent: #ffc107;
  --success: #28a745;
  --info: #17a2b8;
  --dark: #1a1a2e;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-600: #6c757d;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* --- Base --- */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #333;
  background: var(--gray-100);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* --- Navbar --- */
.navbar {
  border-bottom: 3px solid var(--primary);
}

.navbar-brand {
  font-size: 1.4rem;
  letter-spacing: -0.5px;
}

.navbar .nav-link {
  font-weight: 500;
  font-size: 0.95rem;
}

.navbar .dropdown-menu {
  border: none;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

/* --- Button Overrides --- */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-warning {
  background: var(--accent);
  border-color: var(--accent);
  color: #333;
  font-weight: 600;
}

.btn-warning:hover {
  background: #e0a800;
  border-color: #d39e00;
}

/* --- Hero Search Section --- */
.hero-search {
  background: linear-gradient(135deg, #e03c31 0%, #c41e1e 50%, #8b0000 100%);
  padding: 3.5rem 0;
  position: relative;
  overflow: hidden;
}

.hero-search::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
  animation: heroPulse 8s ease-in-out infinite;
}

@keyframes heroPulse {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(2%, 2%); }
}

.hero-search .container {
  position: relative;
  z-index: 1;
}

.hero-search h1 {
  font-size: 2.5rem;
  letter-spacing: -1px;
}

.hero-search .form-control,
.hero-search .form-select {
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.hero-search .form-control:focus,
.hero-search .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
}

.hero-search .btn-warning {
  font-size: 0.95rem;
  height: 100%;
}

/* --- Stats Bar --- */
.stats-bar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}

/* --- Listing Card --- */
.listing-card {
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  background: #fff;
}

.listing-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.listing-card .card-img-top {
  transition: transform 0.4s ease;
}

.listing-card:hover .card-img-top {
  transform: scale(1.05);
}

.listing-card .image-wrapper {
  position: relative;
  overflow: hidden;
  height: 200px;
}

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

.listing-card .image-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.listing-card .price-tag {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.listing-card .type-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  z-index: 2;
}

.listing-card .featured-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
}

.listing-card .card-body {
  padding: 1rem;
}

.listing-card .card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-card .card-title a {
  color: var(--dark);
}

.listing-card .card-title a:hover {
  color: var(--primary);
}

.listing-card .listing-meta {
  font-size: 0.85rem;
  color: var(--gray-600);
}

.listing-card .listing-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* --- Category Card --- */
.category-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  transition: all 0.2s ease;
  background: #fff;
}

.category-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

/* --- Listing Detail --- */
.listing-detail-header {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.listing-detail-price {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
}

/* --- Gallery --- */
.listing-gallery {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.listing-gallery .carousel-item img {
  height: 450px;
  object-fit: contain;
}

.listing-thumbnails img {
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s ease;
}

.listing-thumbnails img:hover,
.listing-thumbnails img.active {
  border-color: var(--primary);
}

/* --- Info Grid --- */
.info-grid .info-item {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.info-grid .info-label {
  font-size: 0.8rem;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-grid .info-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #333;
}

/* --- Description --- */
.description-content {
  line-height: 1.9;
  font-size: 1rem;
  color: #444;
}

/* --- Contact Card --- */
.contact-card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.contact-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
}

/* --- Search Page --- */
.search-filters {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* --- Forms --- */
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(224, 60, 49, 0.15);
}

.card-form {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-form .card-header {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 600;
}

/* --- Flash Messages --- */
.alert {
  border: none;
  border-radius: var(--radius);
}

/* --- Footer --- */
footer {
  background: var(--dark);
  margin-top: auto;
}

footer h5, footer h6 {
  color: #fff;
}

footer a:hover {
  color: #fff !important;
}

/* --- Pagination --- */
.pagination .page-link {
  color: var(--primary);
  border-radius: var(--radius);
  margin: 0 2px;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

/* --- Dashboard --- */
.dashboard-card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
}

.dashboard-card .icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* --- Empty State --- */
.empty-state {
  padding: 3rem 0;
  text-align: center;
  color: var(--gray-600);
}

/* --- Breadcrumb --- */
.breadcrumb {
  background: transparent;
  padding: 0;
  font-size: 0.9rem;
}

/* --- Image Upload Preview --- */
.upload-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.upload-preview {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--gray-200);
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-preview .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-preview .primary-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.7rem;
  text-align: center;
  padding: 2px;
}

/* --- Price Formatting --- */
.price {
  font-variant-numeric: tabular-nums;
}

/* --- Responsive --- */
@media (max-width: 991.98px) {
  .hero-search {
    padding: 2rem 0;
  }

  .hero-search h1 {
    font-size: 1.75rem;
  }

  .hero-search .form-control-lg,
  .hero-search .form-select-lg {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
  }

  .listing-gallery .carousel-item img {
    height: 300px;
  }

  .listing-detail-price {
    font-size: 1.4rem;
  }
}

@media (max-width: 767.98px) {
  .listing-card .image-wrapper {
    height: 160px;
  }

  .navbar-brand {
    font-size: 1.1rem;
  }

  .hero-search h1 {
    font-size: 1.5rem;
  }

  .hero-search .lead {
    font-size: 0.95rem;
  }

  .listing-gallery .carousel-item img {
    height: 220px;
  }

  .info-grid .col-6 {
    margin-bottom: 0.75rem;
  }
}

@media (max-width: 575.98px) {
  .listing-card .image-wrapper {
    height: 200px;
  }

  .hero-search {
    padding: 1.5rem 0;
  }

  .hero-search h1 {
    font-size: 1.35rem;
  }

  .hero-search .lead {
    font-size: 0.85rem;
  }
}
