/* ============================================
   EGK Residents - Layout
   Sidebar, content area, tab bar, responsive
   ============================================ */

@media (max-width: 500px) { .pub-lbl { display: none; } }

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-neutral-900);
  color: var(--color-neutral-300);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: var(--z-sidebar);
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
  overflow: visible; /* allow tooltip to escape sidebar bounds */
}
/* Tooltip on collapsed nav items */
.sidebar.collapsed .sidebar-nav { overflow: visible; }
.sidebar.collapsed .nav-item {
  overflow: visible;
  position: relative;
}
.sidebar.collapsed .nav-item::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-neutral-800);
  color: var(--color-white);
  padding: 3px 10px;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 9999;
  box-shadow: var(--shadow-md);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
  min-height: var(--topbar-height);
}

.sidebar-logo {
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--color-neutral-400);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.sidebar-toggle:hover { color: var(--color-white); }

/* Nav items */
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-2) 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--color-neutral-400);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  margin: 1px var(--space-2);
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: rgb(255 255 255 / 0.06); color: var(--color-white); text-decoration: none; }
.nav-item.active { background: var(--color-primary); color: var(--color-white); }
.nav-item i { width: 16px; text-align: center; flex-shrink: 0; font-size: 0.875rem; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; transition: opacity 0.15s; }

.sidebar.collapsed .nav-item span { opacity: 0; width: 0; }
.sidebar.collapsed .sidebar-logo { opacity: 0; width: 0; }

.nav-section-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-neutral-600);
  padding: var(--space-3) var(--space-4) var(--space-1);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

/* Sidebar footer (user info) */
.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid rgb(255 255 255 / 0.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow: hidden;
}
.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--color-neutral-500);
}
.sidebar.collapsed .sidebar-user-info { display: none; }

/* ---- Main content ---- */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.2s ease;
  display: flex;
  flex-direction: column;
}

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

.page-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--topbar-height);
}

.page-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--color-neutral-900);
  margin: 0;
}

.page-body {
  padding: var(--space-4) var(--space-6);
  flex: 1;
}

/* ---- Bottom Tab Bar (mobile only) ---- */
.tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-height);
  background: var(--color-white);
  border-top: 1px solid var(--border-color);
  z-index: var(--z-tabbar);
  box-shadow: 0 -2px 8px rgb(0 0 0 / 0.06);
}

.tab-bar-inner {
  display: flex;
  height: 100%;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--color-neutral-400);
  text-decoration: none;
  font-size: 10px;
  font-weight: var(--font-medium);
  transition: color 0.15s;
  padding: var(--space-1) 0;
}
.tab-item i { font-size: 1.1rem; }
.tab-item.active { color: var(--color-primary); }
.tab-item:hover { color: var(--color-neutral-700); text-decoration: none; }
.tab-item--logout { color: var(--color-neutral-400); }
.tab-item--logout:hover { color: var(--color-danger); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content,
  .main-content.sidebar-collapsed { margin-left: 0; padding-bottom: var(--tabbar-height); }
  .tab-bar { display: block; }
  .page-body { padding: var(--space-3) var(--space-3); }
  .page-header { padding: var(--space-3) var(--space-3); }
}

@media print {
  .sidebar, .tab-bar, .page-header { display: none !important; }
  .main-content { margin-left: 0 !important; }
}
