:root {
  --blue: #2563EB; --blue-dark: #1D4ED8; --blue-light: #EFF6FF;
  --bg: #F8FAFC; --bg-card: #FFFFFF; --bg-elevated: #F1F5F9;
  --border: #E2E8F0; --text: #0F172A;
  --text-sec: #475569; --text-muted: #94A3B8;
  --success: #16A34A; --error: #DC2626; --warning: #D97706;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, textarea, select, button { font-family: inherit; }

/* NAVBAR */
.navbar { position: sticky; top: 0; z-index: 100; background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); height: 60px;
  box-shadow: var(--shadow-sm); }
.navbar-inner { display: flex; align-items: center; justify-content: space-between;
  height: 100%; max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; gap: 1rem; }
.navbar-logo { font-size: 1.5rem; font-weight: 800; background: linear-gradient(135deg,#2563EB,#3B82F6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.navbar-links { display: flex; align-items: center; gap: 1.5rem; }
.navbar-links a { color: var(--text-sec); font-size: .9rem; font-weight: 500; transition: color .2s; }
.navbar-links a:hover { color: var(--blue); }
.navbar-actions { display: flex; align-items: center; gap: .5rem; }
.navbar-user { display: flex; align-items: center; gap: .5rem; cursor: pointer;
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 5px 12px; transition: border-color .2s; }
.navbar-user:hover { border-color: var(--blue); }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg,var(--blue),#3B82F6);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; color: #fff; }
.dropdown-menu { position: absolute; top: calc(100% + 8px); right: 0; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); min-width: 180px;
  box-shadow: var(--shadow); z-index: 200; display: none; }
.dropdown-menu.open { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; color: var(--text-sec); font-size: .875rem; background: none;
  border: none; width: 100%; cursor: pointer; transition: background .15s; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--blue-light); color: var(--blue); }
.dropdown-menu hr { border: none; border-top: 1px solid var(--border); }

/* LAYOUT */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
.page { padding: 2rem 0; }
.section-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--text); }
.section-title-center { text-align: center; }

/* CATEGORÍAS (home): en mobile se acomodan solas, en PC siempre 5 por línea y centradas */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}
@media (min-width: 768px) {
  .categories-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* CÓMO FUNCIONA (home): los 4 pasos siempre centrados en la pantalla */
.how-it-works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.2rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .875rem;
  border: none; cursor: pointer; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-outline { background: transparent; border: 1.5px solid var(--blue); color: var(--blue); }
.btn-outline:hover { background: var(--blue-light); }
.btn-ghost { background: var(--bg-elevated); color: var(--text-sec); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: #E2E8F0; color: var(--text); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* FORMS */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.1rem; }
.form-label { font-size: .85rem; font-weight: 600; color: var(--text-sec); }
.form-input { width: 100%; padding: .65rem 1rem; background: #fff;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
  font-size: .925rem; transition: all .2s; outline: none; }
.form-input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-input::placeholder { color: var(--text-muted); }
.form-input:disabled { background: var(--bg-elevated); color: var(--text-muted); cursor: not-allowed; }
.form-error { font-size: .78rem; color: var(--error); margin-top: .2rem; }

/* OJITO MOSTRAR/OCULTAR CONTRASEÑA */
.pwd-wrapper { position: relative; }
.pwd-wrapper input { padding-right: 2.75rem; }
.pwd-toggle {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1rem; line-height: 1;
  padding: .4rem; color: var(--text-muted); border-radius: var(--radius-sm);
}
.pwd-toggle:hover { color: var(--text); background: var(--bg-elevated); }

/* CARDS */
.card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 1.25rem; transition: all .2s; box-shadow: var(--shadow-sm); }
.card:hover { border-color: rgba(37,99,235,.3); box-shadow: var(--shadow); }

/* PRODUCT GRID */
/* Máximo 3 tarjetas por fila (desktop y tablet) */
.products-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:1.25rem; }

/* Celulares: 2 tarjetas por línea en vez de 1.
   Tablets (>=768px) mantienen las mismas 3 columnas que en PC. */
@media (max-width: 767px) {
  .products-grid { grid-template-columns:repeat(2, 1fr); gap:.75rem; }
}

/* PRODUCT DETAIL (producto.html) */
/* Antes esto era un style inline con grid-template-columns fijo
   (minmax(0,1fr) 350px), sin ningún @media que lo adaptara a mobile:
   en pantallas angostas las dos columnas se apretaban una al lado de
   la otra en vez de apilarse, y la columna lateral quedaba "flotando"
   encima del contenido por el position:sticky, generando el
   solapamiento que se ve en celulares. */
.product-detail-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) 350px;
  gap: 2rem;
  align-items: start;
}
.product-detail-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 76px;
}
@media (max-width: 860px) {
  .product-detail-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .product-detail-side {
    position: static;
    top: auto;
  }
}

.product-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  width: 100%;
}
.product-card:hover {
  border-color: rgba(37,99,235,.35);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(37,99,235,.12);
}
.product-card img { width:100%; height:180px; object-fit:cover; flex-shrink:0; display:block; }
.product-card-placeholder {
  width:100%; height:180px; background:var(--bg-elevated);
  display:flex; align-items:center; justify-content:center; font-size:2.5rem; flex-shrink:0;
}
@media (max-width: 767px) {
  .product-card img, .product-card-placeholder { height:130px; }
  .product-card-body { padding:.6rem; }
  .product-card-title { font-size:.82rem; }
  .product-card-price { font-size:.95rem; }
}
.product-card-body { padding:.875rem; flex:1; display:flex; flex-direction:column; justify-content:space-between; }
.product-card-cat { font-size:.72rem; color:var(--text-muted); margin-bottom:.3rem; }
.product-card-title {
  font-weight:600; font-size:.9rem; overflow:hidden;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
  margin-bottom:.5rem; color:var(--text); line-height:1.35;
}
.product-card-price { font-size:1.1rem; font-weight:800; color:var(--blue); margin-bottom:.3rem; }
.product-card-meta { display:flex; justify-content:space-between; font-size:.75rem; color:var(--text-muted); margin-top:auto; }

/* Destacadas: borde dorado difuminado */
.product-card-featured {
  border: 2px solid #f59e0b;
  box-shadow: 0 0 0 1px rgba(245,158,11,.2), 0 0 18px rgba(245,158,11,.3), 0 4px 16px rgba(0,0,0,.08);
}
.product-card-featured:hover {
  border-color: #d97706;
  box-shadow: 0 0 0 1px rgba(245,158,11,.3), 0 0 26px rgba(245,158,11,.45), 0 8px 24px rgba(0,0,0,.1);
  transform: translateY(-3px);
}

/* BADGE */
.badge { display: inline-flex; align-items: center; padding: .18rem .6rem;
  border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-orange { background: #FEF3C7; color: #D97706; }
.badge-green  { background: #DCFCE7; color: var(--success); }
.badge-red    { background: #FEE2E2; color: var(--error); }
.badge-yellow { background: #FEF9C3; color: #CA8A04; }
.badge-gray   { background: var(--bg-elevated); color: var(--text-muted); }
.badge-blue   { background: var(--blue-light); color: var(--blue); }

/* CURRENCY BADGE */
.currency-badge { display: inline-flex; align-items: center; padding: .1rem .45rem;
  border-radius: 4px; font-size: .65rem; font-weight: 700; margin-right: .2rem; }
.currency-usd { background: #DCFCE7; color: #16A34A; }
.currency-ars { background: var(--blue-light); color: var(--blue); }

/* ALERT */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 1rem; }
.alert-error   { background: #FEE2E2; border: 1px solid #FECACA; color: var(--error); }
.alert-success { background: #DCFCE7; border: 1px solid #BBF7D0; color: var(--success); }
.alert-info    { background: var(--blue-light); border: 1px solid #BFDBFE; color: var(--blue); }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--text); }
.modal-close { float: right; cursor: pointer; color: var(--text-muted); font-size: 1.3rem; line-height: 1; }

/* HERO */
.hero {
    padding: .5rem 0 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #EFF6FF 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--border);
}
.hero::before { content: ''; position: absolute; top: -200px; left: 50%; transform: translateX(-50%);
  width: 700px; height: 700px; background: radial-gradient(circle,rgba(37,99,235,.08) 0%,transparent 70%); pointer-events: none; }
.hero-title { font-size: clamp(2rem,5vw,3.5rem); font-weight: 800; line-height: 1.15; margin-bottom: 1rem; color: var(--text); }
.hero-title span { background: linear-gradient(135deg,var(--blue),#3B82F6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-sub { font-size: 1.1rem; color: var(--text-sec); max-width: 540px; margin: 0 auto 2rem; line-height: 1.7; }
.search-bar { display: flex; gap: .5rem; max-width: 540px; margin: 0 auto; }
.search-bar input { flex: 1; height: 50px; font-size: 1rem; }

/* SPINNER */
.spinner { display: inline-block; width: 36px; height: 36px; border: 3px solid rgba(37,99,235,.15);
  border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; min-height: 200px; }

/* PAGINATION */
.pagination { display: flex; align-items: center; gap: .4rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.page-btn { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--bg-card); color: var(--text-sec); cursor: pointer; font-size: .875rem; transition: all .2s; }
.page-btn:hover, .page-btn.active { border-color: var(--blue); color: var(--blue); }
.page-btn.active { background: var(--blue-light); }

/* TABLE */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: .75rem 1rem; color: var(--text-muted); font-weight: 600;
  border-bottom: 2px solid var(--border); background: var(--bg-elevated); }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--blue-light); }

/* SIDEBAR ADMIN */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 60px); }
.admin-sidebar { background: var(--bg-card); border-right: 1px solid var(--border); padding: 1.5rem 0; }
.admin-sidebar a { display: flex; align-items: center; gap: .6rem; padding: .65rem 1.5rem;
  color: var(--text-sec); font-size: .875rem; font-weight: 500; transition: all .15s; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: var(--blue-light); color: var(--blue); border-right: 3px solid var(--blue); }
.admin-content { padding: 2rem; background: var(--bg); }

/* SELECTS */
select.form-input { background-color: #fff; color: var(--text); min-height: 38px; overflow: visible; text-overflow: ellipsis; }
select.form-input option { background-color: #fff; color: var(--text); }

/* IMAGE GALLERY */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px,1fr)); gap: .5rem; }
.gallery img { width: 100%; height: 70px; object-fit: cover; border-radius: var(--radius-sm);
  cursor: pointer; border: 2px solid transparent; transition: border-color .2s; }
.gallery img.active, .gallery img:hover { border-color: var(--blue); }
/* Protección anti-descarga básica para fotos de publicaciones */
.gallery-main img, .gallery img {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none; /* evita menú "Guardar imagen" en long-press iOS */
  pointer-events: auto;
}
.gallery-main { width: 100%; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-elevated); margin-bottom: .75rem; }
.gallery-main img { width: 100%; max-height: 420px; object-fit: contain; }

/* MESSAGES */
.messages-wrap { display: flex; height: calc(100vh - 60px); }
.conv-list { width: 320px; border-right: 1px solid var(--border); overflow-y: auto; background: var(--bg-card); }
.conv-item { display: flex; gap: .75rem; padding: 1rem; cursor: pointer;
  transition: background .15s; border-bottom: 1px solid var(--border); }
.conv-item:hover, .conv-item.active { background: var(--blue-light); }
.conv-item .unread-dot { width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue); flex-shrink: 0; margin-top: 6px; }
.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: .6rem; }
.msg-bubble { max-width: 65%; padding: .55rem 1rem; border-radius: 16px; font-size: .9rem; line-height: 1.5; }
.msg-bubble.mine { background: var(--blue); color: #fff; align-self: flex-end; border-radius: 16px 16px 4px 16px; }
.msg-bubble.theirs { background: var(--bg-card); border: 1px solid var(--border); align-self: flex-start; border-radius: 16px 16px 16px 4px; }
.chat-input-area { padding: 1rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; background: var(--bg-card); }
.chat-input-area textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; }

/* VEHICLE FIELDS */
.vehicle-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .75rem; }

/* UTILS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: .5rem; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); } .text-blue { color: var(--blue); }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.w-full { width: 100%; }

/* Divider line */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .vehicle-fields { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .messages-wrap { flex-direction: column; }
  .conv-list { width: 100%; height: 220px; }
}

/* ── Fix: select dropdowns text clipping ── */
select.form-input {
  appearance: auto;
  -webkit-appearance: auto;
  text-overflow: ellipsis;
  min-height: 38px;
  overflow: visible;
}
select.form-input option {
  white-space: normal;
  overflow: visible;
}
/* Fix filter row wrapping to avoid clipping */
.filter-row select.form-input {
  width: 100%;
  min-width: 0;
}

/* ── Logo navbar fix ── */
.navbar-logo img {
  height: 48px !important;
  width: auto !important;
  display: block;
}
.navbar-logo {
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  flex-shrink: 0; /* nunca se achica ni se deforma */
}
.navbar-inner {
  gap: 1.5rem;
}
.navbar-links { flex-shrink: 0; }
.navbar-actions { flex-shrink: 0; }

/* ── Navbar responsive: que todo entre en pantallas chicas ── */
@media (max-width: 600px) {
  .navbar-inner { padding: 0 .85rem; gap: .6rem; }
  .navbar-logo img { height: 36px !important; }
  .navbar-links { gap: .75rem; }
  .navbar-actions { gap: .4rem; }
  .navbar-user { padding: 4px 8px; gap: .35rem; }
  .navbar-user span:first-of-type { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn-sm { padding: .3rem .6rem; font-size: .75rem; }
}
@media (max-width: 430px) {
  /* No entra "Explorar" como texto: lo pasamos a botón-ícono redondo de búsqueda */
  .navbar-links a {
    font-size: 0; /* oculta el texto, dejamos solo el ícono */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
  }
  .navbar-links a::before {
    content: "🔍";
    font-size: 15px;
  }
  .navbar-links a:hover { border-color: var(--blue); }
  .navbar-logo img { height: 32px !important; }
  .navbar-user span:first-of-type { display: none; } /* dejamos solo el avatar y la flechita */
}

/* ── Fix select text clipping in filter bar ── */
.filters-bar select,
.filter-row select,
select.form-input {
  appearance: auto !important;
  -webkit-appearance: auto !important;
  height: auto !important;
  min-height: 40px !important;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  line-height: 1.4 !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-break: break-word !important;
}
/* The filter bar grid columns need more width */
.filters-bar {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: .75rem !important;
  align-items: flex-end;
}
.filters-bar > div,
.filters-bar .form-group {
  flex: 1 1 130px !important;
  min-width: 120px !important;
}

/* ── Filter selects - prevent text clipping ── */
select.filter-select {
  height: auto !important;
  min-height: 40px !important;
  padding: 8px 28px 8px 10px !important;
  line-height: 1.4 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  appearance: auto !important;
  -webkit-appearance: auto !important;
  width: 100% !important;
}
