/* Mobile-First Responsive Design System for SoonerExchange */

/* Reset and Base Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Poppins:wght@600;700&display=swap');

* {
  box-sizing: border-box;
}

html {
  font-size: 14px; /* Smaller base font for mobile */
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 400;
  line-height: 1.4; /* Tighter line height for mobile */
  background-color: #990000;
  color: #FFFDD0;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Responsive font sizes */
@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

/* Flexbox Layout for Sticky Footer */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1;
  padding: 0.5rem; /* Much smaller padding on mobile */
}

@media (min-width: 768px) {
  main {
    padding: 1rem;
  }
}

@media (min-width: 1024px) {
  main {
    padding: 2rem 1rem;
  }
}

/* Mobile-first Container */
.container {
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding: 0 0.5rem;
}

@media (min-width: 768px) {
  .container {
    padding: 0 1rem;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1280px;
  }
}

/* Mobile-First Grid System */
.grid {
  display: grid;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .grid {
    gap: 1rem;
  }
}

/* Mobile-first grid classes */
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr; } /* Stack on mobile */
.grid-3 { grid-template-columns: 1fr; } /* Stack on mobile */
.grid-4 { grid-template-columns: 1fr; } /* Stack on mobile */

@media (min-width: 480px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Mobile-First Listings Grid - Always 2 columns per row */
.listings-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important; /* 2 columns per row */
  gap: 0.5rem !important;
}

/* Same 2-column layout for logged-in users */
.logged-in .listings-grid {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 0.5rem !important;
}

@media (min-width: 480px) {
  .listings-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .logged-in .listings-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    gap: 1rem;
  }
}

@media (min-width: 768px) {
  .listings-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (min-width: 1024px) {
  .listings-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

/* Utility: ensure flex items can shrink instead of overflowing their container.
   Fixes cases where buttons inside a flex row get cut off on small widths. */
.flex > * {
  min-width: 0;
}

/* Mobile-First Button Layouts */
.btn-row {
  display: flex;
  flex-direction: column; /* Stack on mobile */
  gap: 0.5rem;
}

.btn-row > * {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem; /* Better touch targets */
  font-size: 0.9rem;
  text-align: center;
}

@media (min-width: 480px) {
  .btn-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .btn-row > * {
    flex: 1 1 48%;
  }
  
  .btn-row > .msg-btn {
    flex-basis: 100%;
  }
}

/* Utility classes */
.hidden {
  display: none !important;
}

.mobile-only {
  display: block;
}

.desktop-only {
  display: none;
}

@media (min-width: 768px) {
  .mobile-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
}

/* Mobile-First Navigation */
.nav {
  background-color: #FFFDD0;
  color: #990000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-container {
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .nav-container {
    max-width: 1280px;
  }
}

.nav-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  width: 100%;
}

/* Mobile navigation layout - force proper positioning */
@media (max-width: 767px) {
  .nav-top {
    padding: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .nav-brand {
    order: 1;
    flex: 0 0 auto;
    margin-right: auto;
  }
  
  .nav-toggle {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
  }
  
  .nav-links {
    order: 3;
  }
}

.nav-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .nav-bottom {
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }
}

.nav-brand {
  color: #990000;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  margin: 0;
  display: flex;
  align-items: center;
  flex: 1;
}

.nav-brand img,
.nav-logo {
  height: 32px;
  width: auto;
  margin-right: 8px;
  object-fit: contain;
}

/* Mobile logo sizing - bigger on mobile */
@media (max-width: 767px) {
  .nav-brand img,
  .nav-logo {
    height: 60px !important;
    width: auto !important;
    margin-right: 0;
  }
  
  .nav-brand {
    margin: 0;
    padding: 0;
    flex-shrink: 0;
  }
  
  .nav-brand a {
    display: flex !important;
    align-items: center !important;
  }
}

@media (min-width: 768px) {
  .nav-brand {
    flex: none;
  }
  
  .nav-brand img,
  .nav-logo {
    height: 40px;
    margin-right: 10px;
  }
}

/* Mobile hamburger menu - positioned in right corner */
.nav-toggle {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  padding: 0.75rem;
  gap: 4px;
  background: none;
  border: none;
  z-index: 1001;
  margin-left: auto;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .nav-toggle {
    display: flex !important;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
  }
}

.nav-toggle span {
  width: 24px;
  height: 3px;
  background-color: #990000;
  transition: 0.3s;
  border-radius: 1px;
}

@media (min-width: 768px) {
  .nav-toggle {
    display: none;
  }
}

.nav-links {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background-color: #FFFDD0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  padding: 0.5rem;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 150px;
  z-index: 1000;
}

.nav-links.active {
  display: flex;
}

@media (min-width: 768px) {
  .nav-links {
    display: flex;
    position: static;
    flex-direction: row;
    background: none;
    box-shadow: none;
    padding: 0;
    gap: 1rem;
    min-width: auto;
  }
}

/* Home button - positioned next to hamburger */
.home-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: #990000;
  color: #FFFDD0;
  border-radius: 50%;
  text-decoration: none;
  font-size: 1.2rem;
  transition: all 0.3s ease;
  margin-right: 0.5rem;
  box-shadow: 0 2px 8px rgba(153, 0, 0, 0.3);
}

.home-button:hover {
  background-color: #b71c1c;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(153, 0, 0, 0.4);
  color: #FFFDD0;
  text-decoration: none;
}

@media (max-width: 767px) {
  .home-button {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
  
  .home-button:hover {
    transform: translateY(-50%) translateY(-2px);
  }
}

.nav-link {
  color: #990000;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 0.9rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.nav-link:hover {
  background-color: #990000;
  color: #FFFDD0;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(153, 0, 0, 0.3);
}

.nav-link:active {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .nav-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.95rem;
  }
}

/* Mobile-First Cards - Smaller on mobile */
.card {
  background: linear-gradient(135deg, #FFFDD0, #f5f5dc);
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 0.75rem;
  border: 1px solid rgba(255, 253, 208, 0.3);
  transition: all 0.3s ease;
  color: #333333;
  position: relative;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

@media (max-width: 767px) {
  .card {
    padding: 0.75rem;
    border-radius: 0.5rem;
  }
}

@media (min-width: 768px) {
  .card {
    padding: 1.25rem;
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    font-size: 1rem;
  }
}

/* Mobile listing card content - optimized for 2 column layout */
@media (max-width: 767px) {
  .card img {
    height: 120px !important;
    width: 100% !important;
    object-fit: cover;
    border-radius: 0.375rem;
  }
  
  .card h3 {
    font-size: 0.85rem;
    margin: 0.5rem 0 0.25rem 0;
    line-height: 1.2;
    font-weight: 600;
  }
  
  .card h4 {
    font-size: 0.75rem;
    margin: 0.2rem 0;
  }
  
  .card p {
    font-size: 0.7rem;
    line-height: 1.3;
    margin: 0.25rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .card .price {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.25rem;
  }
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #990000, #b71c1c, #990000);
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (min-width: 768px) {
  .card::before {
    height: 4px;
  }
}

/* Reduce hover effects on mobile */
@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
  }
  
  .card:hover::before {
    opacity: 1;
  }
}

@media (min-width: 768px) and (hover: hover) {
  .card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  }
}

/* Mobile-First Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 500;
  text-align: center;
  border: none;
  cursor: pointer;
  transition: all 0.24s ease;
  font-size: 0.9rem;
  min-height: 44px; /* Better touch target */
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-family: 'Poppins', 'Inter', sans-serif;
}

@media (min-width: 768px) {
  .btn {
    padding: 0.65rem 1.25rem;
    border-radius: 0.6rem;
    font-size: 0.95rem;
    font-weight: 600;
    min-height: auto;
    display: inline-block;
  }
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #990000, #b71c1c);
  color: #FFFDD0;
  box-shadow: 0 4px 15px rgba(153, 0, 0, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #b71c1c, #d32f2f);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(153, 0, 0, 0.4);
}

.btn-secondary {
  background-color: #1976d2;
  color: #FFFDD0;
}

.btn-secondary:hover {
  background-color: #1565c0;
  transform: translateY(-1px);
}

.btn-danger {
  background-color: #d32f2f;
  color: #FFFDD0;
}

.btn-danger:hover {
  background-color: #c62828;
  transform: translateY(-1px);
}

/* Mobile-First Search Styles */
.search-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .search-container {
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(153, 0, 0, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
  .search-form {
    flex-direction: row;
    max-width: 600px;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    gap: 1rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(153, 0, 0, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  }
}

/* Mobile-first search row */
.search-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .search-row {
    flex-direction: row;
    gap: 0.75rem;
    align-items: center;
    max-width: 900px;
    margin: 0 auto;
  }
}

/* Nudge search slightly to the right on wide screens */
@media (min-width: 1025px) {
  .search-row { transform: translateX(6%); }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .search-row { transform: translateX(3%); }
}

.search-actions {
  display: flex;
  align-items: center;
}

/* Small action button next to search bars */
.search-action-btn {
  padding: 0.65rem 1rem;
  border-radius: 25px;
  background: linear-gradient(135deg, #990000, #b71c1c); /* brand red */
  color: #FFFDD0;
  text-decoration: none;
  font-weight: 700;
  font-family: 'Poppins', 'Inter', sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.search-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(153, 0, 0, 0.3);
  background: linear-gradient(135deg, #b71c1c, #d32f2f);
}

.search-action-btn:active {
  transform: translateY(0);
}

/* Responsive: stack search and action on small screens */
@media (max-width: 640px) {
  .search-row {
    flex-direction: column;
  }
  .search-action-btn, .search-btn {
    width: 100%;
  }
}

.search-input {
  flex: 1;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  background: transparent;
  color: #333;
  outline: none;
  transition: all 0.3s ease;
}

.search-input:focus {
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.search-input::placeholder {
  color: #666;
  font-style: italic;
}

.search-btn {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #990000, #b71c1c);
  color: #FFFDD0;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 3px 12px rgba(153, 0, 0, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-btn:hover {
  background: linear-gradient(135deg, #b71c1c, #d32f2f);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(153, 0, 0, 0.4);
}

.search-btn:active {
  transform: translateY(0);
}

/* Responsive Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #FFFDD0;
  font-family: 'Poppins', 'Inter', sans-serif;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #b0bec5;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-weight: 600;
  transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: #990000;
  box-shadow: 0 0 0 3px rgba(153, 0, 0, 0.1);
}

/* Responsive Images */
.img-responsive {
  width: 100%;
  height: auto;
  max-width: 100%;
}

.img-listing {
  width: 100%;
  height: 12rem;
  object-fit: cover;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

/* Responsive Footer */
.footer {
  background-color: #990000;
  color: #FFFDD0;
  border-top: 1px solid rgba(255, 253, 208, 0.2);
  padding: 1.5rem 1rem;
  text-align: center;
  margin-top: auto;
}

.footer-content {
  max-width: 1280px;
  margin: 0 auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.footer-link {
  color: #FFFDD0;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Responsive Typography */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.35rem; }
.text-2xl { font-size: 1.6rem; }

/* Headings */
h1, h2, h3, h4, h5 {
  font-family: 'Poppins', 'Inter', sans-serif;
  color: #990000;
  margin: 0 0 0.5rem 0;
  line-height: 1.15;
}

h1 { font-size: 2rem; letter-spacing: 0.6px; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

.font-bold { font-weight: bold; }
.font-semibold { font-weight: 600; }

/* Responsive Spacing */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

/* Responsive Flexbox Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* Mobile First Responsive Breakpoints */
@media (max-width: 640px) {
  .nav-container {
    gap: 0.5rem;
  }
  
  .nav-top {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  
  .nav-links {
    justify-content: center;
  }
  
  /* Removed conflicting rule - using main mobile-first grid instead */
  
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  
  main {
    padding: 0.5rem;
  }
  
  .container {
    padding: 0 0.5rem;
  }
  
  .search-form {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }
  
  .search-input {
    width: 100%;
    font-size: 0.9rem;
  }
  
  .search-btn {
    width: 100%;
    font-size: 0.9rem;
  }
  
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .footer-links {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .nav-brand img,
  .nav-logo {
    height: 36px !important;
    margin-right: 8px !important;
  }

  .nav {
    padding: 0.25rem 0.4rem;
    min-height: 48px;
  }
}

@media (min-width: 641px) and (max-width: 768px) {
  /* Using main mobile-first grid rules instead of overriding */
  
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-3, .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .nav-brand img,
  .nav-logo {
    height: 48px;
    margin-right: 12px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  /* Desktop rules - keeping our mobile-first approach */
  
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1025px) {
  /* Desktop rules - keeping our mobile-first approach */
  
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .nav-brand img,
  .nav-logo {
    height: 56px;
    margin-right: 18px;
  }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .img-responsive, .img-listing {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Print Styles */
@media print {
  .nav, .footer {
    display: none;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .btn {
    display: none;
  }
}

/* Market page theme overrides: cream background and darker text for readability */
.market-page {
  background-color: #FFFDF0; /* soft cream */
  color: #333333;
}
.market-page .nav {
  background-color: #FFFDF0; /* blend nav into page */
  color: #990000;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.market-page .nav-link { color: #990000; }
.market-page .search-action-btn {
  background: linear-gradient(135deg, #6b4a3b, #8b6b50); /* subtle earth tones to contrast cream */
  color: #fffdf0;
}

.market-page .search-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  background: linear-gradient(135deg, #8b6b50, #a07e60);
}

.market-page .card {
  background: linear-gradient(135deg, #fffdf0, #f7f4e6);
  color: #333333;
}
.market-page .footer {
  background-color: #fffdf0;
  color: #333333;
}

/* Make common nav actions look like primary action buttons (match listing Buy styling)
   This targets the nav links by their href so we don't need to edit every header template.
   Applies to Profile, Post, How to Create, Admin and Sign Out links. */
.nav-link[href="/profile"],
.nav-link[href="/post"],
.nav-link[href="/how-to-create"],
.nav-link[href="/admin/listings"],
.nav-link[href="/signout"] {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  background: linear-gradient(135deg, #990000, #b71c1c);
  color: #FFFDD0;
  border-radius: 0.375rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(153, 0, 0, 0.2);
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.nav-link[href="/profile"]:hover,
.nav-link[href="/post"]:hover,
.nav-link[href="/how-to-create"]:hover,
.nav-link[href="/admin/listings"]:hover,
.nav-link[href="/signout"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(153, 0, 0, 0.28);
  background: linear-gradient(135deg, #b71c1c, #d32f2f);
}

/* Ensure the button-like links remain legible in the market-page theme */
.market-page .nav-link[href="/profile"],
.market-page .nav-link[href="/post"],
.market-page .nav-link[href="/how-to-create"],
.market-page .nav-link[href="/admin/listings"],
.market-page .nav-link[href="/signout"] {
  background: linear-gradient(135deg, #990000, #b71c1c);
  color: #FFFDF0;
}

/* Welcome Block - Much smaller on mobile */
.welcome-block {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 0.5rem;
  margin-bottom: 2rem;
  text-align: center;
  padding: 2rem;
}

@media (max-width: 767px) {
  .welcome-block {
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 0.375rem;
  }
}

.welcome-title {
  color: #990000;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

@media (max-width: 767px) {
  .welcome-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }
}

.welcome-subtitle {
  color: #666;
  margin-bottom: 1.5rem;
}

@media (max-width: 767px) {
  .welcome-subtitle {
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
  }
}

.welcome-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .welcome-buttons {
    flex-direction: column;
    gap: 0.5rem;
  }
}

.signup-option {
  background: #f8f8f8;
  padding: 1rem;
  border-radius: 0.25rem;
  flex: 1;
  min-width: 200px;
}

@media (max-width: 767px) {
  .signup-option {
    padding: 0.5rem;
    min-width: auto;
  }
}

.signup-option h3 {
  color: #990000;
  margin-bottom: 0.5rem;
}

@media (max-width: 767px) {
  .signup-option h3 {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
  }
}

.signup-option p {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

@media (max-width: 767px) {
  .signup-option p {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
    line-height: 1.2;
  }
}

/* Profile Page Mobile Optimization */
.profile-main {
  flex: 1;
  padding: 2rem;
  background-color: transparent;
}

@media (max-width: 767px) {
  .profile-main {
    padding: 1rem 0.5rem;
  }
}

.profile-header {
  margin-bottom: 3rem;
  background-color: #FFFDD0;
  padding: 2rem;
  border-radius: 0.5rem;
}

@media (max-width: 767px) {
  .profile-header {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 0.375rem;
  }
}

.profile-banner {
  display: flex;
  align-items: center;
  gap: 2rem;
}

@media (max-width: 767px) {
  .profile-banner {
    gap: 1rem;
    align-items: flex-start;
  }
}

.profile-picture {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #990000;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .profile-picture {
    width: 70px;
    height: 70px;
    border: 2px solid #990000;
  }
}

.profile-info {
  color: #990000;
  flex: 1;
}

.profile-username {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

@media (max-width: 767px) {
  .profile-username {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
  }
}

.profile-email {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  margin: 0 0 0.5rem 0;
}

@media (max-width: 767px) {
  .profile-email {
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
  }
}

.profile-stats {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 767px) {
  .profile-stats {
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
  }
}

.profile-rating {
  margin-top: 0.5rem;
  color: #333333;
  margin: 0.5rem 0 0 0;
}

@media (max-width: 767px) {
  .profile-rating {
    font-size: 0.75rem;
    margin-top: 0.3rem;
  }
}

.profile-rating.no-reviews {
  color: #666666;
}

.rating-score {
  font-size: 1rem;
  font-weight: 700;
  color: #990000;
}

@media (max-width: 767px) {
  .rating-score {
    font-size: 0.8rem;
  }
}

.reviews-link {
  color: #1976d2;
  margin-left: 0.5rem;
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 767px) {
  .reviews-link {
    font-size: 0.7rem;
    margin-left: 0.25rem;
  }
}


/* ==================== Listing Detail Page Responsive Styles ==================== */

/* Compact seller info at top */
.seller-info-compact {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 1rem;
}

.seller-compact-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.seller-compact-avatar {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  flex-shrink: 0 !important;
  border: 2px solid #990000;
  min-width: 48px !important;
  max-width: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  aspect-ratio: 1/1;
}

@media (max-width: 767px) {
  .seller-compact-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
  }
}

.seller-compact-details {
  flex: 1;
}

.seller-compact-name {
  font-weight: 600;
  margin: 0 0 0.25rem 0;
  color: #990000;
  font-size: 0.95rem;
}

@media (max-width: 767px) {
  .seller-compact-name {
    font-size: 0.9rem;
  }
}

.seller-compact-rating {
  margin: 0;
  font-size: 0.8rem;
  color: #666;
}

@media (max-width: 767px) {
  .seller-compact-rating {
    font-size: 0.75rem;
  }
}

/* Header with back button */
.listing-header {
  max-width: 1100px;
  margin: 1rem auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

@media (max-width: 767px) {
  .listing-header {
    margin: 0.5rem auto;
  }
}

.listing-back-btn {
  background-color: #666666;
  color: #FFFDD0;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
}

@media (max-width: 767px) {
  .listing-back-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* Main listing card */
.listing-card {
  max-width: 1100px;
  margin: 0 auto 2rem;
}

@media (max-width: 767px) {
  .listing-card {
    margin: 0 auto 1rem;
    padding: 0.75rem;
  }
}

/* Image gallery */
.listing-gallery {
  margin-bottom: 1.5rem;
}

@media (max-width: 767px) {
  .listing-gallery {
    margin-bottom: 1rem;
  }
}

.listing-main-image {
  width: 100%;
  height: 80vh;
  max-height: 1000px;
  min-height: 600px;
  object-fit: contain;
  border-radius: 0.5rem;
  background-color: #f9f9f9;
}

@media (max-width: 767px) {
  .listing-main-image {
    height: 60vh;
    max-height: 600px;
    min-height: 400px;
  }
}

.listing-thumbnails {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}

@media (max-width: 767px) {
  .listing-thumbnails {
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}

.thumbnail-image {
  height: 100px;
  width: 100px;
  object-fit: cover;
  border-radius: 0.375rem;
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .thumbnail-image {
    height: 70px;
    width: 70px;
  }
}

/* Content below images */
.listing-content-bottom {
  width: 100%;
}

/* Title and price - below image */
.listing-title {
  font-size: 1.75rem;
  color: #990000;
  margin: 1.5rem 0 0.5rem 0;
  word-wrap: break-word;
  font-weight: 600;
}

@media (max-width: 767px) {
  .listing-title {
    font-size: 1.4rem;
    margin: 1rem 0 0.4rem 0;
  }
}

.listing-price {
  font-size: 1.5rem;
  font-weight: bold;
  color: #990000;
  margin: 0 0 1.5rem 0;
}

@media (max-width: 767px) {
  .listing-price {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }
}

/* Sections */
.listing-section {
  margin-bottom: 1.5rem;
}

@media (max-width: 767px) {
  .listing-section {
    margin-bottom: 1rem;
  }
}

.listing-section-title {
  font-size: 0.95rem;
  color: #990000;
  margin: 0 0 0.5rem 0;
  font-weight: 600;
}

@media (max-width: 767px) {
  .listing-section-title {
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
  }
}

.listing-description {
  white-space: pre-wrap;
  color: #333333;
  word-wrap: break-word;
  font-size: 0.9rem;
  line-height: 1.5;
}

@media (max-width: 767px) {
  .listing-description {
    font-size: 0.85rem;
  }
}

/* Shipping options */
.shipping-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shipping-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background-color: #FFFDD0;
  border-radius: 0.375rem;
  border: 1px solid #990000;
}

@media (max-width: 767px) {
  .shipping-option {
    padding: 0.5rem;
    flex-wrap: wrap;
  }
}

.shipping-type {
  color: #333;
  font-weight: 500;
}

@media (max-width: 767px) {
  .shipping-type {
    font-size: 0.875rem;
  }
}

.shipping-cost {
  color: #990000;
  font-weight: bold;
}

@media (max-width: 767px) {
  .shipping-cost {
    font-size: 0.875rem;
  }
}



/* Pending notice */
.pending-notice {
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 767px) {
  .pending-notice {
    padding: 0.75rem;
  }
}

.pending-title {
  color: #856404;
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

@media (max-width: 767px) {
  .pending-title {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
  }
}

.pending-text {
  color: #856404;
  margin: 0;
  font-size: 0.875rem;
}

@media (max-width: 767px) {
  .pending-text {
    font-size: 0.8rem;
  }
}

/* Lease specific */
.lease-price {
  font-weight: bold;
}

.contact-header {
  margin-top: 0.5rem;
}

.lease-notice {
  color: #b91c1c;
}

@media (max-width: 767px) {
  .lease-notice {
    font-size: 0.875rem;
  }
}

/* Purchase section */
.purchase-section {
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

.buy-btn {
  width: 100%;
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
}

@media (max-width: 767px) {
  .buy-btn {
    padding: 0.75rem;
    font-size: 0.95rem;
  }
}

/* Total box */
.total-box {
  background-color: #f8f9fa;
  padding: 0.875rem;
  border-radius: 0.375rem;
  margin: 1.5rem 0 1rem 0;
  border: 1px solid #ddd;
}

@media (max-width: 767px) {
  .total-box {
    padding: 0.75rem;
    margin: 1rem 0 0.75rem 0;
  }
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 1rem;
}

@media (max-width: 767px) {
  .total-row {
    font-size: 0.95rem;
  }
}

/* ==================== User Profile Page Responsive Styles ==================== */

/* Compact Profile Block */
.user-profile-compact {
  margin-bottom: 1.5rem;
  padding: 1rem;
}

@media (max-width: 767px) {
  .user-profile-compact {
    padding: 0.875rem;
  }
}

.user-profile-compact-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .user-profile-compact-content {
    gap: 0.75rem;
  }
}

.user-profile-compact-avatar {
  width: 60px !important;
  height: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  min-height: 60px !important;
  max-height: 60px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: 2px solid #990000;
  flex-shrink: 0 !important;
  aspect-ratio: 1/1;
}

@media (max-width: 767px) {
  .user-profile-compact-avatar {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
  }
}

.user-profile-compact-info {
  flex: 1;
  min-width: 150px;
}

.user-profile-compact-name {
  color: #990000;
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 0.25rem 0;
}

@media (max-width: 767px) {
  .user-profile-compact-name {
    font-size: 1rem;
  }
}

.user-profile-compact-member {
  color: #666;
  font-size: 0.8rem;
  margin: 0;
}

@media (max-width: 767px) {
  .user-profile-compact-member {
    font-size: 0.75rem;
  }
}

.user-profile-compact-stats {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .user-profile-compact-stats {
    gap: 0.75rem;
    width: 100%;
  }
}

.user-stat-compact {
  color: #666;
  font-size: 0.85rem;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .user-stat-compact {
    font-size: 0.8rem;
  }
}

.user-stat-compact strong {
  color: #990000;
  font-weight: 700;
}

.user-profile-compact-reviews-link {
  background: #990000;
  color: #FFFDD0;
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  margin-left: auto;
}

@media (max-width: 767px) {
  .user-profile-compact-reviews-link {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    width: 100%;
    text-align: center;
    margin-left: 0;
  }
}

/* Listings title */
.user-listings-title {
  color: #990000;
  font-weight: bold;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

@media (max-width: 767px) {
  .user-listings-title {
    font-size: 1.25rem;
  }
}
