/* ==========================================================================
   MEGALOOP DESIGN SYSTEM - CORE STRUCTURE
   ========================================================================== */

body {
  background-color: var(--color-background) !important;
  color: var(--theme-text) !important;
  font-family: var(--font-body) !important;
  min-height: 100vh;
  overflow-x: hidden;
  /* Prevent horizontal scroll globally */
}

.opacity-60,
.opacity-80,
.opacity-50,
.opacity-40 {
  color: var(--theme-text) !important;
  opacity: 1 !important;
}

.bg-rose-500\/20,
.bg-rose-500\/10 {
  background-color: #FFE5E5 !important;
}

.text-rose-200,
.text-rose-300,
.text-rose-400 {
  color: #9B1C1C !important;
}

.border-rose-500\/30 {
  border-color: rgba(155, 28, 28, 0.4) !important;
}

.bg-emerald-500\/20,
.bg-emerald-500\/10 {
  background-color: #E6F4EA !important;
}

.text-emerald-200,
.text-emerald-300,
.text-emerald-400 {
  color: #137333 !important;
}

.border-emerald-500\/30 {
  border-color: rgba(19, 115, 51, 0.4) !important;
}

h1,
h2,
h3,
h4,
.theme-logo,
.theme-price {
  font-family: var(--font-heading) !important;
  font-weight: 400 !important;
}

/* --- Nav & Headers --- */
.theme-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0 1.5rem 0;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .theme-header {
    padding: 3rem 0 2rem 0;
    margin-bottom: 2rem;
  }
}

.theme-logo {
  font-family: var(--font-logo) !important;
  font-size: clamp(3rem, 8vw, 5.5rem);
  color: var(--color-primary);
  text-shadow: 0 0 20px rgba(253, 184, 19, 0.3);
  margin-bottom: 1rem;
  letter-spacing: -1px;
  text-transform: lowercase;
}

.theme-logo-mobile {
  font-family: var(--font-logo) !important;
  font-size: 2rem;
  color: var(--color-primary);
  text-transform: lowercase;
  display: inline-block;
  white-space: nowrap;
}

.theme-nav {
  display: none;
  gap: 2.5rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 2px;
}

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

.theme-nav a {
  opacity: 0.7;
  transition: all 0.3s ease;
  color: inherit;
}

.theme-nav a:hover,
.theme-nav a.active {
  opacity: 1;
  color: var(--color-primary);
}

.theme-nav a.active {
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 4px;
}

/* --- Global Tabs --- */
.global-tabs-wrapper {
  margin-bottom: 2rem;
  position: relative;
}

.global-tabs-container {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--theme-card-border);
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;
  /* Firefox */
}

.global-tabs-container::-webkit-scrollbar {
  display: none;
}

.global-tab {
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--theme-text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  opacity: 0.5;
  margin-right: 0.5rem;
}

.global-tab:hover {
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.06);
}

.global-tab.active {
  opacity: 1;
  color: var(--color-secondary);
  background: var(--color-background);
  border-color: var(--theme-card-border);
  border-bottom-color: var(--color-background);
  margin-bottom: -1px;
  position: relative;
  z-index: 10;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.02);
}

/* --- Component Cards --- */
.theme-card {
  position: relative;
  border: 1px solid var(--theme-card-border);
  border-radius: 20px;
  padding: 1.25rem;
  /* Reduced mobile padding */
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  z-index: 1;
  overflow: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}

@media (min-width: 768px) {
  .theme-card {
    padding: 2rem;
    gap: 1.5rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.theme-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--theme-card-bg);
  backdrop-filter: blur(16px);
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
}

/* --- Ad Card: vertical anatomy --- */
.ad-card {
  padding: 0 !important;
  gap: 0 !important;
  overflow: hidden;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
}

/* Image wrapper – enforces 4:3 aspect ratio */
.ad-card-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
}

.ad-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

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

/* Category badge overlaid top-right on image */
.ad-card-category-badge {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  background: var(--theme-card-bg);
  border-radius: 30px;
  padding: 4px 14px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--theme-text);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(128, 128, 128, 0.2);
}

/* Card body below the image */
.ad-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.25rem 1.25rem;
}

/* Badge row */
.ad-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ad-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1.5px solid var(--color-accent);
  border-radius: 30px;
  padding: 3px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  background: transparent;
}

.ad-badge-label {
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 400;
}

.ad-badge-value {
  color: var(--color-secondary);
  font-weight: 700;
  font-size: 0.85rem;
}

/* Title + price on one row – fixed height keeps action buttons aligned across cards */
.ad-title-price-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 3.5rem;
  /* accommodates exactly 2 lines of title at 1.35rem / lh 1.2 */
}

.ad-card-title {
  font-size: 1.35rem;
  font-weight: 700 !important;
  line-height: 1.2;
  color: var(--card-title-color);
  flex: 1;
  min-width: 0;
  /* clamp at 2 lines so layout never grows beyond the fixed row height */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ad-card-price {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700 !important;
  color: var(--card-price-color);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Actions row: CTA + favorite */
.ad-card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: -0.5rem;
}

.ad-card-cta {
  flex: 1;
  text-align: center;
}

.ad-card-favorite {
  flex-shrink: 0;
}

.theme-pill {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(74, 85, 104, 0.15);
  border-radius: 30px;
  padding: 4px 16px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-accent);
}

.theme-price {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  color: var(--color-primary);
}

.theme-btn {
  background: var(--theme-btn-bg);
  color: var(--theme-btn-text) !important;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.75rem 1.5rem;
  /* Slightly reduced padding */
  border-radius: 50px;
  font-size: 0.9rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  cursor: pointer;
  display: inline-block;
  position: relative;
  backface-visibility: hidden;
  will-change: transform;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .theme-btn {
    padding: 0.75rem 2rem;
    font-size: 0.95rem;
  }
}

.theme-btn:hover,
.theme-card:hover .theme-btn {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(238, 108, 77, 0.5);
}

/* --- Layout & Forms --- */
.ads-grid-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .ads-grid-layout {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 2rem;
  }
}

.ads-sidebar {
  order: 2;
}

@media (min-width: 1024px) {
  .ads-sidebar {
    grid-column: span 4 / span 4;
    position: sticky;
    top: 2rem;
    order: 1;
  }
}

.ads-main-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  order: 1;
  width: 100%;
  overflow: hidden;
}

/* Each page frame is a grid, and nested frames span the full width to create a continuous grid effect */
.ads-page-frame {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  grid-column: 1 / -1;
  width: 100%;
}

@media (min-width: 1024px) {
  .ads-main-content {
    grid-column: span 8 / span 8;
    order: 2;
  }

  /* 2-column ad grid on desktop */
  .ads-page-frame {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sidebar-filter-card,
.auth-card {
  background: var(--theme-card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--theme-card-border);
  border-radius: 24px;
  padding: 1.5rem;
  /* Reduced mobile padding */
}

@media (min-width: 768px) {

  .sidebar-filter-card,
  .auth-card {
    padding: 2.5rem;
  }
}

.auth-title {
  font-size: 2rem;
  color: var(--theme-heading-color);
  margin-bottom: 1.5rem;
  text-align: center;
  font-family: var(--font-heading) !important;
}

@media (min-width: 768px) {
  .auth-title {
    font-size: 2.5rem;
  }
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--theme-text);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  background: var(--theme-card-bg) !important;
  border: 1px solid var(--color-primary) !important;
  border-radius: 12px !important;
  color: var(--theme-text) !important;
  padding: 0.85rem 1.25rem !important;
  font-family: var(--font-body) !important;
}

.form-input:focus {
  outline: none !important;
  border-color: var(--color-secondary) !important;
}

.form-btn {
  width: 100%;
  background: var(--theme-btn-bg);
  color: var(--theme-btn-text) !important;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1rem !important;
  border-radius: 12px !important;
  cursor: pointer;
}

input[type="range"] {
  background-color: rgba(44, 62, 80, 0.2) !important;
}

/* --- Mobile Responsive Drawer Mechanics --- */
@media (max-width: 767px) {
  .mobile-nav-drawer {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 50 !important;
    background: var(--theme-card-bg) !important;
    backdrop-filter: blur(24px) !important;
    border-right: 1px solid var(--theme-card-border) !important;
    transition: transform 0.3s ease-in-out !important;
    transform: translateX(-100%);
    height: 100dvh !important;
    width: 280px !important;
    overflow: hidden !important;
    /* Content scrolls in inner div */
  }

  .mobile-nav-drawer.active {
    transform: translateX(0) !important;
  }
}

@media (max-width: 1023px) {
  .ads-sidebar {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    z-index: 50 !important;
    background: var(--theme-card-bg) !important;
    backdrop-filter: blur(24px) !important;
    border-top: 1px solid var(--theme-card-border) !important;
    border-radius: 24px 24px 0 0 !important;
    padding: 1.5rem !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    transition: transform 0.3s ease-in-out !important;
    transform: translateY(100%);
  }

  .ads-sidebar.active {
    transform: translateY(0) !important;
  }
}

.overflow-hidden {
  overflow: hidden !important;
}

/* --- Animations --- */
.scale-in-center {
  animation: scale-in-center 0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}

@keyframes scale-in-center {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}