/* ═══════════════════════════════════════════════════════
   APP COMPONENTS — Professional PWA Layer
   ═══════════════════════════════════════════════════════ */

/* ── 1. Page Entry Animation ── */
@keyframes pgFadeIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main-content {
  animation: pgFadeIn 0.22s ease-out both;
}

/* ── 2. Page Navigation Bar (pnb) ── */
.pnb {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.85);
  position: sticky;
  top: 70px;          /* navbar height */
  z-index: 89;
  gap: 0.5rem;
}

/* Back button */
.pnb-back {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.28rem 0.65rem 0.28rem 0.5rem;
  border-radius: 999px;
  color: #667eea;
  text-decoration: none;
  font-size: 0.81rem;
  font-weight: 600;
  transition: background 0.14s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.pnb-back:hover,
.pnb-back:active { background: rgba(102, 126, 234, 0.1); }
.pnb-back i { font-size: 0.7rem; }

/* Spacer */
.pnb-spacer { flex: 1; }

/* Refresh button */
.pnb-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: #9CA3AF;
  cursor: pointer;
  border-radius: 50%;
  font-size: 0.78rem;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.14s, background 0.14s;
}
.pnb-refresh:hover,
.pnb-refresh:active { background: #F3F4F6; color: #667eea; }

.pnb-refresh i {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.pnb-refresh.spinning i { transform: rotate(360deg); }

/* ── 3. Toast Notifications ── */
.toast-wrap {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom) + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  width: min(440px, 93vw);
  pointer-events: none;
}

.toast {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.9rem;
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.05);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  width: 100%;
  animation: toastIn 0.28s cubic-bezier(0.34, 1.5, 0.64, 1) both;
}
.toast.removing {
  animation: toastOut 0.2s ease-in both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0)   scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.97); }
}

.toast-success { background: rgba(209,250,229,0.97); color: #065F46; border: 1px solid #A7F3D0; }
.toast-danger  { background: rgba(254,226,226,0.97); color: #991B1B; border: 1px solid #FECACA; }
.toast-warning { background: rgba(255,251,235,0.97); color: #92400E; border: 1px solid #FDE68A; }
.toast-info    { background: rgba(219,234,254,0.97); color: #1E40AF; border: 1px solid #BFDBFE; }
.toast-message { background: rgba(249,250,251,0.97); color: #1F2937; border: 1px solid #E5E7EB; }

.toast-icon { font-size: 0.95rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }
.toast-x {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.4;
  padding: 0.1rem 0.2rem;
  color: inherit;
  font-size: 0.75rem;
  border-radius: 3px;
  transition: opacity 0.12s;
  line-height: 1;
}
.toast-x:hover { opacity: 1; }

/* ── Mobile: hide desktop navbar, pnb sticks to very top ── */
@media (max-width: 767px) {
  .navbar { display: none !important; }
  .pnb    { top: 0; }
}

/* ── Desktop: hide pnb (full navbar handles navigation) ── */
@media (min-width: 768px) {
  .pnb        { display: none !important; }
  .toast-wrap { bottom: 1.5rem; }
}

/* ── 4. Skeleton Loader ── */
.skel {
  display: inline-block;
  background: linear-gradient(90deg, #F3F4F6 25%, #E9EAEC 50%, #F3F4F6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.4rem;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 5. Global UX Refinements ── */
html { scroll-behavior: smooth; }

::selection {
  background: rgba(102, 126, 234, 0.18);
  color: #1F2937;
}

:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Smoother link/button tap on mobile */
a, button {
  -webkit-tap-highlight-color: rgba(102, 126, 234, 0.08);
}

/* ── Username elements: always LTR so @ stays on the left ── */
.username-twitter,
.username-student,
.mmd-username,
.tweet-username-small {
  direction: ltr;
  unicode-bidi: isolate;
}

/* ── Hide scrollbar on mobile ── */
@media (max-width: 767px) {
  ::-webkit-scrollbar          { display: none; }
  *                             { scrollbar-width: none; -ms-overflow-style: none; }
}

/* ════════════════════════════════════════
   🏅 Team Badge Icon — أيقونة التيم الدائرية
   تظهر بجانب شارة التوثيق تماماً مثل تويتر
   ════════════════════════════════════════ */

/* ── رابط الشارة ── */
.team-badge-link {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-inline-start: 3px;
    text-decoration: none;
    line-height: 1;
}

/* ── الصورة الدائرية ── */
.team-badge-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(245, 158, 11, 0.55);
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    display: block;
}
.team-badge-link:hover .team-badge-icon {
    transform: scale(1.18);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    border-color: rgba(245, 158, 11, 0.85);
}

/* ── نسخة المالك — حد بنفسجي ── */
.team-badge-owner-link .team-badge-icon {
    border-color: rgba(99, 102, 241, 0.55);
}
.team-badge-owner-link:hover .team-badge-icon {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
    border-color: rgba(99, 102, 241, 0.85);
}

/* ════════════════════════════════════════
   🪪 Team Affiliation Card — بطاقة انتماء التيم
   تظهر أسفل بيانات المستخدم في البروفايل
   ════════════════════════════════════════ */
.team-affil-card {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(245, 158, 11, 0.06);
    border: 1.5px solid rgba(245, 158, 11, 0.28);
    border-radius: 0.65rem;
    padding: 0.45rem 0.85rem 0.45rem 0.55rem;
    margin: 0.6rem 0 0.2rem;
    transition: background 0.18s, border-color 0.18s;
    max-width: fit-content;
}
.team-affil-card:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.50);
}

/* نسخة المالك */
.team-affil-card.team-affil-owner {
    background: rgba(99, 102, 241, 0.06);
    border-color: rgba(99, 102, 241, 0.28);
}
.team-affil-card.team-affil-owner:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.50);
}

/* شعار التيم داخل البطاقة */
.team-affil-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(245, 158, 11, 0.40);
    flex-shrink: 0;
}
.team-affil-owner .team-affil-logo {
    border-color: rgba(99, 102, 241, 0.45);
}

/* نصوص البطاقة */
.team-affil-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.25;
}
.team-affil-role {
    font-size: 0.68rem;
    font-weight: 600;
    color: #92400E;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.team-affil-owner .team-affil-role {
    color: #4338CA;
}
.team-affil-name {
    font-size: 0.88rem;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: 0.01em;
}

/* أيقونة اليمين */
.team-affil-icon {
    font-size: 0.72rem;
    color: #B45309;
    margin-inline-start: auto;
    padding-inline-start: 0.4rem;
    opacity: 0.7;
}
.team-affil-owner .team-affil-icon {
    color: #4338CA;
}

/* ════════════════════════════════════════
   🏫 Section Badge — شارة الشعبة
   ════════════════════════════════════════ */
.section-badge {
    font-size: 0.72rem;
    font-weight: 700;
    background: #EEF2FF;
    color: #4F46E5;
    border-radius: 6px;
    padding: 2px 7px;
    margin-inline-start: 4px;
    border: 1px solid #C7D2FE;
    vertical-align: middle;
    display: inline-block;
    letter-spacing: 0.02em;
}

/* ════════════════════════════════════════
   🤝 Team Action Buttons — أزرار التيم
   ════════════════════════════════════════ */
.join-team-btn {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    border: none;
    border-radius: 99px;
    padding: 6px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: transform 0.18s, box-shadow 0.18s;
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
    text-decoration: none;
}
.join-team-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245,158,11,0.4);
}

.leave-team-btn {
    background: #F3F4F6;
    color: #6B7280;
    border: 1px solid #E5E7EB;
    border-radius: 99px;
    padding: 6px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.18s, color 0.18s;
}
.leave-team-btn:hover {
    background: #FEE2E2;
    color: #EF4444;
    border-color: #FECACA;
}

.team-pending-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #FEF9C3;
    color: #92400E;
    border: 1px solid #FDE68A;
    border-radius: 99px;
    padding: 4px 14px;
    font-size: 0.8rem;
    font-weight: 600;
}
