/* ====================================
   FRONT-END MODERN STYLES
   nodourquiza.com — v2 (with dark mode)
   ==================================== */

/* ── CSS variables (light mode defaults) ─────────────────────────── */
:root {
  --fm-bg:           #f8fafc;
  --fm-card:         #ffffff;
  --fm-card-border:  #e2e8f0;
  --fm-text:         #1e293b;
  --fm-text-m:       #475569;
  --fm-text-l:       #94a3b8;
  --fm-primary:      #10b981;
  --fm-primary-d:    #059669;
  --fm-primary-l:    rgba(16,185,129,.08);
  --fm-primary-b:    rgba(16,185,129,.3);
  --fm-shadow-s:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --fm-shadow:       0 4px 16px rgba(0,0,0,.10);
  --fm-radius:       12px;
  --fm-radius-s:     8px;
  --fm-input-bg:     #ffffff;
  --fm-input-border: #d1d5db;
  --fm-filter-bg:    #f9fafb;
  --fm-filter-text:  #374151;
}

/* ── Dark mode overrides ──────────────────────────────────────────── */
body.dark {
  --fm-bg:           #0f172a;
  --fm-card:         #1e293b;
  --fm-card-border:  #334155;
  --fm-text:         #f1f5f9;
  --fm-text-m:       #94a3b8;
  --fm-text-l:       #64748b;
  --fm-primary-l:    rgba(16,185,129,.12);
  --fm-primary-b:    rgba(16,185,129,.4);
  --fm-shadow-s:     0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --fm-shadow:       0 4px 16px rgba(0,0,0,.4);
  --fm-input-bg:     #1e293b;
  --fm-input-border: #475569;
  --fm-filter-bg:    #1e293b;
  --fm-filter-text:  #94a3b8;
}

/* Page background */
body { transition: background-color .2s; }
body.dark { background: #080f1d !important; }
.container_16.fondo { background: var(--fm-bg) !important; transition: background-color .2s; }

/* =====================================================================
   NAVBAR / HEADER
   ===================================================================== */

#header-pagina {
  height: auto !important;
  min-height: 58px;
  display: flex !important;
  align-items: center !important;
  padding: 0 16px !important;
  box-sizing: border-box;
  gap: 8px;
  /* sticky en scroll: queda fijo arriba */
  position: sticky;
  top: 0;
  z-index: 500;
  /* el bg viene inyectado por jQuery (colorpagina3) — sticky requiere fondo opaco */
}

.front-navbar-left {
  flex-shrink: 0;
  width: auto !important;
  float: none !important;
  margin: 0 !important;
}

/* Home link — sits left of theme toggle */
#fm-home-btn {
  display: inline-flex; align-items: center;
  padding: .3rem .7rem; border-radius: 8px;
  background: none; border: none;
  font-size: .92rem; font-weight: 600; line-height: 1;
  color: rgba(255,255,255,.85) !important;
  text-decoration: none !important;
  cursor: pointer; transition: background .15s;
}
#fm-home-btn:hover { background: rgba(255,255,255,.18); }

/* Theme toggle button — sits at the far right end of the navbar */
#fm-theme-btn {
  margin-left: 8px;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: .3rem .45rem;
  border-radius: 8px;
  font-size: 1.15rem;
  line-height: 1;
  color: rgba(255,255,255,.85);
  transition: background .15s;
}
#fm-theme-btn:hover { background: rgba(255,255,255,.18); }

/* ── Desplegable de Categorías (al lado de Outlet) ──────────────── */
.fm-cat-dd { position: relative; display: inline-block; flex-shrink: 0; }
#fm-cat-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: .3rem .7rem; border-radius: 8px;
  background: none; border: none; cursor: pointer;
  font-size: .92rem; font-weight: 600; line-height: 1; font-family: inherit;
  color: rgba(255,255,255,.9) !important;
  transition: background .15s;
}
#fm-cat-btn:hover { background: rgba(255,255,255,.18); }
.fm-cat-caret { font-size: .7rem; transition: transform .15s; }
.fm-cat-dd.open .fm-cat-caret { transform: rotate(180deg); }
.fm-cat-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 6px; z-index: 800;
  width: 250px; max-width: calc(100vw - 24px); max-height: 70vh; overflow-y: auto;
}
.fm-cat-dd.open .fm-cat-menu { display: block; }
@media (hover: hover) {
  .fm-cat-dd:hover .fm-cat-menu { display: block; }
}
.fm-cat-item {
  display: block; padding: 9px 12px; border-radius: 7px;
  font-size: 13px; line-height: 1.3; color: #1e293b !important; text-decoration: none !important;
  white-space: normal;
}
.fm-cat-item:hover { background: #f1f5f9; }
.fm-cat-outlet { font-weight: 700; color: #b91c1c !important; border-bottom: 1px solid #f1f5f9; border-radius: 0; margin-bottom: 4px; }
body.dark .fm-cat-menu { background: #16213e; border-color: #2a3a5e; }
body.dark .fm-cat-item { color: #e6edf3 !important; }
body.dark .fm-cat-item:hover { background: #1f2d4d; }
body.dark .fm-cat-outlet { color: #fca5a5 !important; border-color: #2a3a5e; }
/* Mobile: el menú se ancla a la pantalla (fixed, ocupa el ancho) para que
   las descripciones se vean completas y no se corte contra el borde derecho.
   El top lo fija el JS al abrir (justo debajo del botón). */
@media (max-width: 820px) {
  #fm-cat-menu {
    position: fixed !important;
    left: 8px !important; right: 8px !important;
    width: auto !important; max-width: none !important;
  }
}

.front-navbar-right {
  width: auto !important;
  float: none !important;
  margin-left: auto !important;
  margin-top: 0 !important;
  flex-shrink: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

/* Category selector */
#selector-categorias {
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer;
  height: 34px;
  outline: none;
}

/* ── Login form (not logged in) ─────────────────────────────────── */

#form-login {
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  margin: 0 !important;
}

#form-login label { display: none !important; }

#form-login div { float: none !important; }

#form-login input.user,
#form-login input.pass {
  padding: 6px 10px !important;
  border-radius: 6px !important;
  border: 1px solid rgba(255,255,255,.4) !important;
  background: rgba(255,255,255,.18) !important;
  background-image: none !important;
  color: #fff !important;
  font-size: 13px !important;
  width: 110px !important;
  outline: none;
  height: 32px;
  box-sizing: border-box;
}

#form-login input.user::placeholder,
#form-login input.pass::placeholder {
  color: rgba(255,255,255,.65);
}

#form-login input.user:focus,
#form-login input.pass:focus {
  background: rgba(255,255,255,.28) !important;
  border-color: rgba(255,255,255,.75) !important;
}

#ingresar-login {
  padding: 5px 12px !important;
  border-radius: 6px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  height: 32px;
  box-sizing: border-box;
  border: none !important;
  white-space: nowrap;
  line-height: 1 !important;
}

#registro-login {
  padding: 5px 11px !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center;
  height: 32px;
  box-sizing: border-box;
  margin: 0 !important;
  white-space: nowrap;
}

/* ── Logged-in user bar ──────────────────────────────────────────── */

#logged {
  width: auto !important;
  margin-top: 0 !important;
  padding: 0 !important;
  text-align: left !important;
}

#logged p {
  font-size: 13px;
  color: rgba(255,255,255,.92);
  margin: 0;
  white-space: nowrap;
  line-height: 1;
}

#logged p a {
  color: rgba(255,255,255,.92) !important;
  text-decoration: none;
}

#logged p a:hover { color: #fff !important; text-decoration: underline; }

#logged .btn-pedido {
  padding: 5px 12px !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  display: inline-block !important;
  color: #fff !important;
  background-image: none !important;
  white-space: nowrap;
  margin-left: 4px !important;
  line-height: 1.5 !important;
}

/* ── Mobile / tablet: layout fluido + header sin recorte ──────────── */
@media (max-width: 820px) {
  /* el sitio usa grid fijo de 960px; en mobile lo hacemos fluido */
  .container_16, .container_12 {
    width: auto !important;
    max-width: 100% !important;
  }
  [class*="grid_"] {
    width: auto !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    display: block;
  }
  html, body { overflow-x: hidden; }

  #header-pagina {
    flex-wrap: wrap !important;
    row-gap: 8px;
    padding-top: 8px !important;
    padding-bottom: 10px !important;
  }
  /* fila 1: Inicio + Outlet + tema, ocupa el ancho */
  .front-navbar-left {
    flex-basis: 100% !important;
    display: flex !important;
    align-items: center;
    gap: 6px;
  }
  #fm-theme-btn { margin-left: auto !important; }
  /* fila 2: la barra de links / login baja a su propia fila completa */
  .front-navbar-right {
    flex-basis: 100% !important;
    margin-left: 0 !important;
  }

  /* ── Estado logueado: links envuelven, Ver Pedido a lo ancho ── */
  #logged { width: 100% !important; }
  #logged p { white-space: normal !important; line-height: 2 !important; }
  #logged .btn-pedido {
    display: block !important;
    text-align: center !important;
    margin: 8px 0 0 0 !important;
    padding: 9px 12px !important;
    font-size: 13px !important;
  }

  /* ── Estado deslogueado: login form no se recorta ── */
  #form-login {
    flex-wrap: wrap !important;
    width: 100% !important;
    gap: 8px !important;
  }
  #form-login > div {
    flex: 1 1 calc(50% - 4px) !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  /* la fila de botones (Ingresar + Registrarse) ocupa todo el ancho */
  #form-login > div:last-child {
    flex-basis: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }
  #form-login input.user,
  #form-login input.pass {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  #form-login #ingresar-login,
  #form-login #registro-login {
    flex: 1 1 0 !important;
    text-align: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }
}

/* ── Logo banner ─────────────────────────────────────────────────── */

.front-logo { margin: 0 !important; line-height: 0; overflow: hidden; }
.front-logo img { width: 100%; display: block !important; margin-top: 0 !important; }

/* =====================================================================
   SEARCH BAR
   ===================================================================== */

#form-buscador {
  margin: 12px 0 14px !important;
  display: flex !important;
  align-items: center;
  gap: 6px;
}

#form-buscador input[type="text"] {
  width: 480px !important;
  padding: 8px 12px !important;
  border: 1px solid var(--fm-input-border) !important;
  border-radius: var(--fm-radius-s) !important;
  font-size: 13px !important;
  outline: none;
  background: var(--fm-input-bg) !important;
  color: var(--fm-text) !important;
  transition: border-color .15s, box-shadow .15s;
}

#form-buscador input[type="text"]:focus {
  border-color: var(--fm-primary) !important;
  box-shadow: 0 0 0 3px var(--fm-primary-l);
}

#form-buscador input.btn-buscar {
  width: auto !important;
  height: auto !important;
  padding: 7px 16px !important;
  background: #3b82f6 !important;
  color: #fff !important;
  border: 1px solid #2563eb !important;
  border-radius: var(--fm-radius-s) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  text-indent: 0 !important;
  display: inline-block !important;
  line-height: 1.3 !important;
  white-space: nowrap;
  transition: background .15s;
}

#form-buscador input.btn-buscar:hover { background: #2563eb !important; }

/* =====================================================================
   FILTER BAR
   ===================================================================== */

#filtros {
  height: auto !important;
  overflow: visible !important;
  border-bottom: 1px solid var(--fm-card-border) !important;
  padding-bottom: 10px;
  margin-bottom: 16px;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#filtros .grid_6,
#filtros .grid_10 {
  float: none !important;
  width: auto !important;
  margin: 0 !important;
}

#filtros p { margin: 0 !important; display: flex; align-items: center; gap: 6px; }

#filtros .btn-listado,
#filtros .btn-galeria {
  display: inline-block !important;
  padding: 5px 12px !important;
  border-radius: 20px !important;
  border: 1px solid var(--fm-card-border) !important;
  background: var(--fm-filter-bg) !important;
  color: var(--fm-filter-text) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  transition: all .15s;
  line-height: 1.4 !important;
  margin: 0 !important;
}

#filtros .btn-listado:hover,
#filtros .btn-galeria:hover {
  border-color: #9ca3af !important;
  color: var(--fm-text) !important;
}

#filtros .grid_10 p { justify-content: flex-end; color: var(--fm-text-m); font-size: 12px; }

#filtros a { color: #3b82f6 !important; font-weight: 600 !important; }
#filtros a:hover { text-decoration: underline !important; }
#filtros .btn-listado, #filtros .btn-galeria { color: var(--fm-filter-text) !important; }

/* =====================================================================
   GALLERY (#galeria) — CSS Grid
   ===================================================================== */

#galeria {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)) !important;
  gap: 16px !important;
  margin: 0 !important;
  padding: 0;
}

#galeria .item {
  width: auto !important;
  height: auto !important;
  float: none !important;
  margin: 0 !important;
  background: var(--fm-card);
  border: 1px solid var(--fm-card-border);
  border-radius: var(--fm-radius);
  overflow: hidden !important;
  box-shadow: var(--fm-shadow-s);
  transition: box-shadow .2s, transform .2s, background-color .2s, border-color .2s;
  display: flex !important;
  flex-direction: column;
  box-sizing: border-box;
}

#galeria .item:hover {
  box-shadow: var(--fm-shadow);
  transform: translateY(-3px);
}

/* ──────────────────────────────────────────────────────────────────
   GUEST card structure (item-text, item-name, etc.)
   ────────────────────────────────────────────────────────────────── */

#galeria .item-text {
  height: auto !important;
  overflow: visible !important;
  display: flex;
  flex-direction: column;
}

#galeria .item-text > a {
  display: block !important;
  overflow: hidden;
  border-radius: var(--fm-radius) var(--fm-radius) 0 0;
  line-height: 0;
  background: #fff;
  flex-shrink: 0;
}

body.dark #galeria .item-text > a { background: #293548; }

#galeria .item-text > a img {
  width: 100% !important;
  height: 130px !important;
  object-fit: cover !important;
  display: block !important;
  transition: transform .22s;
}

#galeria .item:hover .item-text > a img { transform: scale(1.04); }

.item-name {
  padding: 8px 10px 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--fm-text);
  line-height: 1.35;
  flex: 1;
}

.item-name a {
  color: var(--fm-text) !important;
  text-decoration: none !important;
}

.item-name a:hover { color: var(--fm-primary) !important; }

.item-stock {
  padding: 3px 10px 6px;
  font-size: 11px;
  color: var(--fm-text-l);
}

#galeria .item-agregar {
  position: static !important;
  width: auto !important;
  height: auto !important;
  border-top: 1px solid var(--fm-card-border) !important;
  overflow: visible !important;
  margin: 0 !important;
  padding: 8px 10px 10px !important;
}

#galeria .item-precio {
  position: static !important;
  width: auto !important;
  color: inherit !important;
}

#galeria .item-precio a {
  display: block !important;
  text-align: center;
  padding: 7px 0 !important;
  border-radius: var(--fm-radius-s) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  background: var(--fm-primary-l) !important;
  border: 1px solid var(--fm-primary-b) !important;
  transition: background .15s;
}

#galeria .item-precio a:hover { opacity: .85; }

/* ──────────────────────────────────────────────────────────────────
   LOGGED-IN card structure (fm-*)
   ────────────────────────────────────────────────────────────────── */

/* Image wrapper — square aspect ratio */
.fm-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #ffffff;
  flex-shrink: 0;
  border-radius: var(--fm-radius) var(--fm-radius) 0 0;
}

body.dark .fm-img-wrap { background: #293548; }

.fm-img-wrap > a {
  display: block;
  width: 100%;
  height: 100%;
  line-height: 0;
}

.fm-img-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  transition: transform .3s;
}

#galeria .item:hover .fm-img-wrap img { transform: scale(1.05); }

/* Category badge (on image) */
.fm-cat-tag {
  position: absolute;
  top: .55rem;
  left: .55rem;
  background: rgba(0,0,0,.52);
  color: #fff !important;
  font-size: .68rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 50px;
  backdrop-filter: blur(4px);
  letter-spacing: .04em;
  text-transform: uppercase;
  pointer-events: none;
}

/* Card body */
.fm-body {
  padding: .75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: .25rem;
}

.fm-name {
  font-size: .9rem;
  font-weight: 700;
  color: var(--fm-text);
  line-height: 1.3;
}

.fm-name a {
  color: var(--fm-text) !important;
  text-decoration: none;
}

.fm-name a:hover { color: var(--fm-primary) !important; }

.fm-desc {
  font-size: .75rem;
  color: var(--fm-text-m);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: .1rem;
}

.fm-stock {
  font-size: .9rem;
  font-weight: 600;
  color: #475569;
  margin-top: .25rem;
}
body.dark .fm-stock { color: #e2e8f0; }

.fm-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--fm-primary);
  margin-top: auto;
  padding-top: .35rem;
}

/* Agregar button */
.fm-add-wrap { margin-top: .5rem; }

.fm-add-btn {
  width: 100%;
  padding: .6rem .5rem;
  background: var(--fm-primary);
  color: #fff;
  border: none;
  border-radius: var(--fm-radius-s);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, transform .12s;
  white-space: nowrap;
}

.fm-add-btn:hover { background: var(--fm-primary-d); transform: translateY(-1px); }
.fm-add-btn:active { transform: translateY(0); }
.fm-add-btn.fm-in-cart { background: var(--fm-primary-d); }

/* Quantity stepper (replaces + Agregar after first click) */
.fm-qty-ctrl {
  align-items: center;
  width: 100%;
  height: 36px;
  border: 1.5px solid var(--fm-primary);
  border-radius: var(--fm-radius-s);
  overflow: hidden;
  background: var(--fm-card);
  box-sizing: border-box;
}

.fm-qty-sub,
.fm-qty-add {
  flex-shrink: 0;
  width: 36px;
  height: 100%;
  background: var(--fm-filter-bg);
  border: none;
  color: var(--fm-text);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.fm-qty-sub:hover,
.fm-qty-add:hover {
  background: var(--fm-primary-l);
  color: var(--fm-primary);
}

.fm-qty-val {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-size: .92rem;
  font-weight: 700;
  color: var(--fm-primary);
  padding: 0;
  min-width: 0;
  pointer-events: auto;
  cursor: text;
  -moz-appearance: textfield;
}

/* =====================================================================
   LIST VIEW (#listado)
   ===================================================================== */

#listado {
  background: var(--fm-card);
  border: 1px solid var(--fm-card-border);
  border-radius: var(--fm-radius);
  overflow: hidden;
  margin-bottom: 12px;
  transition: background-color .2s, border-color .2s;
}

#listado .item {
  display: flex !important;
  align-items: center;
  padding: 10px 16px !important;
  border-bottom: 1px solid var(--fm-card-border) !important;
  margin-bottom: 0 !important;
  gap: 12px;
  background: var(--fm-card);
  transition: background .1s;
}

#listado .item:hover { filter: brightness(.97); }
body.dark #listado .item:hover { filter: brightness(1.06); }

#listado .item:last-child { border-bottom: none !important; }

#listado .item .grid_8 {
  float: none !important;
  width: auto !important;
  flex: 1;
  margin: 0 !important;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#listado .item .grid_8 .foto { flex-shrink: 0; display: block !important; line-height: 0; }

#listado .item .grid_8 img {
  width: 48px !important;
  height: 48px !important;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  border: 1px solid var(--fm-card-border);
}

#listado .item .grid_8 > a:not(.foto) {
  color: var(--fm-text) !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

#listado .item .grid_8 > a:not(.foto):hover { color: var(--fm-primary) !important; }

#listado .item .grid_2 { float: none !important; width: auto !important; margin: 0 !important; }

#listado .item .item-precio {
  position: static !important;
  width: auto !important;
}

#listado .item .item-precio a {
  display: inline-block !important;
  padding: 5px 14px !important;
  border-radius: var(--fm-radius-s) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  white-space: nowrap;
  background: var(--fm-primary-l) !important;
  border: 1px solid var(--fm-primary-b) !important;
  transition: opacity .15s;
}

#listado .item .item-precio a:hover { opacity: .8; }
