/* PLU App - Custom CSS */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary: #FFD700;
  --primary-light: #FFE066;
  --primary-dark: #B8860B;
  --secondary: #000000;
  --secondary-light: #333333;
  --secondary-dark: #000000;
  --accent: #D32F2F;
  --warning: #FB8C00;
  --danger: #D32F2F;
  --success: #FFD700;
  --bg: #F5F5F5;
  --card: #FFFFFF;
  --text-primary: #212121;
  --text-secondary: #757575;
}

html { scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text-primary); -webkit-font-smoothing: antialiased; }

/* ── Page Transitions ────────────────────────────────── */
/* Applied to <main> — opacity only, NO transform (transform on main would break position:fixed modals) */
main.page-exit { animation: mainOut 0.2s ease forwards; pointer-events: none; }
main.page-enter { animation: mainIn 0.28s ease; } /* no 'forwards' — transform reverts after, keeping viewport context */
@keyframes mainIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes mainOut { from { opacity: 1; } to { opacity: 0; } }

/* Reusable UI animations (safe — applied to non-fixed children) */
@keyframes fadeIn  { from { opacity: 0; transform: translateY(6px); }  to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-fadeIn  { animation: fadeIn  0.3s ease forwards; }
.animate-slideUp { animation: slideUp 0.35s ease forwards; }
.animate-pulse-slow { animation: pulse 2.5s cubic-bezier(0.4,0,0.6,1) infinite; }

/* ── Skeleton Loading ────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
.dark .skeleton { background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%); background-size: 200% 100%; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── Glassmorphism ───────────────────────────────────── */
.glass { background: rgba(255,255,255,0.15); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.25); }
.glass-dark { background: rgba(0,0,0,0.25); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); }
.dark .glass { background: rgba(30,30,40,0.4); border-color: rgba(255,255,255,0.08); }

/* ── Cards ───────────────────────────────────────────── */
.card { background: var(--card); border-radius: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.07); transition: box-shadow 0.2s, transform 0.2s; }
.card:hover { box-shadow: 0 8px 32px rgba(0,0,0,0.12); transform: translateY(-2px); }
.dark .card { background: #1e2130; box-shadow: 0 2px 12px rgba(0,0,0,0.3); }
.dark .card:hover { box-shadow: 0 8px 32px rgba(0,0,0,0.4); }

/* ── Gradient Backgrounds ────────────────────────────── */
.gradient-primary { background: linear-gradient(135deg, #FFD700 0%, #B8860B 100%); }
.gradient-secondary { background: linear-gradient(135deg, #333333 0%, #000000 100%); }
.gradient-warm { background: linear-gradient(135deg, #FFD700 0%, #000000 100%); }
.gradient-hero { background: linear-gradient(160deg, #FFD700 0%, #B8860B 40%, #000000 100%); }
.gradient-finance { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.gradient-rescue { background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%); }
.gradient-green { background: linear-gradient(135deg, #FFD700 0%, #B8860B 100%); }
.gradient-gold { background: linear-gradient(135deg, #b5451b 0%, #e27d37 100%); }

/* ── Tab System ──────────────────────────────────────── */
.tab-bar { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; border-bottom: 2px solid #e5e7eb; }
.dark .tab-bar { border-color: #374151; }
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn { padding: 10px 20px; font-size: 14px; font-weight: 500; color: #757575; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; cursor: pointer; transition: all 0.2s; background: none; border-top: none; border-left: none; border-right: none; }
.tab-btn.tab-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.tab-active) { color: #424242; background: rgba(0,0,0,0.04); }
.dark .tab-btn { color: #9ca3af; }
.dark .tab-btn.tab-active { color: #FFD700; border-bottom-color: #FFD700; }

/* ── Mobile Bottom Nav ───────────────────────────────── */
.mobile-nav { position: fixed !important; bottom: 0; left: 0; right: 0; z-index: 200; background: white; border-top: 1px solid #e5e7eb; display: flex; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.dark .mobile-nav { background: #111827; border-color: #1f2937; }
.mobile-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 4px 6px; gap: 3px; cursor: pointer; color: #9ca3af; transition: color 0.2s; font-size: 10px; font-weight: 500; text-decoration: none; position: relative; }
.mobile-nav-item.active { color: var(--primary); }
.mobile-nav-item.active svg { transform: scale(1.1); }
.mobile-nav-item svg { transition: transform 0.2s; }
.dark .mobile-nav-item { color: #6b7280; }
.dark .mobile-nav-item.active { color: #FFD700; }

/* ── App Bar ─────────────────────────────────────────── */
.app-bar { position: sticky; top: 0; z-index: 50; background: white; border-bottom: 1px solid #f0f0f0; box-shadow: 0 1px 8px rgba(0,0,0,0.06); }
.dark .app-bar { background: #111827; border-color: #1f2937; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar { position: fixed !important; top: 0; left: 0; height: 100dvh; height: 100vh; width: 260px; background: white; box-shadow: 2px 0 20px rgba(0,0,0,0.08); z-index: 100; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; display: flex !important; flex-direction: column; }
.dark .sidebar { background: #111827; }
.sidebar > nav { overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
.sidebar-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: 12px; color: #424242; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; text-decoration: none; margin: 2px 8px; }
.sidebar-item:hover { background: rgba(255,215,0,0.08); color: var(--primary); }
.sidebar-item.active { background: linear-gradient(135deg, rgba(255,215,0,0.12), rgba(0,0,0,0.08)); color: var(--primary); font-weight: 600; }
.dark .sidebar-item { color: #d1d5db; }
.dark .sidebar-item:hover, .dark .sidebar-item.active { background: rgba(255,215,0,0.15); color: #FFD700; }

/* ── Progress Bars ───────────────────────────────────── */
.progress-bar { height: 6px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.dark .progress-bar { background: #374151; }
.progress-fill { height: 100%; border-radius: 999px; transition: width 1s ease; }

/* ── Circular Progress ───────────────────────────────── */
.progress-ring-circle { transition: stroke-dashoffset 1s ease; transform: rotate(-90deg); transform-origin: 50% 50%; }

/* ── Badges ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-primary { background: rgba(255,215,0,0.1); color: var(--primary); }
.badge-secondary { background: rgba(255,215,0,0.1); color: var(--secondary-dark); }
.badge-success { background: rgba(67,160,71,0.1); color: #2d7d32; }
.badge-warning { background: rgba(251,140,0,0.12); color: #e65100; }
.badge-danger { background: rgba(229,57,53,0.1); color: #c62828; }
.dark .badge-success { background: rgba(67,160,71,0.2); color: #66bb6a; }
.dark .badge-warning { background: rgba(251,140,0,0.2); color: #ffa726; }
.dark .badge-danger { background: rgba(229,57,53,0.2); color: #ef5350; }

/* ── Status Indicators ───────────────────────────────── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.green { background: #43A047; box-shadow: 0 0 0 3px rgba(67,160,71,0.2); }
.status-dot.amber { background: #FB8C00; box-shadow: 0 0 0 3px rgba(251,140,0,0.2); }
.status-dot.red { background: #E53935; box-shadow: 0 0 0 3px rgba(229,57,53,0.2); }

/* ── Priority Alerts ─────────────────────────────────── */
.priority-critical { border-left: 4px solid #E53935; }
.priority-high { border-left: 4px solid #FB8C00; }
.priority-medium { border-left: 4px solid #FDD835; }
.priority-low { border-left: 4px solid #43A047; }

/* ── Wallet Card ─────────────────────────────────────── */
.wallet-card { border-radius: 20px; min-height: 180px; position: relative; overflow: hidden; }
.wallet-card::before { content: ''; position: absolute; top: -40px; right: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,0.07); }
.wallet-card::after { content: ''; position: absolute; bottom: -60px; left: -20px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,0.05); }

/* ── Pull to Refresh ─────────────────────────────────── */
#pullToRefresh { display: flex; align-items: center; justify-content: center; height: 48px; transition: transform 0.3s ease; }
#pullToRefresh.ptr-refreshing svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Uganda Map Placeholder ──────────────────────────── */
.map-container { position: relative; background: #faf8f0; border-radius: 16px; overflow: hidden; }
.dark .map-container { background: #1a1910; }
.map-region { fill: #B8860B; stroke: white; stroke-width: 1; cursor: pointer; transition: fill 0.2s, opacity 0.2s; }
.map-region:hover { opacity: 0.8; }
.map-region.high { fill: #000000; }
.map-region.medium { fill: #B8860B; }
.map-region.low { fill: #FFD700; }
.map-region.minimal { fill: #FFF2B2; }
.dark .map-region.high { fill: #FFD700; }
.dark .map-region.medium { fill: #B8860B; }
.dark .map-region.low { fill: #1a1910; }
.dark .map-region.minimal { fill: #11100a; }

/* ── Map Tooltip ─────────────────────────────────────── */
.map-tooltip { position: absolute; background: white; border-radius: 12px; padding: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.15); pointer-events: none; transition: opacity 0.2s; z-index: 10; min-width: 160px; }
.dark .map-tooltip { background: #1e2130; color: white; }

/* ── Input Fields ────────────────────────────────────── */
.input-field { width: 100%; padding: 12px 16px; border: 2px solid #e5e7eb; border-radius: 12px; font-size: 14px; font-family: 'Inter', sans-serif; background: white; color: #212121; transition: border-color 0.2s; outline: none; }
.input-field:focus { border-color: var(--primary); }
.dark .input-field { background: #1e2130; border-color: #374151; color: #f3f4f6; }
.dark .input-field:focus { border-color: #FFD700; }
.input-label { display: block; font-size: 13px; font-weight: 600; color: #424242; margin-bottom: 6px; }
.dark .input-label { color: #d1d5db; }

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: none; outline: none; text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, #FFD700, #B8860B); color: #000000; box-shadow: 0 4px 14px rgba(255,215,0,0.35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(255,215,0,0.45); transform: translateY(-1px); }
.btn-secondary { background: linear-gradient(135deg, #000000, #333333); color: white; box-shadow: 0 4px 14px rgba(0,0,0,0.3); }
.btn-secondary:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.4); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: rgba(255,215,0,0.06); }
.btn-ghost { background: rgba(0,0,0,0.04); color: #424242; }
.dark .btn-ghost { background: rgba(255,255,255,0.06); color: #d1d5db; }
.btn-danger { background: linear-gradient(135deg, #E53935, #c62828); color: white; }
.btn-success { background: linear-gradient(135deg, #43A047, #2d7d32); color: white; }
.btn-warning { background: linear-gradient(135deg, #FB8C00, #e65100); color: white; }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 10px; }
.btn-xs { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: 14px; }
.btn-full { width: 100%; }

/* ── Quick Action Buttons ────────────────────────────── */
.quick-action { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 16px; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.quick-action:hover { transform: translateY(-3px); }
.quick-action:active { transform: scale(0.95); }
.quick-action-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.quick-action-label { font-size: 11px; font-weight: 600; text-align: center; color: #424242; line-height: 1.3; }
.dark .quick-action-label { color: #d1d5db; }

/* ── Stats Card ──────────────────────────────────────── */
.stats-card { border-radius: 16px; padding: 16px; transition: all 0.2s; }
.stats-card:hover { transform: translateY(-3px); }

/* ── Activity Feed ───────────────────────────────────── */
.feed-item { position: relative; padding-left: 40px; }
.feed-item::before { content: ''; position: absolute; left: 13px; top: 28px; bottom: -8px; width: 2px; background: #e5e7eb; }
.dark .feed-item::before { background: #374151; }
.feed-item:last-child::before { display: none; }
.feed-dot { position: absolute; left: 4px; top: 12px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; border: 2px solid white; }
.dark .feed-dot { border-color: #111827; }

/* ── Section Header ──────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 16px; font-weight: 700; color: #212121; }
.dark .section-title { color: #f3f4f6; }
.section-link { font-size: 13px; font-weight: 600; color: var(--secondary); }

/* ── Divider ─────────────────────────────────────────── */
.divider { height: 1px; background: #e5e7eb; margin: 16px 0; }
.dark .divider { background: #1f2937; }

/* ── Empty State ─────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; text-align: center; gap: 12px; }
.empty-state-icon { font-size: 48px; margin-bottom: 4px; }
.empty-state-title { font-size: 16px; font-weight: 700; color: #424242; }
.empty-state-desc { font-size: 13px; color: #9ca3af; max-width: 240px; }
.dark .empty-state-title { color: #d1d5db; }

/* ── Responsive Utilities ────────────────────────────── */
.mobile-only { display: block; }
.desktop-only { display: none; }

@media (min-width: 768px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
  .desktop-flex { display: flex !important; }
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; }
.dark ::-webkit-scrollbar-thumb { background: #374151; }

/* ── Selection ───────────────────────────────────────── */
::selection { background: rgba(255,215,0,0.2); }

/* ── Notification Badge ──────────────────────────────── */
.notif-badge { position: absolute; top: -4px; right: -4px; background: #E53935; color: white; border-radius: 50%; width: 18px; height: 18px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid white; }
.dark .notif-badge { border-color: #111827; }

/* ── Fuel Card ───────────────────────────────────────── */
.fuel-card { border-radius: 20px; min-height: 200px; background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460); position: relative; overflow: hidden; }
.fuel-card .card-chip { width: 40px; height: 30px; background: linear-gradient(135deg, #b8a96e, #d4c78a); border-radius: 6px; }

/* ── Dark mode overrides ─────────────────────────────── */
.dark body { background: #0f1117; color: #f3f4f6; }
.dark .app-bar { background: #111827; border-color: #1f2937; }
.dark .mobile-nav { background: #111827; border-color: #1f2937; }
.dark .input-field { background: #1e2130; border-color: #374151; color: #f3f4f6; }
.dark select { background: #1e2130; color: #f3f4f6; border-color: #374151; }
.dark .tab-bar { border-color: #374151; }

/* ── Scrollbar Hide ───────────────────────────────────── */
.scrollbar-hide { scrollbar-width: none; -ms-overflow-style: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* ── Scrollbar Thin (sidebar nav) ────────────────────── */
.scrollbar-thin { scrollbar-width: thin; scrollbar-color: rgba(255,215,0,0.2) transparent; }
.scrollbar-thin::-webkit-scrollbar { width: 4px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: rgba(255,215,0,0.25); border-radius: 4px; }
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background: rgba(255,215,0,0.45); }
.dark .scrollbar-thin { scrollbar-color: rgba(255,255,255,0.12) transparent; }
.dark .scrollbar-thin::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }
.dark .scrollbar-thin::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ── Safe Area / Bottom Padding ─────────────────────── */
.pb-safe { padding-bottom: max(6rem, calc(5rem + env(safe-area-inset-bottom))); }

/* ── Focus Ring ──────────────────────────────────────── */
.input-field:focus-visible { box-shadow: 0 0 0 3px rgba(255,215,0,0.2); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* ── Hover Card Lift ─────────────────────────────────── */
.card-lift { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card-lift:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.14); }

/* ── Number Ticker ───────────────────────────────────── */
@keyframes countUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.count-up { animation: countUp 0.6s ease forwards; }

/* ── Gradient Text ───────────────────────────────────── */
.text-gradient-primary { background: linear-gradient(135deg, #FFD700, #000000); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ── Image Avatar ────────────────────────────────────── */
.avatar { border-radius: 50%; object-fit: cover; }
.avatar-rounded { border-radius: 14px; object-fit: cover; }

/* ── Fuel Level Bar Colors ───────────────────────────── */
.fuel-low  { background: #E53935; }
.fuel-mid  { background: #FB8C00; }
.fuel-high { background: #43A047; }

/* ── Rescue Pulse ────────────────────────────────────── */
@keyframes rescuePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,57,53,0.5); } 50% { box-shadow: 0 0 0 12px rgba(229,57,53,0); } }
.rescue-pulse { animation: rescuePulse 1.8s infinite; }

/* ── Floating Portrait ───────────────────────────────── */
@keyframes portraitFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.animate-float {
  animation: portraitFloat 5s ease-in-out infinite;
}

/* ── Map Popup ───────────────────────────────────────── */
.map-tooltip { max-width: 200px; font-size: 13px; }

/* ── Section dividers ────────────────────────────────── */
.section-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.section-divider::before, .section-divider::after { content:''; flex:1; height:1px; background:#e5e7eb; }
.dark .section-divider::before, .dark .section-divider::after { background:#374151; }
.section-divider span { font-size: 12px; font-weight: 600; color: #9ca3af; white-space: nowrap; }

/* ── Toast z-index fix ───────────────────────────────── */
.toast-container { z-index: 9999; }

/* ── Wallet card content z-index ─────────────────────── */
.wallet-card > * { position: relative; z-index: 1; }
.fuel-card > * { position: relative; z-index: 1; }

/* ── SVG Map hover ───────────────────────────────────── */
#mapSvg polygon, #mapSvg rect, #mapSvg circle { transition: opacity 0.2s, filter 0.2s; }
#mapSvg polygon:hover, #mapSvg rect:hover, #mapSvg circle:hover { opacity: 0.75; filter: brightness(1.15); cursor: pointer; }

/* ── Print / Export ──────────────────────────────────── */
@media print {
  .mobile-nav, .sidebar, .app-bar, #pullToRefresh { display: none !important; }
  main { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #e5e7eb; }
}

/* ── Tablet breakpoint tweaks ────────────────────────── */
@media (min-width: 640px) and (max-width: 1023px) {
  .main-content-tablet { max-width: 680px; margin: 0 auto; }
}

/* ── Overflow clip for cards ─────────────────────────── */
.card { overflow: hidden; }
.card.no-clip { overflow: visible; }
