/* ============================================
   MOBILE — Improvements for all pages
============================================ */

/* Hamburger button (hidden on desktop, visible on mobile) */
.nav-burger {
  display: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  align-items: center; justify-content: center;
  background: transparent;
  color: var(--ink, #1f1a16);
  border: none; cursor: pointer;
  margin-left: 8px;
}
.nav-burger:hover { background: rgba(31,26,22,0.06); }
.nav-burger svg { width: 22px; height: 22px; }

/* Mobile menu drawer */
.mobile-menu {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 280px;
  background: var(--cream, #faf6ee);
  z-index: 110;
  transform: translateX(100%);
  transition: transform .4s cubic-bezier(.2,.7,.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 60px -20px rgba(31,26,22,0.3);
  padding: 24px 20px;
}
.mobile-menu.open { transform: translateX(0); }
.mobile-menu-overlay {
  position: fixed; inset: 0;
  background: rgba(31,26,22,0.55);
  backdrop-filter: blur(4px);
  z-index: 105;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s, visibility .3s;
}
.mobile-menu-overlay.open { opacity: 1; visibility: visible; }
.mobile-menu-close {
  align-self: flex-end;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: transparent;
  color: var(--ink, #1f1a16);
  border: none; cursor: pointer;
  margin-bottom: 18px;
}
.mobile-menu-close:hover { background: rgba(31,26,22,0.06); }
.mobile-menu a {
  display: block;
  padding: 16px 12px;
  font-family: "Cormorant Garamond", serif;
  font-size: 24px;
  color: var(--ink, #1f1a16);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(31,26,22,0.08);
  transition: color .2s, padding-left .2s;
}
.mobile-menu a:hover {
  color: #c75a87;
  padding-left: 18px;
}
.mobile-menu a.cta-mobile {
  margin-top: 18px;
  background: var(--ink, #1f1a16);
  color: var(--cream, #faf6ee);
  border-radius: 999px;
  padding: 14px 22px;
  text-align: center;
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  border-bottom: none;
}
.mobile-menu a.cta-mobile:hover { background: #c75a87; padding-left: 22px; }

/* ============ LANDING & PRODUCTOS — mobile ============ */
@media (max-width: 980px) {
  /* Prevent horizontal overflow globally */
  html, body { overflow-x: hidden !important; max-width: 100vw; }

  /* Show hamburger, hide links */
  .nav-burger { display: inline-flex; }
  .nav-links { display: none !important; }

  /* Trim padding so logo fits */
  .nav, .nav.scrolled {
    padding: 14px 16px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
  }
  .nav-logo { font-size: 20px; gap: 6px; flex-shrink: 0; min-width: 0; }
  .nav-logo svg:first-child { width: 32px; height: 32px; }
  .nav-wordmark { padding: 4px 8px 4px 12px; overflow: hidden; }
  .word-text { font-size: 20px; }
  .flor { display: none; }
  .nav-cta { padding: 10px 14px; font-size: 12px; }

  /* Productos nav-right icons keep but more compact */
  .nav-right { gap: 4px; }
  .nav-icon { width: 36px; height: 36px; }

  /* Hero on mobile — reduce padding, stack */
  .hero {
    padding: 110px 18px 40px !important;
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }
  .hero-title { font-size: clamp(40px, 11vw, 64px) !important; }
  .hero-sub { font-size: 15px; }
  .mosaic { height: 460px !important; }
  .hero-meta { gap: 24px !important; flex-wrap: wrap; }
  .hero-meta .stat-num { font-size: 28px; }
  .hero-meta .stat-lbl { font-size: 10px; }

  /* Sections */
  section { padding: 70px 18px !important; }
  .section-head h2 { font-size: clamp(32px, 8vw, 48px); }

  /* Categories — 2 col */
  .cats-grid { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
  .cat:nth-child(even) { transform: none !important; }
  .cat:nth-child(even):hover { transform: translateY(-6px) !important; }
  .cat-overlay h3 { font-size: 22px; }

  /* Products grid — 1-2 col */
  .product-grid { grid-template-columns: 1fr 1fr !important; gap: 16px !important; }
  .product-name { font-size: 18px; }

  /* Dedication */
  .dedi-wrap { grid-template-columns: 1fr !important; gap: 40px !important; }
  .giftcard { max-width: 320px; margin: 0 auto; }
  .dedi-copy h2 { font-size: clamp(36px, 9vw, 56px); }

  /* Contact section */
  .contact-wrap { grid-template-columns: 1fr !important; gap: 50px !important; }
  .contact-meta { grid-template-columns: 1fr !important; max-width: none; }
  .phone { width: 260px; height: 480px; }
  .contact-btn { padding: 12px 20px 12px 10px; }
  .contact-btn-text .num { font-size: 20px; }
  .contact-copy h2 { font-size: clamp(32px, 9vw, 56px); }

  /* Footer */
  footer { padding: 30px 18px 16px; margin-top: 0; }
  .foot-grid { grid-template-columns: 1fr 1fr !important; gap: 28px !important; }
  .foot-row { flex-direction: column; align-items: flex-start !important; }
  .foot-links { flex-wrap: wrap; gap: 16px !important; }
  .foot-copy { margin-top: 16px; padding-top: 14px; }

  /* Ticker */
  .ticker-track { font-size: 18px; gap: 36px; }
  .ticker-track .dot { width: 4px; height: 4px; }

  /* Productos page — page head + filters */
  .page-head { padding: 14px 16px 6px; }
  .page-head .eyebrow { font-size: 10px; letter-spacing: 0.25em; }
  .page-head h1 { font-size: clamp(28px, 8vw, 48px); margin-top: 6px; }
  .page-head p { font-size: 13px; margin-top: 8px; }

  .filters {
    padding: 0 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 6px 0 6px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .filter-chips {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .filter-chips::-webkit-scrollbar { height: 0; }
  .chip { white-space: nowrap; flex-shrink: 0; padding: 8px 14px; font-size: 12px; }
  .filter-right { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
  .sort-select { font-size: 12px; padding: 8px 12px; flex: 1; min-width: 0; }
  .result-count { font-size: 12px; }

  .catalog {
    padding: 0 14px 16px;
    gap: 16px !important;
    grid-template-columns: 1fr !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Product cards — single column, full width */
  .p-img { aspect-ratio: 1/1; }
  .p-body { padding: 14px 10px 8px; }
  .p-name { font-size: 13px; letter-spacing: 0.12em; min-height: auto; }
  .p-price-row { margin-top: 8px; font-size: 15px; }
  .p-save { font-size: 11px; }
  .p-quick { bottom: 12px !important; }

  /* Pagination */
  .pagination { padding: 10px 14px 16px; flex-wrap: wrap; gap: 6px; }
  .pagination button { width: 36px; height: 36px; font-size: 13px; }

  /* Search overlay */
  .search-overlay { padding: 14px 16px; }
  .search-bar { padding: 10px 14px; }
  .search-bar input { font-size: 15px; }
}

@media (max-width: 480px) {
  /* Single column on small screens */
  .product-grid { grid-template-columns: 1fr !important; }
  .cats-grid { grid-template-columns: 1fr !important; }

  .hero-meta > div { width: 47%; }
  .hero-meta { gap: 18px !important; }
  .mosaic { height: 380px !important; }
  .marquee-item { font-size: 18px; gap: 30px; }

  /* Admin login card */
  .login-card { padding: 28px 18px 24px; border-radius: 14px; }
  .login-shell { padding: 12px; }
  .login-card h1 { font-size: 28px; }

  /* Admin — tighter */
  .main { padding: 12px 10px 24px !important; }
  .main-head h2 { font-size: 22px; }
  .stat .val { font-size: 22px; }
}

/* ============ ADMIN TOPBAR + DRAWER — hidden on desktop ============ */
.admin-topbar { display: none; }
.admin-drawer-overlay { display: none; }
.admin-drawer { display: none; }
.table-scroll-hint { display: none; }

/* ============ ADMIN — mobile ============ */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr !important;
    overflow-x: hidden;
  }

  /* Hide desktop sidebar completely */
  #desktopSidebar { display: none !important; }

  /* === Top bar (like YouTube) === */
  .admin-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--ink, #1f1a16);
    color: var(--cream, #faf6ee);
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 70;
    width: 100%;
    box-sizing: border-box;
  }
  .topbar-burger {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: transparent;
    color: var(--cream, #faf6ee);
    border: none; cursor: pointer;
    transition: background .2s;
    flex-shrink: 0;
  }
  .topbar-burger:hover { background: rgba(255,255,255,0.1); }
  .topbar-brand {
    font-family: var(--serif, "Cormorant Garamond", serif);
    font-size: 22px;
    font-weight: 500;
    display: flex; align-items: center; gap: 10px;
  }
  .topbar-brand .sb-brand-mark {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(199, 90, 135, 0.18);
    color: var(--rose, #c75a87);
    display: grid; place-items: center;
    font-family: var(--serif, "Cormorant Garamond", serif);
    font-size: 13px; font-weight: 600;
  }

  /* === Drawer overlay === */
  .admin-drawer-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s, visibility .3s;
  }
  .admin-drawer-overlay.open { opacity: 1; visibility: visible; }

  /* === Drawer (slides from left) === */
  .admin-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--ink, #1f1a16);
    color: var(--cream, #faf6ee);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .35s cubic-bezier(.2,.7,.2,1);
    box-shadow: 8px 0 40px -10px rgba(0,0,0,0.5);
    padding: 0;
  }
  .admin-drawer.open { transform: translateX(0); }

  .drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 18px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .drawer-brand {
    font-family: var(--serif, "Cormorant Garamond", serif);
    font-size: 24px;
    font-weight: 500;
    display: flex; align-items: center; gap: 10px;
  }
  .drawer-brand .sb-brand-mark {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(199, 90, 135, 0.18);
    color: var(--rose, #c75a87);
    display: grid; place-items: center;
    font-family: var(--serif, "Cormorant Garamond", serif);
    font-size: 14px; font-weight: 600;
  }
  .drawer-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: transparent;
    color: rgba(250,246,238,0.6);
    border: none; cursor: pointer;
    transition: background .2s, color .2s;
  }
  .drawer-close:hover { background: rgba(255,255,255,0.08); color: var(--cream, #faf6ee); }

  .drawer-tag {
    padding: 10px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: rgba(250,246,238,0.4);
  }

  .drawer-nav {
    display: flex; flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    flex: 1;
  }
  .drawer-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: rgba(250,246,238,0.65);
    cursor: pointer;
    transition: background .2s, color .2s;
  }
  .drawer-item:hover { background: rgba(255,255,255,0.06); color: var(--cream, #faf6ee); }
  .drawer-item.active {
    background: rgba(199, 90, 135, 0.15);
    color: var(--cream, #faf6ee);
  }
  .drawer-item.active svg { color: var(--rose, #c75a87); }
  .drawer-item svg { opacity: 0.7; flex-shrink: 0; }
  .drawer-item.active svg { opacity: 1; }

  .drawer-footer {
    padding: 14px 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; flex-direction: column; gap: 4px;
  }
  .drawer-link {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    color: rgba(250,246,238,0.55);
    background: transparent;
    border: none; cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: background .2s, color .2s;
  }
  .drawer-link:hover { background: rgba(255,255,255,0.06); color: var(--cream, #faf6ee); }
  .drawer-logout:hover { color: #f87171; }

  /* === Main content area === */
  .main { padding: 16px 14px 32px !important; }
  .main-head { flex-direction: column; align-items: stretch !important; gap: 12px; }
  .main-head h2 { font-size: 26px; }
  .main-head p { font-size: 13px; }
  .main-head .btn-new { align-self: flex-start; }

  .stats { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .stat { padding: 14px 16px; }
  .stat .val { font-size: 26px; }

  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; }
  .search { width: 100%; }
  .tool-select { width: 100%; }

  /* Admin table → card layout on mobile */
  .table-wrap {
    overflow: visible;
    background: transparent;
    border: none;
    border-radius: 0;
  }

  /* Hide table header */
  .table-head { display: none !important; }

  /* Rows → stacked cards */
  .row {
    display: grid !important;
    grid-template-columns: 56px 1fr 1fr !important;
    grid-template-rows: auto auto auto auto !important;
    min-width: unset !important;
    gap: 6px 10px !important;
    padding: 14px !important;
    font-size: 13px !important;
    border-radius: 12px !important;
    margin-bottom: 10px;
    background: white;
    border: 1px solid var(--line, rgba(31,26,22,0.1)) !important;
    border-bottom: 1px solid var(--line, rgba(31,26,22,0.1)) !important;
    align-items: center;
  }
  .row:last-child { border-bottom: 1px solid var(--line, rgba(31,26,22,0.1)) !important; margin-bottom: 0; }

  /* Thumb — left, spans rows 1-2 */
  .row .thumb {
    grid-row: 1 / 3;
    grid-column: 1;
    width: 56px !important;
    height: 56px !important;
    border-radius: 10px;
  }

  /* Name — top right, spans 2 cols */
  .row .name-input {
    grid-row: 1;
    grid-column: 2 / 4;
    font-size: 14px !important;
    padding: 8px 10px !important;
  }

  /* Categories — row 2 */
  .row .cat-picker {
    grid-row: 2;
    grid-column: 2 / 4;
    display: flex !important;
    min-height: 32px;
    padding: 4px 8px !important;
  }

  /* Price fields — row 3, with labels */
  .row .price-input {
    grid-row: 3;
    grid-column: 1 / 2;
    font-size: 15px !important;
    padding: 8px 6px !important;
    text-align: center;
  }
  .row .old-input {
    grid-row: 3;
    grid-column: 2;
    font-size: 15px !important;
    padding: 8px 6px !important;
    text-align: center;
  }
  .row .toggle {
    grid-row: 3;
    grid-column: 3;
    justify-self: center;
    align-self: center;
  }

  /* Action row — row 4 */
  .row .feat-btn {
    grid-row: 4;
    grid-column: 1 / 3;
    width: auto !important;
    justify-content: center;
    border-radius: 8px;
    padding: 8px 12px !important;
    height: auto !important;
  }
  .row .delete-btn {
    grid-row: 4;
    grid-column: 3;
    justify-self: end;
  }

  /* Handle de arrastre — barra ancha al pie de la tarjeta, fácil de agarrar
     con el dedo. Ocupa una fila propia debajo de los controles. */
  .row .drag-handle {
    grid-row: 5;
    grid-column: 1 / 4;
    width: 100% !important;
    height: 38px;
    margin-top: 4px;
    border-radius: 9px;
    background: rgba(31, 26, 22, 0.06);
  }
  .row .drag-handle.disabled { display: none; }

  .table-scroll-hint { display: none; }

  .settings-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .settings-card { padding: 22px 18px; }
  .clients-grid { grid-template-columns: 1fr !important; }
  .sale-card { grid-template-columns: auto 1fr !important; gap: 12px; padding: 14px 16px; }
  .sale-total, .sale-actions { grid-column: 2; }

  .theme-options { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .theme-preview { height: 70px; padding: 8px; }

  .modal { padding: 24px 18px; max-height: 90vh; overflow-y: auto; }
  .modal h3 { font-size: 22px; }
  .field-row { grid-template-columns: 1fr; }
}

/* ============ VIEW IMAGE BUTTON + FULLSCREEN VIEWER — hidden on desktop ============ */
.pm-view-image { display: none; }
.img-viewer { display: none; }

/* ============ PRODUCT MODAL — mobile ============ */
@media (max-width: 760px) {
  /* "Ver imagen" button on top-left corner of modal image */
  .pm-view-image {
    display: inline-flex;
    position: absolute;
    top: 12px;
    left: 12px;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink, #1f1a16);
    border: none;
    border-radius: 999px;
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    z-index: 6;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    animation: pmViewPulse 2.4s ease-in-out infinite;
    transition: transform .2s, background .2s;
  }
  .pm-view-image:hover,
  .pm-view-image:active {
    background: white;
    transform: scale(1.05);
    animation: none;
  }
  .pm-view-image svg { flex-shrink: 0; }
  @keyframes pmViewPulse {
    0%, 100% {
      transform: scale(1);
      box-shadow: 0 4px 14px rgba(0,0,0,0.18), 0 0 0 0 rgba(199, 90, 135, 0.5);
    }
    50% {
      transform: scale(1.04);
      box-shadow: 0 6px 18px rgba(0,0,0,0.22), 0 0 0 8px rgba(199, 90, 135, 0);
    }
  }

  /* Fullscreen image viewer */
  .img-viewer {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 300;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
    padding: 20px;
  }
  .img-viewer.open {
    opacity: 1;
    visibility: visible;
  }
  .img-viewer-img {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transform: scale(0.85);
    transition: transform .4s cubic-bezier(.2,.7,.2,1);
  }
  .img-viewer.open .img-viewer-img {
    transform: scale(1);
    animation: imgViewerIn .5s cubic-bezier(.2,.7,.2,1);
  }
  @keyframes imgViewerIn {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
  }
  .img-viewer-close {
    position: absolute;
    top: 18px; right: 18px;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    cursor: pointer;
    display: grid; place-items: center;
    z-index: 5;
    transition: background .2s, transform .2s;
  }
  .img-viewer-close:hover,
  .img-viewer-close:active {
    background: rgba(255,255,255,0.28);
    transform: scale(1.05);
  }
  .img-viewer-hint {
    position: absolute;
    bottom: 24px; left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    animation: imgHintFade 2.4s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes imgHintFade {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.9; }
  }
}

/* ============ PRODUCT MODAL — mobile (continued) ============ */
@media (max-width: 760px) {
  .pm-overlay { padding: 0; align-items: flex-end; }
  .pm {
    grid-template-columns: 1fr !important;
    max-height: 100vh !important;
    height: 100vh;
    border-radius: 0 !important;
    max-width: 100% !important;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .pm-img {
    aspect-ratio: auto;
    height: 240px;
    min-height: 200px;
    flex-shrink: 0;
  }
  .pm-body {
    padding: 20px 18px 28px !important;
    max-height: none !important;
    overflow-y: visible !important;
  }
  .pm-cats { margin-bottom: 10px; gap: 5px; }
  .pm-cat-chip { font-size: 10px; padding: 3px 8px; }
  .pm-name { font-size: 22px !important; line-height: 1.1; }
  .pm-price { font-size: 22px !important; margin-top: 10px; gap: 8px; }
  .pm-price s { font-size: 15px; }
  .pm-save-row { font-size: 11px; }
  .pm-features-wrap { margin-top: 16px; padding-top: 14px; }
  .pm-features-title { font-size: 10px; margin-bottom: 10px; }
  .pm-features li { font-size: 11px; letter-spacing: 0.08em; gap: 8px; }
  .pm-field { margin-top: 14px; }
  .pm-field-title { font-size: 12px; }
  .pm-field input[type="text"],
  .pm-field textarea { padding: 10px 12px; font-size: 13px; }
  .pm-actions { margin-top: 18px; gap: 8px; }
  .pm-btn { padding: 14px 18px; font-size: 13px; border-radius: 12px; }
  .pm-note { margin-top: 16px; padding-top: 12px; font-size: 11px; }
  .pm-close {
    position: fixed;
    top: 10px; right: 10px;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.95) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 160;
  }
}

/* ============ SIDE PANEL — mobile already 100% width, just ensure ============ */
@media (max-width: 540px) {
  .side-panel { width: 100% !important; }
}

/* Hide whatsapp bubble copy on tiny screens, just keep icon */
@media (max-width: 540px) {
  .wa-bubble { display: none !important; }
  .wa-float { bottom: 16px !important; right: 16px !important; }
  .wa-icon { width: 54px !important; height: 54px !important; }
}
