/* ============================================================
   Orphans Family Registry — Custom Styles
   ============================================================ */

/* ---------- CSS Variables / Theme ---------- */
:root {
  --primary: #0d6efd;
  --primary-dark: #0a58ca;
  --secondary: #6c757d;
  --success: #198754;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0dcaf0;
  --accent: #6f42c1;
  --bg-light: #f8f9fa;
  --bg-body: #ffffff;
  --text-main: #212529;
  --text-muted: #6c757d;
  --shadow-sm: 0 .125rem .25rem rgba(0,0,0,.075);
  --shadow: 0 .5rem 1rem rgba(0,0,0,.15);
  --radius: .5rem;
  --transition: all .3s ease;
}

/* ---------- Global ---------- */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-light);
  color: var(--text-main);
}

main {
  flex: 1;
}

/* ---------- RTL Support ---------- */
[dir="rtl"] body {
  font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

[dir="rtl"] .me-1, [dir="rtl"] .me-2, [dir="rtl"] .me-3 {
  margin-right: 0 !important;
}
[dir="rtl"] .me-1 { margin-left: .25rem !important; }
[dir="rtl"] .me-2 { margin-left: .5rem !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; }

[dir="rtl"] .ms-2, [dir="rtl"] .ms-3 {
  margin-left: 0 !important;
}
[dir="rtl"] .ms-2 { margin-right: .5rem !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; }

[dir="rtl"] .text-md-end { text-align: start !important; }
[dir="rtl"] .dropdown-menu-end { right: auto; left: 0; }

/* ---------- Navbar ---------- */
.navbar {
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.navbar-brand {
  font-size: 1.15rem;
  letter-spacing: .02em;
}

.navbar-nav .nav-link {
  padding: .5rem 1rem;
  font-weight: 500;
  transition: var(--transition);
}

.navbar-nav .nav-link:hover {
  background-color: rgba(255,255,255,.1);
  border-radius: .375rem;
}

.navbar-nav .nav-link.active {
  background-color: rgba(255,255,255,.15);
  border-radius: .375rem;
}

/* Mobile Navigation Improvements */
@media (max-width: 991.98px) {
  .navbar-collapse {
    background-color: var(--primary);
    padding: 1rem 0;
    margin-top: 1rem;
    border-radius: .5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
  }
  
  .navbar-nav {
    padding: 0 .5rem;
  }
  
  .navbar-nav .nav-link {
    padding: .75rem 1rem;
    margin: .25rem 0;
    border-radius: .375rem;
    font-size: 1.05rem;
  }
  
  .navbar-nav .nav-link:active {
    background-color: rgba(255,255,255,.2);
  }
  
  .navbar-nav .dropdown-menu {
    background-color: rgba(255,255,255,.95);
    border: none;
    box-shadow: none;
    margin: .5rem 1rem;
  }
  
  .navbar-nav .dropdown-item {
    padding: .75rem 1rem;
    font-size: 1rem;
  }
  
  .navbar-nav .dropdown-item:active {
    background-color: var(--primary);
    color: white;
  }
  
  .navbar-toggler {
    padding: .5rem;
    border: 2px solid rgba(255,255,255,.5);
  }
  
  .navbar-toggler:focus {
    box-shadow: 0 0 0 .25rem rgba(255,255,255,.25);
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  /* Guest button on mobile */
  .navbar-nav .guest-only .nav-link {
    margin-top: .5rem;
    text-align: center;
  }
}

/* ---------- Hero Section ---------- */
.hero-section {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: 5rem 0 4rem;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
  max-width: 600px;
}

@media (max-width: 768px) {
  .hero-title { font-size: 2rem; }
  .hero-subtitle { font-size: 1rem; }
  .hero-section { padding: 3rem 0 2.5rem; }
}

/* ---------- Stats Counter ---------- */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  border: 1px solid rgba(0,0,0,.05);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.stat-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  color: var(--primary);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1;
}

.stat-label {
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: .5rem;
}

/* ---------- Feature Cards ---------- */
.feature-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  height: 100%;
  border-top: 3px solid transparent;
}

.feature-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow);
  border-top-color: var(--primary);
}

.feature-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.feature-icon.bg-primary-subtle { background: rgba(13,110,253,.12); color: var(--primary); }
.feature-icon.bg-success-subtle { background: rgba(25,135,84,.12); color: var(--success); }
.feature-icon.bg-warning-subtle { background: rgba(255,193,7,.12); color: #997404; }
.feature-icon.bg-info-subtle    { background: rgba(13,202,240,.12); color: #087990; }
.feature-icon.bg-danger-subtle  { background: rgba(220,53,69,.12); color: var(--danger); }
.feature-icon.bg-accent-subtle  { background: rgba(111,66,193,.12); color: var(--accent); }

/* ---------- Auth Pages ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  padding: 2rem 1rem;
}

.auth-card {
  background: #fff;
  border-radius: .75rem;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
}

.auth-card .brand-icon {
  font-size: 3rem;
  color: var(--primary);
}

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

/* Pending Approval */
.pending-card {
  background: #fff;
  border-radius: .75rem;
  box-shadow: var(--shadow);
  padding: 3rem;
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.pending-icon {
  font-size: 4rem;
  color: var(--warning);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: .8; }
}

/* ---------- Family Cards ---------- */
.family-list-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  overflow: hidden;
  border-left: 4px solid var(--primary);
}

.family-list-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

[dir="rtl"] .family-list-card {
  border-left: none;
  border-right: 4px solid var(--primary);
}

.family-detail-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: 2rem;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ---------- Search / Filter Bar ---------- */
.search-bar {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

.filter-badge {
  cursor: pointer;
  transition: var(--transition);
}

.filter-badge:hover {
  opacity: .85;
}

/* ---------- Donation Cards ---------- */
.donation-status-badge {
  font-size: .75rem;
  padding: .35em .65em;
}

/* ---------- Data Table ---------- */
.table-container {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ---------- Page Transitions ---------- */
.page-enter {
  animation: fadeInUp .4s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Loading Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, #e9ecef 25%, #f8f9fa 50%, #e9ecef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: .25rem;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: .5rem;
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-card {
  height: 120px;
}

/* ---------- Animate on Scroll ---------- */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity .6s ease, transform .6s ease;
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3.5rem;
  opacity: .4;
  margin-bottom: 1rem;
}

/* ---------- Badges ---------- */
.role-badge {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ---------- User Avatar (Admin Users Page) ---------- */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* Tab badge animation for pending count */
#users-tabs .badge {
  transition: var(--transition);
}

#users-tabs .nav-link.active .badge {
  transform: scale(1.1);
}

/* ---------- Utility ---------- */
.cursor-pointer { cursor: pointer; }

.hover-shadow {
  transition: box-shadow .3s ease;
}
.hover-shadow:hover {
  box-shadow: var(--shadow);
}

/* ---------- Responsive fixes ---------- */
@media (max-width: 576px) {
  .stat-card { padding: 1.25rem 1rem; }
  .stat-number { font-size: 2rem; }
  .feature-card { padding: 1.5rem; }
  .auth-card { padding: 1.75rem; }
  .search-bar { padding: 1rem; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* ============================================================
   PWA — Install Banner, Update Banner, Offline Indicator
   ============================================================ */

/* ---------- Install Banner ---------- */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1080;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.1);
  box-shadow: 0 -4px 16px rgba(0,0,0,.12);
  padding: .75rem 1rem;
  animation: slideUpBanner .4s ease;
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: .75rem;
  max-width: 720px;
  margin: 0 auto;
}

.pwa-install-icon {
  flex-shrink: 0;
}

.pwa-install-icon img {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.pwa-install-text {
  flex: 1;
  min-width: 0;
}

.pwa-install-text strong {
  display: block;
  font-size: .95rem;
  line-height: 1.3;
}

.pwa-install-text small {
  display: block;
  color: var(--text-muted);
  font-size: .8rem;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
}

@keyframes slideUpBanner {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---------- Update Banner ---------- */
.pwa-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: .6rem 1rem;
  font-size: .9rem;
  animation: slideDownBanner .4s ease;
}

.pwa-update-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  max-width: 720px;
  margin: 0 auto;
  flex-wrap: wrap;
}

@keyframes slideDownBanner {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---------- Offline Indicator ---------- */
.offline-indicator {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1085;
  background: var(--danger);
  color: #fff;
  padding: .5rem 1.25rem;
  border-radius: 2rem;
  font-size: .85rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(220,53,69,.3);
  display: flex;
  align-items: center;
  gap: .25rem;
  animation: fadeInUp .4s ease;
}

.offline-indicator i {
  font-size: 1rem;
}

/* ---------- PWA Profile Card ---------- */
.pwa-cache-card .cache-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid rgba(0,0,0,.05);
}

.pwa-cache-card .cache-stat:last-child {
  border-bottom: none;
}

.pwa-cache-card .cache-stat-label {
  color: var(--text-muted);
  font-size: .85rem;
}

.pwa-cache-card .cache-stat-value {
  font-weight: 600;
  font-size: .9rem;
}

/* ---------- iOS Install Prompt (in-app instructions) ---------- */
.ios-install-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1080;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.1);
  box-shadow: 0 -4px 16px rgba(0,0,0,.12);
  padding: 1.25rem;
  animation: slideUpBanner .4s ease;
  text-align: center;
}

.ios-install-prompt .ios-share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: .85rem;
  vertical-align: middle;
  margin: 0 .15rem;
}

.ios-install-prompt p {
  margin: .5rem 0;
  font-size: .9rem;
  color: var(--text-main);
  line-height: 1.6;
}

/* Push install banner above footer on mobile */
@media (max-width: 576px) {
  .pwa-install-banner {
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
  }
  
  .pwa-install-content {
    gap: .5rem;
  }
  
  .pwa-install-text strong {
    font-size: .85rem;
  }
  
  .pwa-install-text small {
    font-size: .75rem;
  }
}

/* ---------- Home Page Install Button ---------- */
.btn-install-hero {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .6rem 1.5rem;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 2rem;
  font-size: .95rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all .25s ease;
  cursor: pointer;
}

.btn-install-hero:hover,
.btn-install-hero:focus {
  background: rgba(255,255,255,.95);
  color: var(--primary);
  border-color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}

.btn-install-hero:active {
  transform: translateY(0);
}

.btn-install-hero i {
  font-size: 1.1rem;
}

/* ---------- iOS Install Modal ---------- */
.ios-install-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn .2s ease;
}

.ios-install-modal {
  background: #fff;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  animation: slideUpBanner .3s ease;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
}

.ios-install-steps {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.ios-step {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .95rem;
  color: var(--text-main);
}

.ios-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ios-share-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: .8rem;
  vertical-align: middle;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
