/* =============================================
   KNOWTHEM — LAYOUT
   App shell, sidebar, nav, panels
   ============================================= */

/* =============================================
   APP SHELL
   ============================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  transition: transform var(--dur-base) var(--ease);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 20px var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
  width: 28px; height: 28px;
}

.sidebar-logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-3) var(--sp-1);
  margin-top: var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item svg { flex-shrink: 0; }

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

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .nav-badge {
  margin-left: auto;
}

/* Sidebar bottom — upgrade banner */
.sidebar-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
}

.upgrade-card {
  background: linear-gradient(135deg, var(--accent-soft) 0%, #e8f5e9 100%);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
}

.upgrade-card p { font-size: var(--text-xs); color: var(--text-secondary); margin-top: var(--sp-1); margin-bottom: var(--sp-3); }

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-content.with-right-panel {
  margin-right: var(--right-panel-w);
}

/* =============================================
   TOP BAR (desktop)
   ============================================= */
.topbar {
  height: 60px;
  background: rgba(250,250,248,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-search {
  flex: 1;
  max-width: 500px;
}

.topbar-search .search-bar {
  height: 38px;
  padding: 0 var(--sp-4);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: auto;
}

.topbar-notif {
  position: relative;
}

.topbar-notif .badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  min-width: 0; font-size: 9px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg-card);
  transition: box-shadow var(--dur-fast) var(--ease);
}
.user-chip:hover { box-shadow: var(--shadow-sm); }
.user-chip-name { font-size: var(--text-sm); font-weight: 500; }
.user-chip-role { font-size: 10px; color: var(--text-muted); }

/* =============================================
   PAGE CONTENT
   ============================================= */
.page-content {
  flex: 1;
  padding: var(--sp-6) var(--sp-8);
  max-width: 1600px;
  width: 100%;
  min-width: 0;
}

.page-header {
  margin-bottom: var(--sp-6);
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 4px;
}

/* =============================================
   RIGHT PANEL
   ============================================= */
.right-panel {
  width: var(--right-panel-w);
  height: 100vh;
  position: fixed;
  top: 0; right: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: var(--sp-6) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.right-panel-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-3);
}

/* =============================================
   MOBILE BOTTOM NAV
   ============================================= */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 12px; right: 12px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  padding: 8px;
}

.mobile-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
}

.mobile-nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.mobile-nav-add {
  width: 48px; height: 48px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(79,111,82,0.4);
  border: none; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.mobile-nav-add:hover { transform: scale(1.05); }
.mobile-nav-add:active { transform: scale(0.96); }

/* =============================================
   MOBILE TOPBAR
   ============================================= */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0; z-index: 100;
}

.mobile-topbar-title {
  font-size: var(--text-lg);
  font-weight: 700;
}

/* =============================================
   SIDEBAR OVERLAY (mobile)
   ============================================= */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* =============================================
   RESPONSIVE BREAKPOINTS
   ============================================= */

@media (min-width: 769px) {
  #sidebar-toggle {
    display: none !important;
  }
}

/* Large Desktop */
@media (min-width: 1441px) {
  .page-content {
    max-width: 1600px;
    margin: 0 auto;
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .right-panel { display: none; }
  .main-content.with-right-panel { margin-right: 0; }
  .page-content { padding: var(--sp-5) var(--sp-6); }
}

/* Small Tablet */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .main-content { margin-left: 0; padding-bottom: calc(var(--nav-h-mobile) + 40px) !important; }
  .sidebar-footer { display: none; }
  .topbar { display: none; }
  .mobile-topbar { display: flex; }
  .mobile-nav { display: block; }
  .page-content {
    padding: var(--sp-4) var(--sp-4);
    padding-bottom: calc(var(--nav-h-mobile) + 24px);
  }
}

/* Mobile */
@media (max-width: 480px) {
  .page-content { padding: var(--sp-3); padding-bottom: calc(var(--nav-h-mobile) + 24px); }
}

/* Small Mobile */
@media (max-width: 375px) {
  .page-content { padding: 12px; padding-bottom: calc(var(--nav-h-mobile) + 24px); }
}
