/* ==========================================================================
   APP LAYOUT & STRUCTURE
   ========================================================================== */

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-main);
}

/* App Shell (Visible after login) */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   SIDEBAR (DESKTOP)
   ========================================================================== */

.app-sidebar {
  width: var(--sidebar-width);
  background-color: #030303;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-smooth), transform var(--transition-smooth);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1rem 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.brand-logo-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #181818, #0a0a0a);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(214, 126, 72, 0.15);
  flex-shrink: 0;
  overflow: hidden;
  padding: 4px;
}

.brand-logo-wrap .brand-logo-img,
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}

.brand-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.6875rem;
  color: var(--accent-primary);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Sidebar desktop collapse toggle button */
.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background-color: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

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

.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-smooth);
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.5rem 0.75rem 0.25rem;
  transition: opacity var(--transition-fast);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.nav-item.active {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -0.75rem;
  top: 15%;
  height: 70%;
  width: 3px;
  background-color: var(--accent-primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-footer {
  padding: 0.875rem 0.875rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-color: #020202;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.25rem 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #242424, #121212);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent-primary);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.2;
}

.user-name {
  font-size: 0.78125rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.user-role {
  font-size: 0.65625rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Reduced size Logout Button */
.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.375rem;
  padding: 0.35rem 0.5rem;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-logout svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-logout:hover {
  color: var(--semantic-expense);
  background-color: var(--semantic-expense-subtle);
}

/* ==========================================================================
   COLLAPSIBLE SIDEBAR STATE (DESKTOP)
   ========================================================================== */

.app-shell.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
}

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

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-section-label,
.app-shell.sidebar-collapsed .nav-item span,
.app-shell.sidebar-collapsed .user-details,
.app-shell.sidebar-collapsed .btn-logout span {
  display: none !important;
}

.app-shell.sidebar-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.app-shell.sidebar-collapsed .sidebar-nav {
  padding: 1.25rem 0.5rem;
  align-items: center;
}

.app-shell.sidebar-collapsed .nav-item {
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
}

.app-shell.sidebar-collapsed .nav-item.active::before {
  left: -0.5rem;
}

.app-shell.sidebar-collapsed .sidebar-footer {
  padding: 0.75rem 0.5rem;
  align-items: center;
}

.app-shell.sidebar-collapsed .user-profile-badge {
  justify-content: center;
  width: 100%;
}

.app-shell.sidebar-collapsed .btn-logout {
  width: 36px;
  height: 30px;
  padding: 0;
  justify-content: center;
}

.app-shell.sidebar-collapsed .main-wrapper {
  margin-left: var(--sidebar-collapsed-width);
  width: calc(100% - var(--sidebar-collapsed-width));
}

/* ==========================================================================
   MAIN VIEWPORT & TOP HEADER
   ========================================================================== */

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-width));
  transition: margin-left var(--transition-smooth), width var(--transition-smooth);
}

.app-header {
  height: var(--header-height);
  background-color: rgba(1, 1, 1, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Estado de Caja Indicator */
.cash-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.875rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.cash-status-text {
  color: var(--text-secondary);
}

.cash-status-amount {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Content Area */
.main-content {
  flex: 1;
  padding: 1.75rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   MOBILE NAVIGATION
   ========================================================================== */

.mobile-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: rgba(10, 10, 10, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  height: 100%;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 500;
}

.mobile-nav-btn svg {
  width: 20px;
  height: 20px;
}

.mobile-nav-btn.active {
  color: var(--accent-primary);
}

.mobile-nav-btn:hover {
  color: var(--text-primary);
}

.menu-toggle-btn {
  display: none;
}

/* Responsive Breakpoints */
@media (max-width: 860px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
    padding-bottom: calc(var(--bottom-nav-height) + 1rem);
  }

  .mobile-nav-bar {
    display: grid;
  }

  .menu-toggle-btn {
    display: inline-flex;
  }

  .main-content {
    padding: 1.25rem 1rem;
  }

  .app-header {
    padding: 0 1rem;
  }
}
