/* ==========================================================================
   NGOHUB Mobile App Touch-First Modern Stylesheet (Light/Dark Theme)
   ========================================================================== */

:root {
  --primary: #1b5e20;
  --primary-light: #2e7d32;
  --primary-dark: #0f3d13;
  --primary-accent: #4caf50;
  --primary-subtle: #e8f5e9;
  --secondary: #0284c7;
  --accent-gold: #f59e0b;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #2e7d32;
  
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-fab: 0 8px 20px rgba(27, 94, 32, 0.35);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --header-height: 64px;
  --nav-height: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 15px);
}

[data-theme="dark"] {
  --bg-main: #0b130e;
  --bg-card: #142319;
  --bg-subtle: #1b2f22;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #233e2c;
  --primary-subtle: rgba(46, 125, 50, 0.15);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 15px);
  user-select: none;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ----------------------------------------------------
   1. APP HEADER
---------------------------------------------------- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-wrapper img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand-title {
  display: flex;
  flex-direction: column;
}

.brand-title h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.brand-title span {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease;
}

.btn-icon:active {
  transform: scale(0.92);
}

/* ----------------------------------------------------
   2. MAIN CONTAINER & TABS
---------------------------------------------------- */
.app-container {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-content.active {
  display: block;
}

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

/* ----------------------------------------------------
   3. HERO CARDS & METRICS
---------------------------------------------------- */
.hero-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #ffffff;
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -40px;
  left: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  border-radius: 50%;
}

.hero-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero-card h2 {
  font-size: 1.35rem;
  font-weight: 900;
  margin-bottom: 6px;
  line-height: 1.25;
}

.hero-card p {
  font-size: 0.85rem;
  opacity: 0.92;
  margin-bottom: 14px;
}

.hero-actions {
  display: flex;
  gap: 10px;
}

.btn-hero-primary {
  flex: 1;
  background: #ffffff;
  color: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-hero-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Quick Metrics 4-Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.metric-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.metric-icon.water { background: #e0f2fe; color: #0284c7; }
.metric-icon.ngo { background: #e8f5e9; color: #2e7d32; }
.metric-icon.money { background: #fef3c7; color: #d97706; }
.metric-icon.vol { background: #fce7f3; color: #db2777; }

.metric-value {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 2px;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ----------------------------------------------------
   4. SECTION HEADERS & CARDS
---------------------------------------------------- */
.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title-wrap h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-wrap h3 i {
  color: var(--primary);
}

.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.service-card:active {
  transform: scale(0.985);
}

.service-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.service-badge-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.service-info h4 {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-primary);
}

.service-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.service-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.45;
}

.service-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
}

.service-price {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary);
}

.btn-service-action {
  background: var(--primary-subtle);
  color: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ----------------------------------------------------
   5. CALCULATOR STYLES
---------------------------------------------------- */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.calc-tabs-nav {
  display: flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
}

.calc-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.calc-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.input-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}

.slider-val-badge {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  min-width: 60px;
  text-align: center;
}

.calc-results-box {
  background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.calc-res-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.res-item {
  display: flex;
  flex-direction: column;
}

.res-item span {
  font-size: 0.72rem;
  opacity: 0.9;
}

.res-item strong {
  font-size: 1.15rem;
  font-weight: 900;
}

/* ----------------------------------------------------
   6. GRANTS DIRECTORY LIST
---------------------------------------------------- */
.grants-search-box {
  position: relative;
  margin-bottom: 12px;
}

.grants-search-box input {
  width: 100%;
  padding: 12px 42px 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

.grants-search-box i {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.grants-filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.grants-filter-pills::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.grant-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.grant-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.grant-card-top h4 {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
}

.grant-tag {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.grant-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.4;
}

.grant-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
}

.grant-funding {
  font-size: 0.8rem;
  font-weight: 800;
  color: #059669;
}

.btn-grant-apply {
  background: var(--primary-subtle);
  color: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 800;
  text-decoration: none;
}

/* ----------------------------------------------------
   7. FIXED BOTTOM NAVIGATION BAR
---------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  height: 100%;
  font-family: inherit;
  transition: color 0.2s ease;
}

.nav-item i {
  font-size: 1.15rem;
}

.nav-item span {
  font-size: 0.68rem;
  font-weight: 700;
}

.nav-item.active {
  color: var(--primary);
}

/* Center Elevated FAB (Calculators) */
.nav-item.center-fab {
  position: relative;
  top: -14px;
}

.fab-circle {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #ffffff;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-fab);
  border: 3px solid var(--bg-card);
  transition: transform 0.15s ease;
}

.fab-circle i {
  font-size: 1.35rem;
}

.nav-item.center-fab:active .fab-circle {
  transform: scale(0.92);
}

.nav-item.center-fab span {
  color: var(--primary);
  font-weight: 800;
  margin-top: 2px;
}

/* ----------------------------------------------------
   8. ACTION SHEET MODAL (MORE MENU)
---------------------------------------------------- */
.action-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.action-sheet-overlay.open {
  opacity: 1;
  visibility: visible;
}

.action-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  z-index: 210;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
  max-height: 85vh;
  overflow-y: auto;
}

.action-sheet-overlay.open .action-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  margin: -8px auto 14px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-card-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  text-align: right;
  transition: transform 0.15s ease, background 0.2s ease;
}

.sheet-card-btn:active {
  transform: scale(0.96);
  background: var(--primary-subtle);
}

.sheet-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.sheet-card-btn strong {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
}

.sheet-card-btn span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sheet-wa-btn {
  width: 100%;
  background: #25d366;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

/* ----------------------------------------------------
   9. POLICY & MODAL POPUP
---------------------------------------------------- */
.app-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.app-modal.open {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-lg);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.btn-close-modal {
  background: var(--bg-subtle);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}

.policy-badge-banner {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}

.policy-badge-banner h4 {
  color: #1b5e20;
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.policy-badge-banner p {
  color: #2e7d32;
  font-size: 0.78rem;
  line-height: 1.4;
}

.policy-article-item {
  border-right: 3px solid var(--primary);
  padding-right: 10px;
  margin-bottom: 14px;
}

.policy-article-item h5 {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.policy-article-item p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.btn-download-pdf {
  width: 100%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-weight: 800;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  margin-top: 14px;
}
