/* Mari Presentes — ajustes responsivos complementares
   Este arquivo trabalha junto com style.css; não substitui o estilo existente. */

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  overflow-x: hidden;
}

img,
input,
select,
textarea,
button {
  max-width: 100%;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

/* Tablets */
@media (min-width: 651px) and (max-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view {
    padding-left: 20px;
    padding-right: 20px;
  }

  .topbar {
    padding-left: 22px;
    padding-right: 22px;
  }

  .panel {
    padding: 20px;
  }
}

/* Celulares */
@media (max-width: 650px) {
  .topbar {
    position: sticky;
    min-height: 0;
    padding: 12px 14px;
    gap: 11px;
    align-items: stretch;
  }

  .brand {
    min-width: 0;
    width: 100%;
  }

  .brand strong {
    font-size: 16px;
  }

  .brand small {
    font-size: 11px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .top-actions .button {
    min-width: 0;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 12px;
    line-height: 1.2;
    white-space: normal;
  }

  .view {
    width: 100%;
    max-width: 100%;
    padding: 14px 12px 30px;
  }

  .hero {
    padding: 24px 17px;
    border-radius: 17px;
  }

  .hero h1 {
    font-size: clamp(27px, 8vw, 36px);
    line-height: 1.12;
  }

  .hero > p:not(.eyebrow) {
    font-size: 14px;
    line-height: 1.45;
  }

  .catalog-search {
    margin-top: 18px;
  }

  .catalog-search input {
    min-height: 46px;
    font-size: 16px;
  }

  .section-heading {
    align-items: flex-end;
    flex-wrap: wrap;
    margin: 23px 0 13px;
    gap: 8px;
  }

  .section-heading h2,
  .panel h2 {
    font-size: 19px;
    line-height: 1.25;
  }

  /* Um cartão por linha evita que texto e preço fiquem espremidos.
     Mantém a miniatura compacta à esquerda, como no layout atual. */
  .product-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
  }

  .product-card {
    width: 100%;
    min-width: 0;
    border-radius: 12px;
  }

  .product-info h3 {
    font-size: 14px;
    line-height: 1.3;
  }

  .product-description {
    font-size: 12px;
    line-height: 1.4;
  }

  .price {
    font-size: 18px;
  }

  .whatsapp-button {
    min-height: 42px;
    font-size: 12px;
  }

  .login-card {
    width: 100%;
    max-width: 440px;
    margin: 22px auto;
    padding: 21px 17px;
    border-radius: 17px;
  }

  .admin-heading {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 17px;
  }

  .admin-heading > div {
    min-width: 0;
    flex: 1 1 210px;
  }

  .admin-heading h1 {
    font-size: 24px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  #logout-btn {
    min-height: 42px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 15px 0 20px;
  }

  .stat-card {
    min-width: 0;
    padding: 13px 12px;
    border-radius: 13px;
  }

  .stat-card span {
    font-size: 11px;
    line-height: 1.3;
    margin-bottom: 8px;
  }

  .stat-card strong {
    font-size: clamp(19px, 6vw, 24px);
  }

  .admin-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 7px;
    padding: 4px 1px 12px;
    margin: 0 -1px 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }

  .admin-tabs .tab {
    flex: 0 0 auto;
    min-height: 43px;
    padding: 10px 12px;
    font-size: 12px;
    scroll-snap-align: start;
  }

  .admin-tab {
    gap: 13px;
  }

  .panel {
    min-width: 0;
    padding: 15px 13px;
    border-radius: 15px;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 11px;
    margin-bottom: 15px;
  }

  .panel-heading > div {
    min-width: 0;
  }

  .panel-heading .button,
  .panel-heading .compact-input {
    width: 100%;
  }

  .compact-input {
    min-height: 43px;
    font-size: 16px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
  }

  .form-grid label,
  .stack label {
    min-width: 0;
    font-size: 13px;
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .stack input,
  .input {
    min-height: 44px;
    font-size: 16px;
  }

  .form-grid textarea {
    min-height: 88px;
  }

  .full {
    grid-column: 1 / -1;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .form-actions .button {
    width: 100%;
    min-height: 45px;
  }

  .form-message {
    overflow-wrap: anywhere;
  }

  .checkbox-label {
    align-items: flex-start;
    line-height: 1.4;
  }

  .checkbox-label input {
    flex: 0 0 auto;
    width: 19px;
    height: 19px;
    margin-top: 1px;
  }

  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 9px;
  }

  table {
    min-width: 690px;
    font-size: 12px;
  }

  th,
  td {
    padding: 10px 9px;
  }

  .small-button {
    min-height: 36px;
    padding: 8px 9px;
  }

  .row-actions {
    gap: 5px;
  }

  .photo-preview {
    gap: 7px;
  }

  .photo-preview img {
    width: 66px;
    height: 66px;
  }

  #existing-photos {
    max-width: 100%;
    overflow-x: auto;
  }

  #sale-items-body,
  #sales-table-body,
  #products-table-body,
  #customers-table-body,
  #movements-table-body {
    overflow-wrap: anywhere;
  }

  footer {
    padding: 17px 14px;
    flex-direction: column;
    gap: 5px;
  }

  .toast {
    width: calc(100% - 24px);
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: none;
    padding: 13px 14px;
    font-size: 13px;
  }
}

/* Celulares estreitos */
@media (max-width: 380px) {
  .view {
    padding-left: 9px;
    padding-right: 9px;
  }

  .topbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .top-actions .button {
    font-size: 11px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .stat-card span {
    margin: 0;
  }

  .stat-card strong {
    font-size: 21px;
    text-align: right;
  }

  .product-card > .product-info {
    padding: 9px;
  }
}

/* Reduz animações quando o dispositivo pede menos movimento */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Área dedicada de ponto de pedido e relatórios */
.reports-alerts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}
#stock-alert-panel,
#expiry-alert-panel {
  margin: 0 !important;
  min-width: 0;
  overflow-wrap: anywhere;
}
#reports-tab .panel-heading {
  align-items: flex-start;
}

/* Lente de aumento das fotos do catálogo */
.product-main-photo {
  cursor: zoom-in !important;
  transform-origin: center center;
  transition: transform .18s ease, filter .18s ease;
}
@media (hover: hover) and (pointer: fine) {
  .product-main-photo:hover {
    transform: scale(1.28);
    filter: drop-shadow(0 2px 5px rgba(30, 18, 45, .22));
  }
}
.product-main-photo:focus-visible {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
}

/* Janela ampliada: funciona com clique no computador e toque no celular */
.product-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
}
.product-lightbox.hidden {
  display: none !important;
}
.product-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 12, 32, .88);
  backdrop-filter: blur(3px);
}
.product-lightbox-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(100%, 1040px);
  max-height: 94vh;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.product-lightbox-figure {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
}
.product-lightbox-image {
  display: block;
  width: 100%;
  height: min(76vh, 760px);
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}
.product-lightbox-caption {
  margin-top: 8px;
  color: #554765;
  font-size: 13px;
  text-align: center;
}
.product-lightbox-close {
  position: absolute;
  top: 8px;
  right: 9px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #f2ebff;
  color: #55358a;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.product-lightbox-arrow {
  width: 42px;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: #f2ebff;
  color: #55358a;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
.product-lightbox-prev { grid-column: 1; grid-row: 1; }
.product-lightbox-next { grid-column: 3; grid-row: 1; }
.product-lightbox-counter {
  grid-column: 1 / -1;
  grid-row: 2;
  color: #766d83;
  font-size: 12px;
  text-align: center;
}
body.product-lightbox-open {
  overflow: hidden;
}
@media (max-width: 600px) {
  .product-lightbox {
    padding: 8px;
  }
  .product-lightbox-dialog {
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    gap: 5px;
    width: 100%;
    max-height: 96vh;
    padding: 12px 6px 10px;
    border-radius: 14px;
  }
  .product-lightbox-image {
    height: 78vh;
    max-height: 78vh;
  }
  .product-lightbox-arrow {
    width: 32px;
    height: 44px;
    font-size: 27px;
  }
  .product-lightbox-close {
    top: 4px;
    right: 4px;
    width: 34px;
    height: 34px;
    font-size: 24px;
  }
  .product-lightbox-caption {
    padding: 0 8px;
    font-size: 12px;
  }
}

