/* --- General Styling & Variables --- */
:root {
  --primary-color: #D42D35;
  --secondary-color: #0033A0;
  --gold-color: #D4AF37;
  --text-color: #212529;
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --border-color: #e9ecef;
  --muted-color: #6c757d;
  --header-height: 80px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--secondary-color);
}

/* --- Header --- */
.site-header {
  background: white;
  height: var(--header-height);
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.logo-link {
  display: flex;
  align-items: center;
  height: 100%;
}

.logo-image {
  height: 60px;
  width: auto;
}

/* --- Authentication Area --- */
.auth-area {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto; /* Push to the right */
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-name {
  font-weight: 500;
  display: block;
}

.avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

/* --- Buttons & Forms --- */
.auth-button, button, input[type="submit"] {
  background: var(--primary-color);
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.auth-button:hover, button:hover, input[type="submit"]:hover {
  background: #B82229;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#auth-area .post-ad-button {
    background-color: var(--secondary-color);
}
#auth-area .post-ad-button:hover {
    background-color: #002269;
}

.logout-button {
  background-color: var(--muted-color);
}

.logout-button:hover {
  background-color: #555;
}

input, select, textarea {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Poppins', sans-serif;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 4px rgba(0, 51, 160, 0.1);
}

/* --- Rich Text Editor Toolbar --- */
.editor-toolbar {
  background-color: #f8f9fa;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  flex-wrap: nowrap; /* keep single row */
  overflow-x: auto; /* allow horizontal scroll on small screens */
  white-space: nowrap;
  scrollbar-width: thin;
}

.editor-toolbar::-webkit-scrollbar {
  height: 6px;
}
.editor-toolbar::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}
.editor-toolbar::-webkit-scrollbar-track {
  background: transparent;
}

/* Toolbar buttons */
.toolbar-btn {
  background: #fff;
  color: var(--text-color);
  border: 1px solid #ced4da;
  border-radius: 6px;
  width: 38px;
  height: 38px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.toolbar-btn:hover {
  background-color: var(--secondary-color);
  color: #fff;
  border-color: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Dropdown (font size selector) */
.toolbar-select {
appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid #ced4da;
  border-radius: 6px;
  height: 38px;
  font-size: 0.95rem;
  padding: 0 0.6rem;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 80px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.toolbar-select:hover {
  background-color: var(--secondary-color);
  color: #fff;
  border-color: var(--secondary-color);
}

/* Color picker */
.toolbar-color {
  width: 38px;
  height: 38px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  background-clip: content-box;
  flex: 0 0 auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Editor body */
.custom-editor {
background-color: #e8e8e8;
  border: 1px solid var(--border-color);
  padding: 15px;
  min-height: 200px;
  border-radius: 0 0 8px 8px;
  margin-top: -1px;
  resize: vertical;
  overflow: auto;
  line-height: 1.7;
}
.custom-editor:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 4px rgba(0, 51, 160, 0.1);
}


/* Hover effects */
.toolbar-btn:hover,
.toolbar-select:hover {
  background-color: var(--secondary-color);
  color: #fff;
  border-color: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}



/* --- Homepage Hero Section --- */
.hero-section {
  background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('/assets/img/hero-background.jpg');
  background-size: cover;
  background-position: center;
  padding: 6rem 1.5rem;
  text-align: center;
  color: white;
}

.hero-content h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-content p {
  font-size: 1.25rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.search-bar-hero {
  max-width: 800px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-bar-hero form {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr auto;
  gap: 1rem;
}

.search-bar-hero input,
.search-bar-hero select {
  border: none;
  box-shadow: none;
}

.search-bar-hero button {
  background-color: var(--primary-color);
}

/* --- Ad Listing --- */
main.container {
  padding-top: 0;
}

.ad-listing-container {
  background-color: var(--bg-color);
}

.ad-listing-container h2 {
  text-align: center;
  font-size: 2rem;
  margin-top: 2.5rem;
  margin-bottom: 1.5rem;
}

.ad-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.ad-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.ad-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.ad-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.ad-card-content {
  padding: 1rem;
}

.ad-card h3 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  color: var(--text-color);
  font-weight: 600;
}

.meta {
  font-size: 0.85rem;
  color: var(--muted-color);
  margin-bottom: 0.5rem;
}

.price {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 1.2rem;
}

.ad-card a {
  text-decoration: none;
  color: inherit;
}

/* --- Load More Button --- */
#load-more-container {
  text-align: center;
  margin: 2rem 0;
}
.loader {
  width: 48px; height: 48px; border: 5px solid #FFF; border-bottom-color: var(--primary-color);
  border-radius: 50%; display: inline-block; animation: rotation 1s linear infinite;
}
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }


/* --- Footer --- */
.site-footer {
  background: #343a40;
  color: #f8f9fa;
  padding: 2rem 0;
  margin-top: 3rem;
  border-top: 4px solid var(--primary-color);
}

.site-footer .container {
  text-align: center;
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
  list-style: none;
  padding: 0;
}

.footer-nav a {
  color: #adb5bd;
  font-weight: 500;
}

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

/* --- FINAL UPDATE: Ad Detail Page Styles --- */
.ad-detail {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Two-column layout */
    gap: 2.5rem;
    margin-top: 1.5rem;
}
.ad-primary-column h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.ad-primary-column .meta {
    font-size: 0.9rem;
    color: var(--muted-color);
    margin-bottom: 1.5rem;
}
.ad-description {
    margin-top: 2.5rem;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}
.ad-description h2 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}
.description-content {
    line-height: 1.8;
}
.description-content p, .description-content ul {
    margin-bottom: 1rem;
}

/* Sidebar Styles */
.ad-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 1.5rem); /* Sticks below the header */
    align-self: start;
}
.sidebar-block {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.sidebar-block h3 {
    margin-top: 0;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}
.price-block .price {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin: 0;
}
.seller-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.contact .button, .video-block .button {
    width: 100%;
}
.phone {
    font-weight: 600;
    text-align: center;
    margin-top: 1rem;
    font-size: 1.1rem;
}
.owner-controls .button, .owner-controls .button-danger {
    width: 100%;
    margin-top: 0.5rem;
}
.related-ads-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.related-ads-list li {
    border-bottom: 1px solid var(--border-color);
}
.related-ads-list li:last-child {
    border-bottom: none;
}
.related-ads-list a {
    display: block;
    padding: 0.75rem 0.25rem;
    color: var(--text-color);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.related-ads-list a:hover {
    color: var(--primary-color);
}

/* --- Styles for Static Pages (About, Contact, Terms) --- */
.static-page {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    margin-top: 1.5rem;
    border: 1px solid var(--border-color);
}
.static-page h1, .static-page h2, .static-page h3 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.static-page p, .static-page ol {
    line-height: 1.8;
    margin-bottom: 1rem;
}
.static-page ol {
    padding-left: 20px;
}
.static-page li {
    margin-bottom: 0.75rem;
}
.static-page .tagline {
    font-style: italic;
    text-align: center;
    margin-top: 2rem;
    font-weight: 500;
    color: var(--muted-color);
}
.contact-details {
    font-size: 1.1rem;
}
/* Carousel Styles */
.carousel-container { position: relative; border-radius: 12px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.1); background: #eee; }
.carousel .slide { display: none; }
.carousel .slide.active { display: block; animation: fadeIn 0.5s; }
.carousel .slide img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
@keyframes fadeIn { from { opacity: 0.4; } to { opacity: 1; } }
.carousel-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background-color: rgba(0,0,0,0.4); color: white; border: none;
    font-size: 24px; width: 44px; height: 44px;
    cursor: pointer; border-radius: 50%;
    transition: background-color 0.2s ease;
    display: flex; align-items: center; justify-content: center;
}
.carousel-btn:hover { background-color: rgba(0,0,0,0.7); }
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }
.carousel-dots {
    position: absolute; bottom: 15px; left: 50%;
    transform: translateX(-50%); display: flex; gap: 8px;
}
.dot {
    width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,0.5);
    border: 1px solid rgba(0,0,0,0.2); cursor: pointer; padding: 0; transition: background-color 0.2s ease;
}
.dot.active { background: white; }

/* Responsive Adjustments for Ad Detail Page */
@media (max-width: 900px) {
    .ad-detail {
        grid-template-columns: 1fr; /* Stack columns on tablets and phones */
    }
    .ad-sidebar {
        position: static; /* Un-stick the sidebar */
        top: auto;
    }

.container {
  padding: 0.1rem;
}
.ad-description {
    padding: 0.5rem;
}


}
/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
  .hero-content h1 {
    font-size: 2.25rem;
  }
  .hero-section {
    padding: 4rem 1.5rem;
  }
  .search-bar-hero form {
    grid-template-columns: 1fr; /* Stack form elements on mobile */
  }
}

@media (max-width: 600px) {
  .user-name {
    display: none; /* Hide username on small screens */
  }
  .auth-area {
    gap: 0.5rem;
  }
  .auth-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}
    .editor-toolbar {
    gap: 0.3rem;
    padding: 0.4rem;
  }
  .toolbar-btn,
  .toolbar-select,
  .toolbar-color {
    height: 32px;
    width: 32px;
    font-size: 0.85rem;
  }
  .toolbar-select {
    min-width: 70px;
  }
