/* ========================================================
   STOCKFLOW | APP SHELL & LAYOUT (TASK PULSE INSPIRATION)
   ======================================================== */

#app-root {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background-color: var(--bg-app);
}

/* ========================================================
   SIDEBAR NAVIGATION (PURE WHITE & CORAL ACCENT)
   ======================================================== */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: var(--z-sidebar);
  transition: width var(--transition-smooth), transform var(--transition-smooth);
  border-right: 1px solid var(--border-light);
  box-shadow: 1px 0 3px rgba(20, 27, 52, 0.02);
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow: hidden;
  text-decoration: none;
}

.brand-logo-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  background: linear-gradient(135deg, #FF6E40 0%, #FF5722 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.3);
}

.brand-text {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
}

.brand-title {
  font-size: var(--text-md);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
}

.sidebar-collapse-btn {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-collapse-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Sidebar Navigation Items */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-3) var(--space-1);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.68rem var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
  text-decoration: none;
  cursor: pointer;
}

.nav-item:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
}

/* Active Nav State — Exact match to Task Pulse image: soft orange/peach background & coral text */
.nav-item.active {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: transform var(--transition-fast);
}

.nav-item:hover .nav-icon {
  transform: scale(1.05);
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.nav-item.active .nav-badge {
  background: var(--color-primary);
  color: #FFFFFF;
}

/* Sidebar Promo Upgrade Card ("Go Premium" like Task Pulse) */
.sidebar-promo-card {
  margin: var(--space-2) var(--space-3) var(--space-3);
  padding: var(--space-4);
  background: linear-gradient(180deg, #FFF8F5 0%, #FFF0E9 100%);
  border: 1px solid #FFE4D6;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
}

.promo-crown-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #F59E0B;
}

.promo-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.promo-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}

.promo-btn {
  margin-top: 4px;
  background-color: var(--color-primary);
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  height: 32px;
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

.promo-btn:hover {
  background-color: var(--color-primary-hover);
}

/* Sidebar Footer (Warehouse status badge) */
.sidebar-footer {
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid var(--border-light);
  background-color: var(--bg-surface);
}

.warehouse-pill {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
}

.warehouse-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.warehouse-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.warehouse-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.warehouse-rotation {
  color: var(--text-secondary);
  font-size: 0.7rem;
}

/* Collapsed Sidebar State */
.app-sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .nav-text,
.app-sidebar.collapsed .nav-badge,
.app-sidebar.collapsed .nav-section-label,
.app-sidebar.collapsed .sidebar-promo-card,
.app-sidebar.collapsed .warehouse-details {
  display: none;
}

.app-sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}

.app-sidebar.collapsed .brand-wrapper {
  justify-content: center;
}

.app-sidebar.collapsed .sidebar-collapse-btn {
  display: none;
}

.app-sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem 0;
}

.app-sidebar.collapsed .warehouse-pill {
  justify-content: center;
  padding: var(--space-2);
}

/* ========================================================
   MAIN CONTENT SHELL
   ======================================================== */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-smooth);
}

.app-sidebar.collapsed + .app-main {
  margin-left: var(--sidebar-width-collapsed);
}

/* ========================================================
   TOPBAR HEADER (CLEAN PILL SEARCH & USER PROFILE)
   ======================================================== */
.app-topbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  box-shadow: 0 1px 2px rgba(20, 27, 52, 0.02);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

/* Global Pill Search Bar (Task Pulse style) */
.global-search-container {
  position: relative;
  width: 380px;
  max-width: 100%;
}

.global-search-input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-4) 0 2.6rem;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.global-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-glow);
  width: 440px;
}

.global-search-input::placeholder {
  color: var(--text-muted);
}

.global-search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 380px;
  overflow-y: auto;
  z-index: 150;
  display: none;
}

.search-results-dropdown.active {
  display: block;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Notification Bell with Coral Badge */
.topbar-bell-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  transition: all var(--transition-fast);
}

.topbar-bell-btn:hover {
  background-color: #F1F5F9;
  color: var(--text-primary);
}

.notif-badge-counter {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background-color: var(--color-primary);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface);
}

/* User & Role Simulator Pill (Matching Sarah Kim in Task Pulse) */
.user-simulator-pill {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.35rem 0.85rem 0.35rem 0.45rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-simulator-pill:hover {
  background: var(--bg-surface-alt);
  border-color: var(--border-strong);
}

.user-avatar-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #FFFFFF;
  background: linear-gradient(135deg, #FF6E40 0%, #FF5722 100%);
  box-shadow: 0 2px 6px rgba(255, 87, 34, 0.25);
  overflow: hidden;
}

.user-avatar-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user-info-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.user-info-role {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ========================================================
   CONTENT CONTAINER
   ======================================================== */
.app-content {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Mobile Sidebar Drawer Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(20, 27, 52, 0.4);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ========================================================
   RESPONSIVE DESIGN RULES
   ======================================================== */
@media (max-width: 1200px) {
  .global-search-container {
    width: 280px;
  }
  .global-search-input:focus {
    width: 320px;
  }
  .app-content {
    padding: var(--space-6);
  }
}

@media (max-width: 900px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .app-sidebar.mobile-open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0 !important;
    width: 100%;
    max-width: 100vw;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .app-topbar {
    padding: 0 var(--space-4);
  }
  .app-content {
    padding: var(--space-4);
  }
  .global-search-container {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-topbar {
    padding: 0 var(--space-3);
    height: 62px;
  }
  .topbar-right {
    gap: var(--space-2);
  }
  /* Hide prefix breadcrumb "Bodega360 /" and show only active section */
  .breadcrumb-nav .breadcrumb-item:not(.current),
  .breadcrumb-nav .breadcrumb-separator {
    display: none;
  }
  .breadcrumb-item.current {
    font-size: var(--text-base);
    font-weight: 800;
  }
  /* In user pill, hide text so only circular avatar remains visible */
  .user-simulator-pill .user-info-text,
  .user-simulator-pill svg {
    display: none;
  }
  .user-simulator-pill {
    padding: 2px;
    background: transparent;
    border: none;
  }
  .app-content {
    padding: var(--space-3);
  }
}

@media (max-width: 440px) {
  /* On very compact screens, shorten or hide Tour button text */
  #btn-start-tour .tour-btn-text {
    display: none;
  }
  #btn-start-tour {
    padding: 0 var(--space-2);
    min-width: 34px;
    height: 34px;
  }
  .topbar-left {
    gap: var(--space-2);
  }
  .topbar-right {
    gap: 6px;
  }
  .topbar-bell-btn {
    width: 36px;
    height: 36px;
  }
  .user-avatar-badge {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
}

/* ========================================================
   APPLICATION FOOTER (DISCLAIMER & CREDITS)
   ======================================================== */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  background-color: var(--bg-surface);
  padding: var(--space-6) var(--space-8);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: 1.6;
}

.footer-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
}

.footer-disclaimer {
  max-width: 820px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 0;
}

.footer-author {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0;
}

.footer-author a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-author a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

@media (max-width: 768px) {
  .app-footer {
    padding: var(--space-5) var(--space-4);
  }
}


