/* ==========================================================================
   APP SHELL LAYOUT (SIDEBAR, HEADER, MAIN VIEW, MOBILE BOTTOM NAV)
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 100;
  transition: transform var(--transition-slow), width var(--transition-normal);
  overflow-y: auto;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-main);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-600), var(--accent-purple));
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

.brand-logo-img {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  object-fit: contain !important;
  flex-shrink: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  display: block !important;
}

.top-header-brand .brand-logo-img {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  object-fit: contain !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  display: block !important;
}

.login-brand-logo {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-2xl);
  object-fit: contain;
  display: block;
  margin: 0 auto 0.65rem;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
  border: 1.5px solid rgba(14, 165, 233, 0.35);
}

.pwa-banner-icon-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  object-fit: contain;
  flex-shrink: 0;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

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

.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 700;
  padding: 0.75rem 0.75rem 0.25rem;
  letter-spacing: 0.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

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

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
  color: var(--primary-400);
  border-right: 3px solid var(--primary-500);
}

.nav-icon {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.nav-badge {
  margin-right: auto;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--danger-500);
  color: white;
  font-weight: 700;
}

/* Main Content Area */
.main-container {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin var(--transition-normal);
}

/* Header Styles */
.top-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-search {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  width: 320px;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.header-search:focus-within {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.header-search input {
  background: none;
  border: none;
  width: 100%;
  color: var(--text-main);
  outline: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
  position: relative;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--primary-400);
}

.notification-indicator {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger-500);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-surface);
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-500), var(--accent-purple));
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* Page View Content */
.content-area {
  padding: 1.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 95;
  box-shadow: var(--shadow-lg);
}

.mobile-nav-items {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
  padding: 0 0.5rem;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  flex: 1;
  padding: 6px 0;
  cursor: pointer;
  position: relative;
}

.mobile-nav-item.active {
  color: var(--primary-400);
}

.mobile-nav-item.quick-add {
  transform: translateY(-14px);
}

.quick-add-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-600), var(--accent-purple));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
  border: 3px solid var(--bg-app);
}

/* Overlay for Mobile Sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block !important;
}

/* ==========================================================================
   DEDICATED FULL-SCREEN AUTHENTICATION PAGE (BEFORE LOGIN)
   ========================================================================== */
body.auth-mode .app-wrapper,
body.auth-mode .mobile-bottom-nav,
body.auth-mode .sidebar-overlay,
body.auth-mode .pwa-install-banner,
body.auth-mode #topbarInstallBtn {
  display: none !important;
}

body.auth-mode {
  background-color: #0b0f19 !important;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.18) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(14, 165, 233, 0.15) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(124, 58, 237, 0.12) 0px, transparent 50%) !important;
  background-attachment: fixed !important;
  min-height: 100vh !important;
  overflow-x: hidden !important;
}

/* Ensure Login Backdrop takes full screen without peeking */
#loginModal.modal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  background: transparent !important;
  z-index: 99999 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

#loginModal.modal-backdrop.active {
  display: flex !important;
}

/* Ensure Forgot Password Modal sits above login modal with matching luxury style */
#forgotPasswordModal.modal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  background: rgba(11, 15, 25, 0.85) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  z-index: 100000 !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  padding: 1.25rem 1rem !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

#forgotPasswordModal.modal-backdrop.active {
  display: flex !important;
}

#forgotPasswordModal .modal-card {
  max-width: 440px !important;
  width: 100% !important;
  margin: auto !important;
  background: var(--bg-surface-elevated, rgba(17, 24, 39, 0.96)) !important;
  border: 1px solid rgba(99, 102, 241, 0.32) !important;
  border-radius: var(--radius-2xl, 22px) !important;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 45px rgba(14, 165, 233, 0.18) !important;
  animation: login-card-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

