/* ===== التنقل - الهيدر والشريط السفلي والشريط الجانبي ===== */

/* ─── الهيدر ───────────────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  /* دعم Dynamic Island / Notch على iPhone */
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-height) + env(safe-area-inset-top));
  background: var(--bg-header);
  color: var(--text-header);
  display: flex;
  align-items: center;
  padding-right: var(--space-md);
  padding-left: var(--space-md);
  padding-bottom: 0;
  z-index: 500;
  box-shadow: var(--shadow-md);
  gap: var(--space-sm);
}
@media (min-width: 769px) {
  #app-header {
    position: static;
    right: auto;
    left: auto;
  }
}
.header-back {
  background: transparent;
  border: none;
  color: var(--text-header);
  padding: 6px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background var(--transition);
}
.header-back:hover { background: rgba(255,255,255,0.15); }
.header-title {
  flex: 1;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-header);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.header-btn {
  background: transparent;
  border: none;
  color: var(--text-header);
  padding: 6px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  position: relative;
  transition: background var(--transition);
}
.header-btn:hover { background: rgba(255,255,255,0.15); }

/* تكبير أزرار الهيدر على الجوال */
@media (max-width: 480px) {
  .header-btn {
    width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: 50%;
    justify-content: center;
  }
  .header-btn svg {
    width: 24px;
    height: 24px;
  }
  .header-back {
    padding: 10px;
  }
  .header-back svg {
    width: 24px;
    height: 24px;
  }
}
.header-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  background: var(--color-danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* نبض الجرس عند وجود إشعارات غير مقروءة */
@keyframes bell-pulse {
 0%, 100% { transform: scale(1); }
 50% { transform: scale(1.15); }
}

.header-btn.has-unread svg {
 animation: bell-pulse 1.2s ease-in-out infinite;
 transform-origin: top center;
}

/* ─── زر التبديل بين الوضع الداكن والفاتح ──────────────────── */
.theme-toggle {
  opacity: 0.8;
  transition: opacity var(--transition), transform var(--transition);
}
.theme-toggle:hover {
  opacity: 1;
  transform: scale(1.1);
}
.theme-toggle-icon {
  transition: transform 0.3s ease;
}
.theme-toggle:hover .theme-toggle-icon {
  transform: rotate(15deg);
}

/* ─── الشريط السفلي ────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  /* ارتفاع الشريط + مساحة الأمان السفلية على iPhone */
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-nav);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 500;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition);
  border: none;
  background: transparent;
  font-family: var(--font-family);
  text-decoration: none;
  min-height: var(--nav-height);
}
.nav-item.active { color: var(--color-primary); }
.nav-item:hover { color: var(--color-primary); }
.nav-icon {
  width: 32px;
  height: 32px;
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg {
  width: 28px;
  height: 28px;
}
.nav-label { font-size: 12px; font-weight: 600; }

/* زر الإضافة المركزي */
.nav-add {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), background var(--transition);
  flex-shrink: 0;
}
.nav-add:hover { transform: scale(1.08); background: var(--color-primary-dark); }

/* ─── الشريط الجانبي ───────────────────────────────────────── */
.sidebar {
  display: none;
  flex-direction: column;
  background: var(--bg-sidebar);
  width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: var(--space-md) 0;
}
.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}
.sidebar-logo img {
  max-height: 60px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.sidebar-logo-text {
  font-size: var(--font-size-md);
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
}
.sidebar-section-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--space-sm) var(--space-lg);
  margin-top: var(--space-sm);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-lg);
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: all var(--transition);
  border-right: 3px solid transparent;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--font-family);
  width: 100%;
  text-align: right;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.sidebar-link.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-right-color: var(--color-accent);
}
.sidebar-link svg { flex-shrink: 0; }

/* زر تنزيل التطبيق في الشريط الجانبي */
.sidebar-link-install {
  background: rgba(255,255,255,0.1);
  color: var(--color-accent);
  border-right-color: var(--color-accent);
  font-weight: 700;
}
.sidebar-link-install:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.sidebar-footer {
  margin-top: auto;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: rgba(255,255,255,0.85);
  font-size: var(--font-size-sm);
}
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-sm);
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role { font-size: var(--font-size-xs); opacity: 0.7; }
