:root {
  --primary: #1a1a1a;
  --accent: #0070f3;
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
}

body { 
  font-family: 'Inter', -apple-system, sans-serif; 
  background-color: var(--bg); 
  color: var(--text-main);
  margin: 0; 
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

body.modal-open #main-content {
  overflow: hidden;
}

/* Header Estilo Apple/Cafran */
.navbar { 
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 100;
  padding: 1rem 2rem;
  box-shadow: 0 2px 6px rgba(0, 0, 128, 0.3);
  display: flex; align-items: center; justify-content: space-between;
  width: max(100%);
}

#menuLogo {
  display: flex;          /* Ativa o Flexbox */
  align-items: center;    /* Centraliza os itens verticalmente */
  justify-content: flex-start; /* Alinha os itens à esquerda */
  gap: 10px;              /* Espaço entre o botão de menu e o logo */
  height: 100%;           /* Garante que ocupe a altura total da navbar */
  margin-right: auto;
}

#menuToggle {
  border:none;  
  font-size:26px; 
  cursor:pointer;
}

.menu-btn-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-cart-badge {
  position: absolute;
  top: -4px;
  right: -6px;

  min-width: 20px;
  height: 20px;

  background: #A00;
  color: white;
  border-radius: 10px;
  font-size: 0.75rem;
  padding: 2px 7px;

  
  display: none;
  align-items: center;
  justify-content: center;

  pointer-events: none;
}


/* Layout Principal */
.main-wrapper { display: flex; max-width: 1400px; margin: 0 auto; }

#sidebar {
  position: fixed;
  top: 70px; /* height of navbar */
  left: 0;

  width: 300px;
  height: calc(100vh - 70px);

  padding: 1rem 0.5rem;

  overflow-y: auto;
  overscroll-behavior: contain;

  background: color-mix(in srgb, var(--bg) 95%, black);
  border-right: 1px solid #eaeaea;

  z-index: 50;
  
  transition: all 0.3s ease;
}

#sidebar.collapsed {
  transform: translateX(-100%);
}

.menu-item {
  padding: 10px 12px; margin-bottom: 4px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; cursor: pointer;
  transition: all 0.2s; font-size: 0.95rem; display: block;
}
.menu-item:hover { background: #eee; color: var(--primary); }
.menu-item.active { background: var(--primary); color: white; }

/* Product Section */
#main-content { 
  flex: 1; padding: 2rem; 
  margin-left: 260px;
  transition: all 0.3s ease;
  overflow-y: auto;
}

#main-content.expanded {
  margin-left: 0;
}

.family-section { margin-bottom: 3rem; }
.family-title { 
  font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; 
  padding-bottom: 0.5rem; border-bottom: 2px solid var(--primary);
}

/* Product Card - Estilo Cafran */
.product-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  display: flex; align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #efefef;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.08); }

.product-image-container {
  width: 90px; height: 90px; border-radius: 8px;
  background: #f3f4f6; overflow: hidden; margin-right: 1.5rem;
  flex-shrink: 0;
}
.product-img { width: 100%; height: 100%; object-fit: cover; }

.product-details { flex-grow: 1; }
.product-code { font-size: 0.75rem; color: var(--accent); font-weight: 600; text-transform: uppercase; }
.product-name { font-size: 1.1rem; font-weight: 600; margin: 4px 0; }
.product-price { font-size: 1.1rem; color: var(--accent); font-weight: 600; margin: 4px 0; }

/* Botão + Minimalista */
.expand-btn {
  color: #A00;
  width: 40px; height: 40px; border-radius: 50%;
  border: 2.5px solid #A00; background: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-size: 1.2rem; color: var(--text-muted);
}
.expand-btn:hover { border-color: white; color: white; background: #A00; }

.logout-btn {
  border: none;
  border-radius: 10%;
  background:#FFF; 
  color:#A00;
}

.logout-btn:hover {
  border: none;
  border-radius: 10%; 
  background:#A00; 
  color:#FFF; 
  cursor:pointer;
}

/* Drawer de Informações */
.info-drawer {
  display: none; padding: 1.5rem; background: #fafafa;
  border-bottom-left-radius: 12px; border-bottom-right-radius: 12px;
  margin-top: -12px; margin-bottom: 1rem; border: 1px solid #efefef; border-top: none;
}

.qty-container {
  display: inline-flex;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  width: fit-content;
  gap: 4px;
}

.qty-input {
  width: 56px;
  padding: 6px 10px;
  text-align: center;
  border: none;
  outline: none;
  font-size: 12px;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-input {
  -moz-appearance: textfield;
}

.add-cart-btn {
  margin-left: 10px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 500;

  border-radius: 4px;
  border: 1px solid #eaeaea;

  background: #ffffff;
  color: var(--primary);

  cursor: pointer;
  transition: all 0.2s ease;

  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.add-cart-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
}

#clear-cart-btn {
    width:100%;
    margin-top:8px;
    padding:6px;
    border-radius:8px;
    border:1px solid #eaeaea;
    background: #fff;
    cursor:pointer;
    font-size:12px;
}

#clear-cart-btn:hover {
  background: #000;
  color: white;
  transform: translateY(-1px);
}

.add-cart-btn:active {
  transform: scale(0.97);
}

.cart-box {
  background: var(--card-bg);
  border: 1px solid #efefef;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 20px;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

#cart-count {
  background: #A00;
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 10px;
}

.cart-items {
  font-size: 0.85rem;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.cart-footer {
  border-top: 1px solid #eee;
  margin-top: 8px;
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

#cart-box {
  background: #cefad0;
  display: none;
}

.whatsapp-btn {
  width: 100%;
  margin-top: 10px;
  padding: 8px;

  border-radius: 8px;
  border: 1px solid #eaeaea;

  background: #fff;
  color: #25D366; /* WhatsApp green */

  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.whatsapp-btn:hover {
  background: #25D366;
  color: white;
  border-color: #25D366;
}

.family-section {
  scroll-margin-top: 85px; /* navbar height */
}

/*.img-modal {
  display: none;
  position: fixed;
  z-index: 3000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  justify-content: center;
  align-items: center;
}

.img-modal-content {
  width: 500px;
  height: 500px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}
*/

.img-modal {
  display: none;
  position: fixed;
  z-index: 3000;
  inset: 0;

  background: rgba(0,0,0,0.7);

  justify-content: center;
  align-items: flex-start;

  overflow-y: auto;

  padding: 30px 20px;
  box-sizing: border-box;
}

.img-modal-content {
  width: 500px;

  background: #fff;
  border-radius: 12px;

  padding: 15px;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  gap: 20px;
}

.img-modal-content img {
  width: 100%;
  height: auto;

  object-fit: contain;

  border-radius: 8px;

  display: block;
}

.img-wrapper {
  position: relative;
  display: inline-block;
  cursor: zoom-in;
}


.drawer-product-img {
  width: 250px;
  max-width: 100%;
  
  background: #fff;
  border-radius: 12px;

  padding: 15px;
  box-sizing: border-box;

  object-fit: cover;
  display: block;
}

.dropdown-content {
	display: none;
	position: absolute;
	background-color: #DDD;
	width: 100%;
	box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
	z-index: 1000;
	max-height: 300px;
	overflow-y: auto;
	border-radius: 0 0 5px 5px;
}
.dropdown-item {
	padding: 10px;
	cursor: pointer;
	border-bottom: 1px solid #eee;
	display: flex;
	justify-content: space-between;
	background-color: #EEE;
	font-size: 0.7rem;
}
.dropdown-item:hover { background-color: #f1f1f1; }
.dropdown-item .code-label { font-weight: bold; color: #007bff; }

#product-search {
	width: 100%; padding: 10px; border-radius: 5px; border: 1px solid #ccc;font-size: 0.9rem;
}

.loader {
  width: 20px;
  height: 20px;
  border: 3px solid #ccc;
  border-top: 3px solid #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loader-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ---------------- MOBILE ---------------- */
@media (max-width: 768px) {


  .main-wrapper {
    flex-direction: column;
  }

#main-content {
    margin-top: 60px !important; /* Exatamente a altura da navbar */
    margin-left: 0 !important;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
  }
/*  #main-content {
    margin-left: 0 !important;
    top: 60px;
    width: 100%;
  }
*/

  #sidebar {
    position: fixed;
    top: 60px !important;
	width: min(99vw, 350px);
    height: calc(100vh - 60px); /* fill screen below header */

    overflow-y: auto;           /* enable vertical scroll */
    -webkit-overflow-scrolling: touch; /* smooth iOS scroll */

    border-right: 1px solid #fff;
    border-bottom: 1px solid #eee;
	z-index: 999;
  }

.navbar {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  padding: 5px 10px;
  margin: 0;

  display: flex;
  flex-direction: row !important; /* IMPORTANT */
  align-items: center;
  justify-content: space-between;

  background: white;
  box-sizing: border-box;
  overflow: hidden;
}

#menuLogo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}


#sessionInfo {
  flex: 1;
  min-width: 0;
  align-items: center;   
  justify-content: center;
  text-align: center; 
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.1;

  font-size: 0.85rem;
  padding-left: 10px;
}

  #logo {
    width: 40px;
    height: 40px;
    padding: 1px;
    border: 0px;
  }


  
  /* Product card adjustments */
  .product-card {
    flex-direction: column;
    align-items: flex-start;
  }
  */

  .product-image-container {
    width: 100%;
    text-align: center;
  }

  .product-img {
    max-width: 100%;
    height: auto;
  }
.product-name {
	font-size: 0.95rem;
}
  /* Buttons full width */
  .add-cart-btn {
    width: 100%;
    margin-top: 8px;
  }

  /* Cart box full width */
  .cart-box {
    width: 100%;
  }
}

@keyframes blinkCart {
  0%   { transform: scale(1); opacity: 1; }
  25%  { transform: scale(1.25); opacity: 0.4; }
  50%  { transform: scale(0.95); opacity: 1; }
  75%  { transform: scale(1.15); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

.cart-blink {
  animation: blinkCart 0.45s ease;
}

.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 9999;
  font-size: 14px;
  max-width: 90%;
  text-align: center;
  animation: toastIn 0.25s ease;
}
.app-toast-success { background: #2e7d32; }
.app-toast-warning { background: #ed6c02; }
.app-toast-error   { background: #c62828; }
.app-toast-fade    { opacity: 0; transition: opacity 0.3s ease; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.app-toast-info { background: #0277bd; }