/* =========================================================
   OLX-style Classified Ads — Custom Stylesheet
   ========================================================= */

/* ─── Variables ───────────────────────────────────────────── */
:root {
  --primary:       #3b5bdb;
  --primary-dark:  #2f4bbf;
  --accent:        #f59f00;
  --success:       #2f9e44;
  --surface:       #f8f9fb;
  --card-shadow:   0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.05);
  --card-hover:    0 4px 20px rgba(0,0,0,.13);
  --radius:        .75rem;
  --radius-sm:     .5rem;
}

/* ─── Base ────────────────────────────────────────────────── */
html { height: 100%; }
body {
  background: var(--surface);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #212529;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > main { flex: 1 0 auto; }

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

/* ─── Navbar ──────────────────────────────────────────────── */
.navbar {
  background: #fff !important;
  border-bottom: 1px solid #e9ecef;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  /* NÃO sobrescrever position — Bootstrap sticky-top já define position:sticky */
  z-index: 1030 !important;
}

/* Dropdown do usuário sempre acima de qualquer elemento da página */
.navbar .dropdown-menu {
  z-index: 9999 !important;
  position: absolute !important;
}

/* ATENÇÃO: não adicionar isolation, z-index ou position neste seletor —
   qualquer contexto de empilhamento aqui faz os modais do Bootstrap ficarem
   atrás do backdrop (tela escura travada). O seller-sticky abaixo já cuida
   do único elemento que precisava de z-index controlado. */

/* Card lateral sticky (substitui sticky-top do Bootstrap sem o z-index alto) */
.seller-sticky {
  position: sticky;
  top: 75px;
  z-index: 1 !important;
}

.navbar-brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.5px;
}

.navbar .form-control {
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.navbar .form-control:focus {
  box-shadow: none;
  border-color: var(--primary);
}
.navbar .btn-search {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .45rem 1rem;
  transition: background .15s;
}
.navbar .btn-search:hover { background: var(--primary-dark); }

.btn-advertise {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  padding: .45rem 1.1rem;
  transition: filter .15s;
}
.btn-advertise:hover { filter: brightness(.93); color: #1a1a1a; }

/* ─── Hero ────────────────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, var(--primary) 0%, #4c6ef5 60%, #748ffc 100%);
  padding: 3.5rem 0 4rem;
  position: relative;
  overflow: hidden;
}
.hero-section::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero-section .lead {
  opacity: .9;
  font-size: 1.1rem;
}

.hero-search {
  background: #fff;
  border-radius: var(--radius);
  padding: .5rem .5rem .5rem 1rem;
  display: flex;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  max-width: 620px;
  margin: 0 auto;
}
.hero-search input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 1rem;
  background: transparent;
  color: #333;
}
.hero-search button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  padding: .6rem 1.4rem;
  font-weight: 600;
  font-size: .95rem;
  transition: background .15s;
  white-space: nowrap;
}
.hero-search button:hover { background: var(--primary-dark); }

.hero-stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.hero-stat {
  text-align: center;
  color: rgba(255,255,255,.85);
}
.hero-stat-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}
.hero-stat-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ─── Category Cards ──────────────────────────────────────── */
.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem .75rem;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: #333;
  transition: transform .18s, box-shadow .18s;
  height: 100%;
}
.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-hover);
  color: var(--primary);
}
.category-card .cat-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .75rem;
  font-size: 1.4rem;
}
.category-card .cat-name {
  font-weight: 600;
  font-size: .88rem;
  text-align: center;
  line-height: 1.3;
}
.category-card .cat-count {
  font-size: .75rem;
  color: #999;
  margin-top: .15rem;
}

/* ─── Ad Cards ────────────────────────────────────────────── */
.ad-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
  height: 100%;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.ad-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-hover);
}
.ad-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #f0f2f5;
}
.ad-card-img-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: 2.5rem;
}
.ad-card-body {
  padding: .85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.ad-card-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}
.ad-card-price.free  { color: var(--success); }
.ad-card-price.nego  { color: #e67700; }
.ad-card-title {
  font-size: .9rem;
  font-weight: 500;
  color: #333;
  margin-top: .25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-card-meta {
  margin-top: auto;
  padding-top: .5rem;
  font-size: .75rem;
  color: #999;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f0f0f0;
}
.ad-card-badge {
  position: absolute;
  top: .5rem;
  left: .5rem;
  background: var(--accent);
  color: #1a1a1a;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 4px;
}

/* ─── Filters Sidebar ─────────────────────────────────────── */
.filter-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 1.25rem;
}
.filter-card h6 {
  font-weight: 700;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #555;
  margin-bottom: .75rem;
}
.filter-divider {
  border-top: 1px solid #f0f2f5;
  margin: 1rem 0;
}

/* ─── Ad Detail ───────────────────────────────────────────── */
.ad-gallery-img {
  max-height: 460px;
  object-fit: contain;
  background: #f8f9fa;
}

.carousel-thumbs {
  background: #fff;
  border-top: 1px solid #eee;
}
.carousel-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: .65;
  border: 2px solid transparent;
  transition: opacity .15s, border-color .15s;
  flex-shrink: 0;
}
.carousel-thumb.active,
.carousel-thumb:hover {
  opacity: 1;
  border-color: var(--primary);
}

.ad-price {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
}

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

/* ─── Upload Area ─────────────────────────────────────────── */
.upload-area {
  cursor: pointer;
  transition: border-color .2s, background .2s;
  border: 2px dashed #ced4da !important;
  border-radius: var(--radius) !important;
}
.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary) !important;
  background: #eef2ff;
}

/* ─── CTA Section ─────────────────────────────────────────── */
.cta-section {
  background: linear-gradient(135deg, #1e3a8a 0%, var(--primary) 100%);
  border-radius: var(--radius);
  color: #fff;
  padding: 3rem 2rem;
  text-align: center;
}
.cta-section h2 { font-weight: 800; }

/* ─── Footer ──────────────────────────────────────────────── */
footer {
  background: #1a1a2e;
  color: #adb5bd;
}
footer h6 {
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .08em;
  margin-bottom: .75rem;
}
footer a {
  color: #adb5bd;
  text-decoration: none;
  font-size: .9rem;
  transition: color .15s;
}
footer a:hover { color: #fff; }
footer .footer-brand {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
}

/* ─── Flash Messages ──────────────────────────────────────── */
.flash-message {
  border-radius: var(--radius-sm);
  animation: slideDown .3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Section Headers ─────────────────────────────────────── */
.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, var(--primary), transparent);
  margin-left: .5rem;
  border-radius: 2px;
}

/* ─── Pagination ──────────────────────────────────────────── */
.pagination .page-link {
  border-radius: var(--radius-sm) !important;
  color: var(--primary);
  border-color: #e0e4f0;
  margin: 0 2px;
  padding: .45rem .8rem;
}
.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}
.pagination .page-link:focus { box-shadow: none; }

/* ─── Status Badges ───────────────────────────────────────── */
.badge { font-weight: 600; }

/* ─── Responsive tweaks ───────────────────────────────────── */
@media (max-width: 767px) {
  .hero-section { padding: 2rem 0 2.5rem; }
  .hero-search { flex-wrap: wrap; padding: .75rem; }
  .hero-search input { width: 100%; margin-bottom: .5rem; }
  .hero-search button { width: 100%; border-radius: var(--radius-sm); }
  .hero-stats { gap: 1.25rem; }
  .ad-gallery-img { max-height: 280px; }
  .cta-section { padding: 2rem 1rem; }
}

@media (max-width: 575px) {
  .category-card .cat-icon { width: 42px; height: 42px; font-size: 1.15rem; }
  .category-card .cat-name { font-size: .8rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ÁREA DO USUÁRIO — sidebar, chat, favoritos
   ═══════════════════════════════════════════════════════════════════════════ */

/* Sidebar avatar */
.user-avatar-circle {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), #6f42c1);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700;
  flex-shrink: 0;
}

/* Sidebar list-group: active state */
.list-group-item.active {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.list-group-item.active i { color: #fff !important; }
.list-group-item:hover:not(.active) { background: #f8f9ff; }

/* Chat bubbles */
.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 0.92rem;
  word-break: break-word;
}
.chat-me {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-other {
  background: #f0f2f5;
  color: #222;
  border-bottom-left-radius: 4px;
}

/* Ad card favorito: hover */
.ad-card-fav { transition: box-shadow 0.2s; }
.ad-card-fav:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important; }

/* Garantir que truncate funcione em flex */
.min-width-0 { min-width: 0; }

/* Navbar: badge de não lidas */
.nav-item .badge {
  pointer-events: none;
}

/* ─── Tom Select — integração com tema ───────────────────────── */
.ts-wrapper .ts-control {
  border-radius: var(--radius-sm);
  border-color: #dee2e6;
  min-height: 38px;
  font-size: 0.9375rem;
}
.ts-wrapper.form-select-sm .ts-control {
  min-height: 31px;
  font-size: 0.875rem;
  padding: 4px 8px;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(59,91,219,.18);
}
.ts-dropdown {
  border-color: #dee2e6;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  z-index: 9999;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background: var(--primary);
  color: #fff;
}
.ts-dropdown .no-results {
  padding: 10px 14px;
  color: #6c757d;
  font-size: .875rem;
}
.ts-wrapper .ts-control input { color: #212529; }
