/* ===========================
   GLOBAL STYLES
   =========================== */

:root {
  --brand-dark: #1a2b4a;
  --brand-orange: #ff6b35;
  --brand-orange-hover: #e55a2b;
  --brand-green: #25d366;
  --brand-green-hover: #1da851;
  --brand-light: #f8fafc;
  --brand-gray: #64748b;
  --transition-smooth: all 0.3s ease;
}

* {
  font-family: 'Plus Jakarta Sans', sans-serif;
  box-sizing: border-box;
}

html {
  height: 100%;
  background-color: var(--brand-light);
  overscroll-behavior: none;
}

body {
  min-height: 100%;
  background-color: var(--brand-light);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
}

/* ===========================
   SEARCH MODE STYLES
   =========================== */

/* Search bar: Always visible, outside hero */
#search-bar-container {
  transition: all 0.3s ease-in-out;
  position: relative;
  z-index: 30;
  background: var(--brand-dark);
  opacity: 1;
  visibility: visible;
  display: block;
}

/* In search mode: bar becomes fixed at top */
body.search-mode #search-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 50;
  padding: 0.75rem 1rem;
  background: var(--brand-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

body.search-mode,
body.search-mode #app,
body.search-mode #page-home,
body.search-mode #recent-ads {
  background-color: #ffffff !important;
}

/* Hero section: Collapses in search mode */
#hero-section {
  transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, padding 0.3s ease-in-out, margin 0.3s ease-in-out;
  overflow: hidden;
  max-height: auto;
  opacity: 1;
  visibility: visible;
}

body.search-mode #hero-section {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden;
}

/* Page adjusts padding when bar is fixed */
#page-home {
  transition: padding-top 0.3s ease-in-out;
  padding-top: 0;
}

body.search-mode #page-home {
  padding-top: 80px;
}

/* Categories section: Hides in search mode */
#categories {
  transition: opacity 0.3s ease-in-out, max-height 0.3s ease-in-out, visibility 0.3s ease-in-out;
  opacity: 1;
  max-height: 100vh;
  visibility: visible;
  overflow: hidden;
}

body.search-mode #categories {
  opacity: 0;
  max-height: 0;
  visibility: hidden;
}

/* Recent ads: Stays visible in search mode */
#recent-ads {
  transition: opacity 0.3s ease-in-out;
  opacity: 1;
  max-height: none;
  visibility: visible;
  overflow: visible;
}

body.search-mode #recent-ads {
  opacity: 1;
  visibility: visible;
  padding-top: 1rem;
}

/* Hide recent ads header in search mode */
body.search-mode #recent-ads-header {
  display: none !important;
}

/* Hide pagination elements in search mode */
body.search-mode #ads-loader,
body.search-mode #ads-end,
body.search-mode #ads-sentinel {
  display: none !important;
}

/* ===========================
   SEARCH INPUT ANIMATION
   =========================== */

/* Cursor piscante para animação de digitação */
@keyframes blinkCursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

#searchInput {
  font-family: 'Plus Jakarta Sans', sans-serif;
}

#searchInput::placeholder {
  transition: color 0.05s ease;
}

/* Cursor animado visível apenas na animação */
.search-input-animating::placeholder {
  letter-spacing: 0.02em;
}

/* ===========================
   LAYOUT & PAGES
   =========================== */

#app {
  min-height: 100%;
  width: 100%;
  background-color: var(--brand-light);
}

body.page-anunciar #app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  overflow-y: visible;
}

body.page-anunciar-home,
body.page-anunciar-home #app {
  background-color: #2F4B7C;
}

body.page-anunciar-auth,
body.page-anunciar-auth #app {
  background-color: #2F4B7C;
}

body.page-anunciar-auth header {
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
}

body.page-anunciar-auth footer,
body.page-anunciar-auth .footer-compact {
  background: rgba(26, 43, 74, 0.92);
}

body.page-anunciar-auth .footer-compact-copyright {
  border-top-color: rgba(255, 255, 255, 0.18);
}

body.page-anunciar-produto,
body.page-anunciar-produto #app,
body.page-anunciar-servico,
body.page-anunciar-servico #app {
  background-color: #2F4B7C;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

body.page-anunciar .page.active {
  display: flex !important;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

body.page-painel .page.active {
  justify-content: flex-start;
  align-items: stretch;
}

/* Layout compacto para páginas com rodapé compact */
body.page-anunciar header {
  flex-shrink: 0;
}

body.page-anunciar footer {
  flex-shrink: 0;
  margin-top: auto;
}

/* Footer customization */
footer {
  letter-spacing: 0.3px;
}

footer a {
  text-decoration: none;
}

footer a:focus {
  outline: 1px solid rgba(255, 107, 53, 0.5);
  border-radius: 2px;
}

/* ===========================
   FORM CARD
   =========================== */

.card-form-container {
  max-width: 750px;
  width: 100%;
}

/* ===========================
   HEADER
   =========================== */

header {
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 40;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.125rem 0.25rem;
  border-radius: 9999px;
  color: var(--brand-dark);
  transition: var(--transition-smooth);
}

.user-menu-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.user-area {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: auto;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  background: #e2e8f0;
  color: var(--brand-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  overflow: hidden;
  flex-shrink: 0;
  pointer-events: none;
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.user-avatar.has-image .user-avatar-img {
  display: block;
}

.user-avatar.has-image .user-avatar-initials {
  display: none;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.1;
}

.user-chevron {
  width: 0.75rem;
  height: 0.75rem;
  color: var(--brand-gray);
  pointer-events: none;
}

.user-dropdown {
  position: absolute;
  top: 110%;
  right: 0;
  left: auto;
  width: 200px;
  min-width: 180px;
  max-width: 220px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(26, 43, 74, 0.12);
  padding: 0.5rem 0;
  opacity: 0;
  transform: translate(4px, -4px);
  transform-origin: top right;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 999;
}

.user-dropdown.open {
  opacity: 1;
  transform: translate(4px, 0);
  pointer-events: auto;
}

.mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 12px rgba(26, 43, 74, 0.06);
  display: none;
  align-items: center;
  justify-content: space-around;
  padding: 0 0.75rem;
  z-index: 60;
}

.mobile-nav-item {
  flex: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  color: var(--brand-gray);
  font-size: 0.6875rem;
  font-weight: 600;
  text-decoration: none;
}

.mobile-nav-item.active {
  color: #2563eb;
}

.mobile-nav-icon {
  width: 20px;
  height: 20px;
}

.mobile-nav-cta {
  flex: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--brand-gray);
  font-size: 0.6875rem;
  font-weight: 600;
  text-decoration: none;
}

.mobile-nav-cta.active {
  color: #2563eb;
}

.mobile-nav-cta.active .mobile-nav-cta-icon {
  color: #2563eb;
}

.mobile-nav-cta-icon {
  width: 20px;
  height: 20px;
  border-radius: 0;
  background: transparent;
  color: var(--brand-orange);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.35rem;
  line-height: 1;
  margin-top: 0;
  box-shadow: none;
  transform: translateY(-1px);
}

/* ===========================
   BUTTONS
   =========================== */

.btn-pulse:hover {
  animation: pulse 0.3s ease;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* ===========================
   CARDS
   =========================== */

.category-card {
  transition: var(--transition-smooth);
  cursor: pointer;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(26, 43, 74, 0.15);
}

.category-scroll {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  color: var(--brand-dark);
  transition: var(--transition-smooth);
}

.category-circle {
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 9999px;
  background: #f5f7fb;
  border: 1px solid #dbe3ee;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.category-icon {
  width: 1.55rem;
  height: 1.55rem;
  color: #334766;
  transition: var(--transition-smooth);
}

.category-icon path,
.category-icon circle {
  stroke-width: 1.8;
}

.category-label {
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

.category-pill:hover .category-circle {
  border-color: rgba(255, 107, 53, 0.55);
  background: #fffaf7;
  box-shadow: 0 4px 10px rgba(26, 43, 74, 0.08);
}

.category-pill.active {
  color: var(--brand-orange);
}

.category-pill.active .category-circle {
  border-color: var(--brand-orange);
  background: #fffaf7;
  box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.16);
}

.category-pill.active .category-icon {
  color: var(--brand-orange);
}

@media (min-width: 1025px) {
  .category-scroll {
    gap: 1.25rem;
  }

  .category-pill {
    gap: 0.5rem;
    width: 6rem;
  }

  .category-circle {
    width: 4.5rem;
    height: 4.5rem;
  }

  .category-icon {
    width: 1.95rem;
    height: 1.95rem;
  }

  .category-label {
    font-size: 0.8125rem;
  }

  .categories-hint {
    display: none;
  }

  .user-menu-button:hover {
    background: rgba(26, 43, 74, 0.06);
    box-shadow: 0 6px 16px rgba(26, 43, 74, 0.08);
  }
}

.ad-card {
  background-color: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ad-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.08);
}

.ad-card-image {
  height: 170px;
  background: #f8f9fb;
  position: relative;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
}

.ad-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.35s ease;
}

.ad-card:hover .ad-card-image img {
  transform: scale(1.06);
}

.ad-card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 168px;
}

.ad-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--brand-dark);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ad-card-price {
  margin-top: 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-orange);
}

.ad-card-location {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--brand-gray);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.ad-card-description {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--brand-gray);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.ad-card-tags {
  margin-top: auto;
  padding-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

#ads-container {
  align-items: stretch;
  margin-bottom: 1.5rem;
}

#ads-container > a {
  display: block;
  height: 100%;
}

.ad-card-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--brand-gray);
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
}

.ad-card-tag-new {
  color: #0f766e;
  background: #ccfbf1;
}

.ad-card-tag-used {
  color: #1d4ed8;
  background: #dbeafe;
}

.ad-card-tag-service {
  color: #b45309;
  background: #ffedd5;
}

/* ===========================
   HERO SECTION
   =========================== */

.hero-gradient {
  background: linear-gradient(135deg, #1a2b4a 0%, #2d4a7c 100%);
  color: white;
}

/* ===========================
   IMAGES
   =========================== */

.image-preview {
  aspect-ratio: 1;
  object-fit: cover;
}

/* ===========================
   DETAIL GALLERY (MOBILE)
   =========================== */

@media (max-width: 768px) {
  .product-gallery {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: 0;
    padding-right: 0;
  }

  .detail-gallery-wrapper {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }

  .detail-gallery-main {
    width: 100vw;
    aspect-ratio: 4 / 5;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  #detail-main-image {
    width: 100%;
    object-fit: cover;
    aspect-ratio: 4 / 5;
  }
}

/* ===========================
   UPLOAD ZONE
   =========================== */

.upload-zone {
  border: 2px dashed #cbd5e1;
  transition: var(--transition-smooth);
}

.upload-zone:hover {
  border-color: var(--brand-orange);
  background-color: #fff7ed;
}

.upload-zone.has-image {
  border-style: solid;
  border-color: var(--brand-green);
}

/* ===========================
   COMPACT FOOTER
   =========================== */

.footer-compact {
  background-color: #1a2b4a;
  color: white;
  padding: 2rem 1rem;
}

.footer-compact-content {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
}

.footer-compact-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.footer-compact-brand span {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.footer-compact-brand .text-brand-orange {
  color: #ff6b35;
}

.footer-compact-copyright {
  font-size: 0.75rem;
  color: #cbd5e1;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
  width: 100%;
}

.footer-compact-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: 0.75rem;
}

.footer-compact-links a {
  color: #cbd5e1;
  text-decoration: none;
  transition: var(--transition-smooth);
}

.footer-compact-links a:hover {
  color: #ff6b35;
}

@media (min-width: 768px) {
  footer,
  .footer-compact {
    background: var(--brand-light) !important;
    color: var(--brand-gray) !important;
    border-top: 1px solid #e5e7eb !important;
    padding: 0.75rem 1rem !important;
  }

  .footer-compact-content {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
  }

  .footer-compact-brand {
    justify-content: flex-start;
  }

  .footer-compact-copyright {
    border-top: 0 !important;
    padding-top: 0 !important;
    width: auto;
    color: var(--brand-gray) !important;
  }

  footer .text-white,
  footer .text-gray-300,
  footer .text-gray-400,
  footer .text-gray-500 {
    color: var(--brand-gray) !important;
  }

  footer .text-brand-dark {
    color: var(--brand-dark) !important;
  }

  footer .border-gray-700 {
    border-color: #e5e7eb !important;
  }

  footer .grid {
    gap: 0.75rem !important;
    margin-bottom: 0.5rem !important;
  }

  footer [style*="color: white"] {
    color: var(--brand-dark) !important;
  }

  .footer-compact [style*="rgba(255,255,255"] {
    color: var(--brand-gray) !important;
  }
}

/* ===========================
   RESPONSIVE HELPERS
   =========================== */

@media (max-width: 640px) {
  .hidden-sm {
    display: none;
  }

  .header-container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .header-logo {
    display: none;
  }

  .header-row {
    gap: 0.5rem;
  }

  #auth-section {
    order: -1;
    width: 100%;
    justify-content: space-between;
    gap: 0.75rem;
  }

  #user-logged,
  #user-logout {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 767px) {
  body {
    padding-bottom: 84px;
  }

  body.app-page {
    padding-bottom: 90px;
  }

  body.app-page #app {
    padding-bottom: 90px;
  }

  header {
    display: none;
  }

  #auth-section {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  footer {
    display: none;
  }
}

@media (min-width: 641px) {
  .visible-sm {
    display: none;
  }
}
/* ===========================
   BOTÃO VOLTAR PADRÃO
   =========================== */

.btn-voltar-circular {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(26, 43, 74, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1.5rem;
}

.btn-voltar-circular:hover {
  background: #ffffff;
  transform: translateX(-3px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  border-color: rgba(26, 43, 74, 0.12);
}

.btn-voltar-circular svg {
  width: 20px;
  height: 20px;
  stroke: #1a2b4a;
  stroke-width: 2.5;
}

/* ===========================
   LOGO KIT (HEADER/SEARCH/FOOTER)
   =========================== */

.logo-wordmark {
  --logo-size: 1.25rem;
  --logo-letter-spacing: 0.005em;
  display: inline-flex;
  align-items: baseline;
  gap: 0.04em;
  line-height: 1;
  letter-spacing: var(--logo-letter-spacing);
  font-family: 'Chewy', sans-serif;
  font-size: var(--logo-size);
  white-space: nowrap;
}

.logo-wordmark .logo-part-ita,
.logo-wordmark .logo-part-vende {
  font-family: inherit;
  line-height: inherit;
}

.logo-wordmark .logo-part-ita {
  color: var(--brand-dark);
  font-weight: 800;
}

.logo-wordmark .logo-part-vende {
  color: var(--brand-orange);
  font-weight: 900;
}

.logo-header {
  --logo-size: 2rem;
}

.logo-footer {
  --logo-size: 0.95rem;
}

@media (max-width: 640px) {
  .logo-header {
    --logo-size: 1.6rem;
  }

  .logo-footer {
    --logo-size: 0.9rem;
  }
}

/* ===========================
   ACCENT SUGGESTION HINT
   =========================== */

.accent-suggestion {
  display: none;
  margin-top: 0.45rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.7rem;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.78rem;
  line-height: 1.3;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.accent-suggestion.visible {
  display: flex;
}

.accent-suggestion-text {
  flex: 1;
}

.accent-suggestion-btn {
  border: 0;
  border-radius: 999px;
  background: #ff6b35;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.26rem 0.62rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.accent-suggestion-btn:hover {
  background: #e55a2b;
}