.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100% !important;
  max-width: 100vw !important;
  overflow: hidden;
  background: var(--bg-main) !important;
  position: relative;
}

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main) !important;
  position: relative;
  min-width: 0;
  width: 100%;
}

.top-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: #FFFFFF !important;
  border-bottom: 1px solid var(--glass-border);
  z-index: 50;
  flex-shrink: 0;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  width: 100%;
  max-width: 100%;
  margin: 0;
  -webkit-overflow-scrolling: touch;
}

/* --- Responsive Breakpoints --- */

/* Tablet & Smaller */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .top-header {
    padding: 0 1rem;
  }
  
  .page-content {
    padding: 1rem;
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  }
}

/* Mobile Specific */
@media (max-width: 480px) {
  .top-header {
    display: none !important; /* iOS Header will handle it on small mobile */
  }
  
  .page-content {
    padding: 0.75rem;
    /* Increased padding to ensure no content is cut off and respects safe areas */
    padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important;
  }
  
  /* Force containers to fill width */
  .card, .glass-card, .kpi-grid {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* Grid adjustments */
  .kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
}

/* Ensure images and videos are responsive */
img, video {
  max-width: 100%;
  height: auto;
}

/* Override iOS Styles from styles.css for total consistency */
.ios-navbar, .ios-search-row, .ios-large-title-row {
  background: #FFFFFF !important;
  backdrop-filter: none !important;
  width: 100% !important;
  box-sizing: border-box;
}

.ios-header {
  background: #FFFFFF !important;
  width: 100% !important;
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Ensure content doesn't get hidden under sticky headers on mobile */
@media (max-width: 480px) {
  .page-content {
    padding-top: 10px !important;
  }
}

/* --- Mobile & Tablet Bottom Navbar Styles --- */
@media (max-width: 1024px) {
  body.user-is-padeiro .sidebar {
    display: none !important;
  }

  body.user-is-padeiro .ios-menu-btn {
    display: none !important;
  }

  /* Put bell icon on the left, profile/avatar on the right for Padeiro */
  body.user-is-padeiro .ios-notif-btn {
    position: absolute !important;
    left: 16px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 15 !important;
  }

  body.user-is-padeiro .ios-navbar-right {
    display: flex !important;
    justify-content: flex-end !important;
    margin-left: auto !important;
  }

  /* Style mobile sidebar header for gestor */
  .sidebar-header.hig-mobile-only {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 0 24px !important;
    height: 100px !important;
    border-bottom: 1px solid var(--glass-border, rgba(0,0,0,0.05)) !important;
  }

  .sidebar-header.hig-mobile-only .sidebar-toggle-btn {
    display: none !important;
  }

  .sidebar-header.hig-mobile-only .sidebar-logo-img {
    height: 52px !important;
    width: auto !important;
    margin: 0 !important;
    display: block !important;
  }

  .bottom-navbar {
    position: fixed;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
    width: 280px;
    height: 64px;
    z-index: 9999;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    justify-items: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.50);
    backdrop-filter: blur(24px) saturate(190%);
    -webkit-backdrop-filter: blur(24px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 32px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), 
                0 2px 8px rgba(0, 0, 0, 0.04),
                inset 0 1px 2px rgba(255, 255, 255, 0.85),
                inset 0 -1px 1px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    padding: 0 8px;
    transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.32s ease;
    will-change: transform, opacity;
  }

  @media (min-width: 600px) and (max-width: 1024px) {
    .bottom-navbar {
      width: 360px;
      height: 66px;
      border-radius: 33px;
      padding: 0 12px;
    }
  }

  body.hide-bottom-navbar .bottom-navbar,
  .bottom-navbar.hidden {
    transform: translate(-50%, 140px) scale(0.88) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease !important;
  }

  /* Nav Indicator (The sliding bubble) */
  .nav-indicator {
    position: absolute;
    top: -16px;
    width: 60px;
    height: 60px;
    background: var(--primary, #1E4BFF);
    border-radius: 30px;
    box-shadow: 0 6px 16px rgba(30, 75, 255, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 0;
    will-change: width, left;
    transform: translateZ(0); /* Forçar GPU */
  }


  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    height: 48px;
    width: 48px;
    min-width: 48px;
    min-height: 48px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text-secondary, #4B5563);
    padding: 0;
    box-sizing: border-box;
    z-index: 1;
  }

  .bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    transition: all 0.2s ease;
  }

  .bottom-nav-icon i,
  .bottom-nav-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.75;
  }

  .bottom-nav-label {
    display: none !important;
  }

  /* Active item styling */
  .bottom-nav-item.active {
    color: #ffffff !important;
    background: none !important;
    border: none !important;
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    margin-top: 0;
    box-shadow: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-18px) scale(1);
    animation: highlightedNavItemBounce 0.4s cubic-bezier(0.25, 1, 0.5, 1) both;
  }
  
  .bottom-nav-item.active .bottom-nav-icon {
    width: 32px;
    height: 32px;
  }
  
  .bottom-nav-item.active .bottom-nav-icon i,
  .bottom-nav-item.active .bottom-nav-icon svg {
    width: 32px !important;
    height: 32px !important;
    stroke-width: 2;
  }

  .bottom-nav-item.active .bottom-nav-label {
    display: none;
  }

  body.dark-mode .nav-indicator,
  body.dark .nav-indicator,
  [data-theme="dark"] .nav-indicator {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  }

  /* Target icon specifically for bounce to avoid label jitter */
  .bottom-nav-item.active .bottom-nav-icon i,
  .bottom-nav-item.active .bottom-nav-icon svg {
    animation: iconBounce 0.35s cubic-bezier(0.25, 1, 0.5, 1) both;
  }

  /* Keyframes for fluid bounce animation */
  @keyframes iconBounce {
    0% { transform: scale(0.6); opacity: 0.5; }
    65% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
  }

  @keyframes highlightedNavItemBounce {
    0% { transform: translateY(-18px) scale(0.85); opacity: 0.5; }
    65% { transform: translateY(-18px) scale(1.15); opacity: 1; }
    100% { transform: translateY(-18px) scale(1); opacity: 1; }
  }

  /* Adjust page content to prevent overlap */
  body.user-is-padeiro .page-content,
  body.user-is-vendedor .page-content {
    padding-bottom: calc(110px + env(safe-area-inset-bottom)) !important;
  }
}

/* Hide bottom navbar on larger screens (desktop only) */
@media (min-width: 1025px) {
  .bottom-navbar {
    display: none !important;
  }
}

/* Sidebar Credits */
.sidebar-credits {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.3);
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  letter-spacing: 0.3px;
  margin-top: auto;
}


