/* ===== invite-k PWA Mobile Styles ===== */
/* يُضاف لجميع الصفحات لتحسين تجربة الجوال دون التأثير على المتصفح */

/* ===== متغيرات الجوال ===== */
:root {
  --bottom-nav-height: 64px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
}

/* ===== شريط التنقل السفلي (يظهر فقط على الجوال في وضع standalone) ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: var(--surface, #fff);
  border-top: 1px solid var(--border, #e2e8f0);
  z-index: 500;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}

.bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--bottom-nav-height);
  padding: 0 4px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--muted, #64748b);
  font-size: 10px;
  font-weight: 600;
  min-width: 52px;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform .2s;
}

.bottom-nav-item.active {
  color: var(--primary, #2A9D8F);
}

.bottom-nav-item.active .nav-icon {
  transform: scale(1.15);
}

.bottom-nav-item:active {
  background: var(--bg, #f8fafc);
  transform: scale(0.95);
}

/* زر المسح المركزي (بارز) */
.bottom-nav-item.center-btn {
  background: linear-gradient(135deg, var(--primary, #2A9D8F), var(--secondary, #264653));
  color: #fff !important;
  border-radius: 18px;
  padding: 8px 14px;
  margin-top: -12px;
  box-shadow: 0 4px 16px rgba(42,157,143,.4);
}

.bottom-nav-item.center-btn .nav-icon {
  font-size: 24px;
}

/* ===== إخفاء الـ sidebar على الجوال في وضع standalone ===== */
@media (display-mode: standalone) {
  .bottom-nav {
    display: block;
  }

  .sidebar {
    display: none !important;
  }

  .content {
    margin-right: 0 !important;
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px) !important;
  }

  .app-shell {
    display: block !important;
  }

  /* topbar محسّن للجوال */
  .topbar {
    padding-top: calc(12px + var(--safe-area-top)) !important;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg, #f8fafc);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

/* ===== تحسينات عامة للجوال (بغض النظر عن وضع العرض) ===== */
@media (max-width: 768px) {
  /* تحسين حجم النصوص */
  body {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
  }

  /* منع التكبير عند النقر على الحقول */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* تحسين الأزرار للمس */
  .btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  /* بطاقات أكثر تكيفاً */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* جدول قابل للتمرير */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* تحسين المودال على الجوال */
  .modal-box {
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }

  .modal-overlay {
    align-items: flex-end !important;
  }
}

/* ===== شاشة التثبيت (Install Prompt) ===== */
#pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1e3255, #264653);
  color: #fff;
  padding: 16px 20px;
  padding-bottom: calc(16px + var(--safe-area-bottom));
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 14px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.2);
  animation: slideUp .3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

#pwa-install-banner .banner-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

#pwa-install-banner .banner-text {
  flex: 1;
}

#pwa-install-banner .banner-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
}

#pwa-install-banner .banner-desc {
  font-size: 12px;
  opacity: .8;
}

#pwa-install-banner .banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#pwa-install-banner .btn-install {
  background: #2A9D8F;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

#pwa-install-banner .btn-dismiss {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

/* ===== تأثير splash screen ===== */
@media (display-mode: standalone) {
  body::before {
    content: '';
    display: none;
  }
}

/* ===== تحسين الـ scroll ===== */
* {
  -webkit-overflow-scrolling: touch;
}

/* ===== منع تحديد النص عند اللمس ===== */
.bottom-nav, .btn, .action-btn {
  -webkit-user-select: none;
  user-select: none;
}

/* ===== تحسين الأداء ===== */
.sidebar, .content, .topbar {
  will-change: transform;
}

/* ===== إخفاء Sidebar في الجوال (متصفح عادي) ===== */
@media (max-width: 768px) {
  .sidebar {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
  }
  .app-shell {
    display: block !important;
  }
  .content {
    padding-bottom: 80px !important;
    margin-right: 0 !important;
  }
  .bottom-nav {
    display: flex !important;
  }
}
