/* =========================================================
   FARMÁCIAS MEGA PHARMA — app de pedidos (PWA leve)
   Design tokens
   ========================================================= */
:root{
  /* Cores da marca (extraídas da logo oficial) */
  --mp-navy: #0E2A6E;
  --mp-navy-dark: #081b4d;
  --mp-navy-tint: #eef2fb;
  --mp-red: #E31E24;
  --mp-red-dark: #b8151a;
  --mp-white: #ffffff;

  --mp-ink: #172142;
  --mp-muted: #667088;
  --mp-border: #e2e7f3;
  --mp-bg: #f5f7fc;
  --mp-success: #17a363;
  --mp-success-tint: #e7f8ef;
  --mp-warn: #b8151a;
  --mp-warn-tint: #fdeceb;

  --mp-radius-sm: 10px;
  --mp-radius-md: 16px;
  --mp-radius-lg: 22px;
  --mp-shadow-sm: 0 1px 3px rgba(14,42,110,.08), 0 1px 2px rgba(14,42,110,.06);
  --mp-shadow-md: 0 8px 24px rgba(14,42,110,.12);
  --mp-shadow-lg: 0 -6px 24px rgba(14,42,110,.16);

  --mp-font-display: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --mp-font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,*::before,*::after{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family: var(--mp-font-body);
  background: var(--mp-bg);
  color: var(--mp-ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100vh;
}
img{ max-width:100%; display:block; }
button{ font-family: inherit; }
h1,h2,h3,h4{ font-family: var(--mp-font-display); margin:0; }
p{ margin:0; }
a{ color:inherit; }

.visually-hidden{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

:focus-visible{
  outline: 3px solid #6f8ff2;
  outline-offset: 2px;
  border-radius: 6px;
}

/* =========================================================
   Shell do app — largura de app mobile centralizada em telas grandes
   ========================================================= */
.app-shell{
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--mp-bg);
  position: relative;
  box-shadow: 0 0 60px rgba(14,42,110,.08);
  padding-bottom: 110px;
}

@media (min-width: 481px){
  body{ background: linear-gradient(180deg, var(--mp-navy-dark), #1a2b57 340px, var(--mp-bg) 340px); }
}

/* =========================================================
   Cabeçalho / topo
   ========================================================= */
.topbar{
  position: sticky; top:0; z-index: 40;
  background: linear-gradient(160deg, var(--mp-navy) 0%, var(--mp-navy-dark) 100%);
  color: var(--mp-white);
  padding: calc(14px + var(--safe-top)) 16px 16px;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  box-shadow: var(--mp-shadow-md);
}
.topbar__row{
  display:flex; align-items:center; gap:12px;
}
.topbar__logo{
  width:52px; height:52px; border-radius: 14px;
  background: var(--mp-white);
  display:flex; align-items:center; justify-content:center;
  padding:5px;
  flex-shrink:0;
  box-shadow: var(--mp-shadow-sm);
}
.topbar__logo img{ width:100%; height:100%; object-fit:contain; }
.topbar__brand{ flex:1; min-width:0; }
.topbar__name{
  font-size: 1.05rem; font-weight: 800; letter-spacing: .2px; line-height:1.15;
}
.topbar__slogan{
  font-size: .72rem; font-weight:600; letter-spacing:.4px; text-transform:uppercase;
  color: #ffd8d8; margin-top:2px;
}
.status-badge{
  display:inline-flex; align-items:center; gap:6px;
  font-size:.72rem; font-weight:700;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  white-space:nowrap;
  flex-shrink:0;
}
.status-badge__dot{
  width:8px; height:8px; border-radius:50%;
  background: #33e28a;
  box-shadow: 0 0 0 3px rgba(51,226,138,.25);
}
.status-badge.is-closed .status-badge__dot{
  background: #ff8b8b;
  box-shadow: 0 0 0 3px rgba(255,139,139,.25);
  animation:none;
}
.status-badge:not(.is-closed) .status-badge__dot{ animation: mp-pulse 1.8s ease-in-out infinite; }
@keyframes mp-pulse{
  0%,100%{ transform:scale(1); opacity:1; }
  50%{ transform:scale(1.35); opacity:.6; }
}

/* Busca */
.search-wrap{ margin-top:16px; position:relative; }
.search-icon{
  position:absolute; left:14px; top:50%; transform:translateY(-50%);
  width:20px; height:20px; color: var(--mp-navy); opacity:.55;
  pointer-events:none;
}
.search-input{
  width:100%;
  border:none;
  border-radius: var(--mp-radius-lg);
  padding: 14px 16px 14px 42px;
  font-size: .95rem;
  font-weight:500;
  background: var(--mp-white);
  color: var(--mp-ink);
  box-shadow: var(--mp-shadow-sm);
}
.search-input::placeholder{ color:#93a0bd; }
.search-clear{
  position:absolute; right:8px; top:50%; transform:translateY(-50%);
  width:28px; height:28px; border-radius:50%; border:none;
  background:var(--mp-navy-tint); color:var(--mp-navy);
  display:none; align-items:center; justify-content:center; cursor:pointer;
  font-size:16px; line-height:1;
}
.search-input:not(:placeholder-shown) ~ .search-clear{ display:flex; }

/* =========================================================
   Categorias (chips)
   ========================================================= */
.categories{
  display:flex; gap:8px; overflow-x:auto;
  padding: 14px 16px 4px;
  scrollbar-width:none;
}
.categories::-webkit-scrollbar{ display:none; }
.chip{
  flex-shrink:0;
  display:flex; align-items:center; gap:6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--mp-white);
  border:1px solid var(--mp-border);
  color: var(--mp-navy);
  font-size:.82rem; font-weight:700;
  cursor:pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .1s ease;
}
.chip__icon{ font-size:.95rem; line-height:1; }
.chip:active{ transform: scale(.96); }
.chip.is-active{
  background: var(--mp-navy);
  border-color: var(--mp-navy);
  color: var(--mp-white);
}

/* =========================================================
   Seções de produto
   ========================================================= */
.section{ padding: 18px 16px 4px; }
.section__head{
  display:flex; align-items:baseline; justify-content:space-between;
  margin-bottom:10px;
}
.section__title{
  font-size: 1rem; font-weight:800; color: var(--mp-navy-dark);
  display:flex; align-items:center; gap:8px;
}
.section__title .mp-cross{ color: var(--mp-red); }
.section__count{ font-size:.75rem; color:var(--mp-muted); font-weight:600; }

.product-grid{
  display:grid; grid-template-columns: 1fr 1fr; gap:12px;
}

.product-card{
  background: var(--mp-white);
  border-radius: var(--mp-radius-md);
  overflow:hidden;
  box-shadow: var(--mp-shadow-sm);
  display:flex; flex-direction:column;
  position:relative;
  border: 1px solid var(--mp-border);
}
.product-card__media{
  aspect-ratio: 1.2/1;
  background: var(--mp-navy-tint);
  display:flex; align-items:center; justify-content:center;
  position:relative;
  color: var(--mp-navy);
  font-size: 2rem;
}
.product-card__badge{
  position:absolute; top:8px; left:8px;
  display:flex; align-items:center; gap:4px;
  background: var(--mp-red);
  color:#fff; font-size:.62rem; font-weight:800;
  letter-spacing:.3px; text-transform:uppercase;
  padding: 4px 8px 4px 6px;
  border-radius: 999px;
  box-shadow: var(--mp-shadow-sm);
}
.product-card__badge .mp-cross{ font-size:.7rem; }
.product-card__badge.badge--muted{ background: var(--mp-navy); }
.product-card__unavailable{
  position:absolute; inset:0; background: rgba(23,33,66,.55);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-size:.72rem; font-weight:700; text-align:center; padding: 0 10px;
}
.product-card__body{ padding: 10px 12px 12px; display:flex; flex-direction:column; gap:4px; flex:1; }
.product-card__brand{ font-size:.66rem; font-weight:700; color: var(--mp-red); text-transform:uppercase; letter-spacing:.3px; }
.product-card__name{ font-size:.86rem; font-weight:700; line-height:1.25; color: var(--mp-ink); }
.product-card__pres{ font-size:.72rem; color: var(--mp-muted); }
.product-card__desc{ font-size:.72rem; color: var(--mp-muted); line-height:1.35; margin-top:2px; }
.product-card__footer{
  margin-top:auto; padding-top:8px;
  display:flex; align-items:center; justify-content:space-between; gap:8px;
}
.product-card__price{ font-size:.95rem; font-weight:800; color: var(--mp-navy-dark); }
.product-card__price small{ font-size:.65rem; font-weight:600; color:var(--mp-muted); display:block; }

.btn-add{
  width:34px; height:34px; border-radius:10px;
  border:none; background: var(--mp-navy);
  color:#fff; font-size:1.1rem; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  transition: transform .12s ease, background .15s ease;
  flex-shrink:0;
}
.btn-add:active{ transform: scale(.9); }
.btn-add:disabled{ background:#c7cede; cursor:not-allowed; }

.qty-stepper{
  display:flex; align-items:center; gap:0;
  background: var(--mp-navy-tint);
  border-radius:10px; overflow:hidden;
  flex-shrink:0;
}
.qty-stepper button{
  width:30px; height:34px; border:none; background:transparent;
  color: var(--mp-navy); font-size:1rem; font-weight:800; cursor:pointer;
}
.qty-stepper button:active{ background: rgba(14,42,110,.12); }
.qty-stepper__val{ min-width:20px; text-align:center; font-weight:800; font-size:.82rem; color: var(--mp-navy-dark); }

.empty-state{
  text-align:center; padding: 40px 20px; color: var(--mp-muted);
}
.empty-state__icon{ font-size:2rem; margin-bottom:8px; }
.empty-state__title{ font-weight:800; color: var(--mp-navy-dark); margin-bottom:4px; }

/* =========================================================
   Barra flutuante do carrinho
   ========================================================= */
.cart-bar{
  position: fixed; left:0; right:0; bottom:0; z-index:50;
  display:flex; justify-content:center;
  padding: 0 16px calc(16px + var(--safe-bottom));
  pointer-events:none;
}
.cart-bar__inner{
  pointer-events:auto;
  max-width: 448px; width:100%;
  background: var(--mp-red);
  color:#fff;
  border-radius: var(--mp-radius-lg);
  padding: 13px 16px;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  box-shadow: 0 10px 30px rgba(227,30,36,.4);
  cursor:pointer;
  border:none;
  transform: translateY(0);
  transition: transform .25s ease, opacity .25s ease;
}
.cart-bar__inner:active{ transform: scale(.98); }
.cart-bar.is-hidden .cart-bar__inner{ transform: translateY(140%); opacity:0; }
.cart-bar__left{ display:flex; align-items:center; gap:10px; }
.cart-bar__count{
  background:#fff; color:var(--mp-red); font-weight:800; font-size:.78rem;
  width:24px; height:24px; border-radius:50%; display:flex; align-items:center; justify-content:center;
}
.cart-bar__label{ font-weight:700; font-size:.86rem; }
.cart-bar__total{ font-weight:800; font-size:.95rem; }

/* =========================================================
   Overlay + Bottom sheets (carrinho / checkout)
   ========================================================= */
.overlay{
  position:fixed; inset:0; background: rgba(8,20,50,.5);
  z-index:60; opacity:0; pointer-events:none; transition: opacity .25s ease;
}
.overlay.is-open{ opacity:1; pointer-events:auto; }

.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:61;
  max-width:480px; margin:0 auto;
  background: var(--mp-bg);
  border-top-left-radius: 22px; border-top-right-radius:22px;
  box-shadow: var(--mp-shadow-lg);
  max-height: 88vh;
  display:flex; flex-direction:column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.sheet.is-open{ transform: translateY(0); }
.sheet__handle{
  width:40px; height:4px; border-radius:99px; background:#d6dcea;
  margin: 10px auto 4px;
}
.sheet__header{
  padding: 6px 18px 14px; display:flex; align-items:center; justify-content:space-between;
  border-bottom:1px solid var(--mp-border);
}
.sheet__title{ font-size:1.02rem; font-weight:800; color:var(--mp-navy-dark); }
.sheet__close{
  width:32px; height:32px; border-radius:50%; border:none; background:var(--mp-navy-tint);
  color:var(--mp-navy); font-size:1.1rem; cursor:pointer;
}
.sheet__body{ padding: 14px 18px; overflow-y:auto; flex:1; }
.sheet__footer{
  padding: 12px 18px calc(16px + var(--safe-bottom));
  border-top:1px solid var(--mp-border);
  background: var(--mp-white);
}

/* itens do carrinho */
.cart-item{ display:flex; gap:10px; padding: 10px 0; border-bottom:1px solid var(--mp-border); }
.cart-item:last-child{ border-bottom:none; }
.cart-item__icon{
  width:44px; height:44px; border-radius:10px; background: var(--mp-navy-tint);
  display:flex; align-items:center; justify-content:center; font-size:1.2rem; flex-shrink:0; color:var(--mp-navy);
}
.cart-item__info{ flex:1; min-width:0; }
.cart-item__name{ font-size:.85rem; font-weight:700; color:var(--mp-ink); }
.cart-item__pres{ font-size:.7rem; color:var(--mp-muted); margin-top:1px; }
.cart-item__row{ display:flex; align-items:center; justify-content:space-between; margin-top:6px; }
.cart-item__price{ font-size:.82rem; font-weight:800; color:var(--mp-navy-dark); }
.cart-item__remove{
  background:none; border:none; color:var(--mp-red); font-size:.7rem; font-weight:700; cursor:pointer; padding:4px 0;
}

.summary-row{ display:flex; justify-content:space-between; align-items:center; padding: 5px 0; font-size:.85rem; color: var(--mp-muted); }
.summary-row strong{ color: var(--mp-ink); font-weight:600; }
.summary-row.total{ font-size:1rem; padding-top:10px; margin-top:4px; border-top:1px dashed var(--mp-border); }
.summary-row.total strong{ color: var(--mp-navy-dark); font-weight:800; font-size:1.05rem; }

.btn-primary{
  width:100%; border:none; border-radius: var(--mp-radius-md);
  background: var(--mp-red); color:#fff;
  font-weight:800; font-size:.95rem; padding: 15px;
  cursor:pointer; display:flex; align-items:center; justify-content:center; gap:8px;
  transition: transform .12s ease, opacity .15s ease;
  box-shadow: 0 8px 20px rgba(227,30,36,.28);
}
.btn-primary:active{ transform: scale(.98); }
.btn-primary:disabled{ background:#c7cede; box-shadow:none; cursor:not-allowed; }
.btn-secondary{
  width:100%; border:1px solid var(--mp-border); border-radius: var(--mp-radius-md);
  background: var(--mp-white); color:var(--mp-navy-dark);
  font-weight:700; font-size:.88rem; padding: 12px;
  cursor:pointer;
}

/* =========================================================
   Checkout — formulários
   ========================================================= */
.seg-control{
  display:flex; background: var(--mp-navy-tint); border-radius: 12px; padding:4px; gap:4px;
}
.seg-control button{
  flex:1; border:none; background:transparent; padding:10px 8px; border-radius:9px;
  font-weight:700; font-size:.82rem; color: var(--mp-navy); cursor:pointer;
}
.seg-control button.is-active{ background:#fff; color:var(--mp-red); box-shadow: var(--mp-shadow-sm); }

.field-group{ margin-top:14px; }
.field-group legend, .field-label{
  font-size:.72rem; font-weight:800; text-transform:uppercase; letter-spacing:.4px;
  color: var(--mp-muted); margin-bottom:6px; display:block;
}
.field-row{ display:flex; gap:8px; }
.field-row > *{ flex:1; }
input[type="text"], input[type="tel"], textarea{
  width:100%; border:1px solid var(--mp-border); border-radius:12px;
  padding: 11px 13px; font-size:.88rem; font-family:inherit; color:var(--mp-ink);
  background:#fff; margin-bottom:10px;
}
textarea{ resize:vertical; min-height:60px; }
input:focus, textarea:focus{ border-color: var(--mp-navy); }

.pay-options{ display:flex; flex-direction:column; gap:8px; margin-top:6px; }
.pay-option{
  display:flex; align-items:center; gap:10px;
  border:1px solid var(--mp-border); border-radius:12px; padding: 11px 12px;
  cursor:pointer; background:#fff;
}
.pay-option.is-active{ border-color: var(--mp-navy); background: var(--mp-navy-tint); }
.pay-option__icon{ font-size:1.1rem; width:24px; text-align:center; }
.pay-option__label{ font-weight:700; font-size:.86rem; flex:1; }
.pay-option input{ width:auto; margin:0; accent-color: var(--mp-navy); }

.pix-key-box{
  margin-top:8px; background: var(--mp-navy-tint); border-radius:10px; padding:10px 12px;
  font-size:.78rem; color:var(--mp-navy-dark); display:flex; align-items:center; justify-content:space-between; gap:8px;
}
.pix-key-box code{ font-weight:700; }
.pix-key-box button{
  border:none; background:var(--mp-navy); color:#fff; font-size:.68rem; font-weight:700;
  padding:6px 10px; border-radius:8px; cursor:pointer; flex-shrink:0;
}

.map-link{
  display:inline-flex; align-items:center; gap:6px; margin-top:8px;
  font-size:.8rem; font-weight:700; color: var(--mp-navy);
  text-decoration:none; border-bottom: 1px solid var(--mp-navy);
}

.pickup-card{
  background: var(--mp-white); border:1px solid var(--mp-border); border-radius: var(--mp-radius-md);
  padding: 14px; margin-top:8px;
}
.pickup-card__title{ font-weight:800; font-size:.88rem; color: var(--mp-navy-dark); margin-bottom:4px; }
.pickup-card__text{ font-size:.8rem; color: var(--mp-muted); line-height:1.5; }

/* aviso de fechado */
.closed-banner{
  display:flex; gap:10px; align-items:flex-start;
  background: var(--mp-warn-tint); border:1px solid #f6c9c9;
  border-radius: var(--mp-radius-md); padding:12px 14px; margin: 0 16px 4px;
  font-size:.8rem; color: var(--mp-warn-dark, #8a1216);
}
.closed-banner__icon{ font-size:1.1rem; }
.closed-banner strong{ display:block; margin-bottom:2px; color: var(--mp-warn); }

/* =========================================================
   Toast de confirmação
   ========================================================= */
.toast{
  position:fixed; left:50%; bottom:26px; transform: translateX(-50%) translateY(20px);
  background: var(--mp-navy-dark); color:#fff; padding:12px 18px; border-radius:12px;
  font-size:.82rem; font-weight:600; box-shadow: var(--mp-shadow-md);
  z-index:80; opacity:0; pointer-events:none; transition: all .25s ease;
  display:flex; align-items:center; gap:8px; max-width: 90%;
}
.toast.is-visible{ opacity:1; transform: translateX(-50%) translateY(0); }

/* =========================================================
   Rodapé
   ========================================================= */
.footer{
  margin-top: 26px; padding: 22px 20px calc(20px + var(--safe-bottom));
  background: var(--mp-navy-dark); color: rgba(255,255,255,.85);
  border-top-left-radius: 22px; border-top-right-radius:22px;
}
.footer__brand{ display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.footer__logo{ width:38px; height:38px; border-radius:10px; background:#fff; padding:4px; }
.footer__name{ font-weight:800; color:#fff; font-size:.92rem; }
.footer__slogan{ font-size:.68rem; color:#ffb3b3; font-weight:700; text-transform:uppercase; letter-spacing:.3px; }
.footer__list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:7px; font-size:.78rem; }
.footer__list li{ display:flex; gap:8px; align-items:flex-start; }
.footer__divider{ height:1px; background: rgba(255,255,255,.12); margin:14px 0; }
.footer__credit{ font-size:.68rem; color: rgba(255,255,255,.45); text-align:center; }

/* =========================================================
   Prompt de instalação (Adicionar à tela inicial)
   ========================================================= */
.install-hint{
  margin: 14px 16px 0;
  background: linear-gradient(120deg, var(--mp-navy-tint), #fff);
  border:1px dashed #b9c6ea;
  border-radius: var(--mp-radius-md);
  padding: 12px 14px;
  display:flex; align-items:center; gap:10px;
  font-size:.78rem; color: var(--mp-navy-dark);
}
.install-hint__icon{ font-size:1.3rem; flex-shrink:0; }
.install-hint__close{
  margin-left:auto; background:none; border:none; color:var(--mp-muted); font-size:1rem; cursor:pointer; padding:4px;
}
.install-hint button.install-btn{
  border:none; background: var(--mp-navy); color:#fff; font-weight:700; font-size:.72rem;
  padding: 7px 10px; border-radius: 8px; cursor:pointer; white-space:nowrap;
}

.mp-cross{ display:inline-block; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}


/* =========================================================
   Validação final — demonstração, feedback e acessibilidade
   ========================================================= */
.demo-banner{
  margin:12px 14px 0; padding:10px 12px; border-radius:12px;
  display:flex; align-items:flex-start; gap:8px; flex-wrap:wrap;
  background:#fff8e6; border:1px solid #f0cf7b; color:#5f4500;
  font-size:.76rem; line-height:1.35;
}
.demo-banner strong{ font-size:.72rem; letter-spacing:.5px; }
.status-badge.is-orders-open{ background:#eef4ff; color:var(--mp-navy); }
.status-badge.is-orders-open .status-badge__dot{ background:#3b82f6; }
.closed-banner.is-orders-open{ background:#eef4ff; border-color:#c9d9ff; color:var(--mp-navy-dark); }

input.is-invalid, textarea.is-invalid{
  border-color:var(--mp-red) !important;
  box-shadow:0 0 0 3px rgba(227,30,36,.12);
  animation:mp-shake .32s ease;
}
@keyframes mp-shake{
  0%,100%{ transform:translateX(0); }
  25%{ transform:translateX(-5px); }
  50%{ transform:translateX(5px); }
  75%{ transform:translateX(-3px); }
}
@media (prefers-reduced-motion: reduce){
  input.is-invalid, textarea.is-invalid{ animation:none; }
}
