@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap');

:root {
  --gov-primary: #1E3A8A;       /* Deep Royal Blue */
  --gov-primary-hover: #172554;
  --gov-accent: #F97316;        /* Saffron / Indian Orange */
  --gov-accent-hover: #EA580C;
  --gov-success: #10B981;       /* Emerald Green for Solved */
  --gov-danger: #EF4444;        /* Crimson Red for Urgent */
  --gov-warning: #F59E0B;       /* Amber for Slow */
  --gov-bg: #F8FAFC;            /* Slate 50 */
  --gov-card: #FFFFFF;
  --gov-border: #E2E8F0;
  --gov-text: #0F172A;
  --gov-text-muted: #64748B;
}

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

body {
  font-family: 'Inter', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #0F172A;
  color: var(--gov-text);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* App Wrapper & Mobile Frame Simulation */
.app-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background-color: #0B1120;
}

/* Device View Modes */
.phone-frame {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  height: 100vh;
  background-color: #F8FAFC;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-width 0.3s ease;
}

/* Fullscreen / Desktop mode */
.phone-frame.desktop-mode {
  max-width: 960px;
  border-radius: 16px;
  margin: 16px auto;
  min-height: 94vh;
  height: 94vh;
}

/* 100% Native Mobile Responsive Rules */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  body {
    background-color: #F8FAFC !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
  }

  .app-container {
    background-color: #F8FAFC !important;
    min-height: 100dvh !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .phone-frame {
    max-width: 100% !important;
    width: 100% !important;
    min-height: 100dvh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }

  .app-header {
    padding-top: max(8px, env(safe-area-inset-top, 8px)) !important;
    padding-bottom: 8px !important;
  }

  /* Micro Typography Upgrades for Mobile Legibility */
  .text-\[9px\] {
    font-size: 11.5px !important;
    line-height: 1.3 !important;
  }
  .text-\[10px\] {
    font-size: 12.5px !important;
    line-height: 1.35 !important;
  }
  .text-\[11px\] {
    font-size: 13.5px !important;
    line-height: 1.4 !important;
  }
  .text-xs {
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  /* Form Inputs on Mobile: Minimum 16px to completely prevent iOS Safari auto-zoom */
  input, select, textarea,
  input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="password"] {
    font-size: 16px !important;
    min-height: 46px !important;
  }

  /* Buttons on Mobile: Minimum touch area */
  button {
    touch-action: manipulation;
  }

  /* Bottom Sheets for All Modals on Mobile */
  .modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
    z-index: 1000 !important;
  }

  .modal-backdrop > div {
    width: 100% !important;
    max-width: 100% !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 1.75rem !important;
    border-top-right-radius: 1.75rem !important;
    max-height: 88dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    margin: 0 !important;
    padding: 1.25rem 1.25rem max(28px, env(safe-area-inset-bottom, 28px)) 1.25rem !important;
    animation: slideUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  #admin-panel-modal > div {
    max-height: 94dvh !important;
    height: 94dvh !important;
  }

  /* Mobile Bottom Navigation */
  .bottom-nav {
    z-index: 40 !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px)) !important;
    height: auto !important;
    min-height: 60px !important;
  }

  .bottom-nav .nav-item span {
    font-size: 12px !important;
  }

  main {
    padding-bottom: max(85px, calc(70px + env(safe-area-inset-bottom, 15px))) !important;
  }
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Top App Header */
.app-header {
  background: linear-gradient(135deg, #1E3A8A 0%, #1e40af 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.15);
}

/* Tricolor Stripe */
.tricolor-bar {
  height: 3px;
  width: 100%;
  background: linear-gradient(to right, #FF9933 0%, #FF9933 33.3%, #FFFFFF 33.3%, #FFFFFF 66.6%, #138808 66.6%, #138808 100%);
}

/* Ticker Bar */
.ticker-wrap {
  background: #172554;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.ticker-wrap::-webkit-scrollbar {
  display: none;
}

/* Urgency Flashing Badge */
@keyframes pulse-urgent {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

.urgent-badge {
  animation: pulse-urgent 1.8s infinite;
  background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
  color: white;
}

.solved-banner {
  background: linear-gradient(135deg, #059669 0%, #10B981 100%);
  color: white;
}

/* Bottom Nav */
.bottom-nav {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: #FFFFFF;
  border-top: 1px solid #E2E8F0;
  z-index: 40;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.nav-item {
  color: #64748B;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item.active {
  color: #1E3A8A;
}

.nav-item.active .nav-indicator {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background-color: #F97316;
  border-radius: 0 0 3px 3px;
}

/* Badges & Tags */
.kiosk-badge {
  background-color: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}

.verified-tick {
  color: #2563EB;
}

/* Floating Action Button (FAB) */
.fab-btn {
  position: fixed;
  bottom: 74px;
  right: calc(50% - 200px);
  z-index: 35;
  box-shadow: 0 10px 25px -5px rgba(249, 115, 22, 0.5);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 768px) {
  /* Mobile Typography - Eliminate unreadable micro-fonts */
  .text-\[8px\],
  .text-\[9px\] {
    font-size: 11px !important;
    line-height: 1.35 !important;
  }
  .text-\[10px\] {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }
  .text-\[11px\] {
    font-size: 13px !important;
    line-height: 1.4 !important;
  }
  .text-xs {
    font-size: 13.5px !important;
    line-height: 1.45 !important;
  }

  /* Universal touch-friendly inputs & zero iOS auto-zoom distortion */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px !important;
    min-height: 46px !important;
  }

  /* Universal button height & visibility on mobile */
  button.w-full,
  .modal-backdrop button[id^="btn-submit"],
  .modal-backdrop button[id^="btn-verify"],
  .modal-backdrop button[id^="btn-send"] {
    min-height: 48px !important;
    font-size: 15px !important;
  }

  /* Modals on mobile: make them scrollable bottom sheets with safe-area padding */
  .modal-backdrop > div {
    max-height: 90dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px)) !important;
  }

  /* Prevent horizontal screen scrolling / cut-offs on mobile */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
  }
  #phone-frame {
    max-width: 100vw !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  .fab-btn {
    right: 16px !important;
    bottom: max(72px, calc(64px + env(safe-area-inset-bottom, 8px))) !important;
  }

  #chat-room-screen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1000 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }

  #chat-bottom-bar,
  .chat-bottom-input-bar {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 50 !important;
    background-color: #ffffff !important;
  }

  #chat-messages-container {
    flex: 1 1 0% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
  }

  #chat-input-text {
    font-size: 16px !important;
    min-height: 44px !important;
  }

  #btn-send-message {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    flex-shrink: 0 !important;
  }

  #call-modal {
    padding-top: max(16px, env(safe-area-inset-top, 16px)) !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important;
  }

  #radar-map {
    height: 220px !important;
  }
}

.fab-btn:hover {
  transform: scale(1.08);
}

.fab-btn:active {
  transform: scale(0.95);
}

/* Chat Room Styles */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #F1F5F9;
}

.chat-bubble-received {
  background: #FFFFFF;
  color: #0F172A;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-bubble-sent {
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%);
  color: #FFFFFF;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 6px rgba(30, 58, 138, 0.25);
}

/* Read Receipts */
.read-tick-blue {
  color: #38BDF8;
}
.read-tick-gray {
  color: rgba(255, 255, 255, 0.6);
}

/* WebRTC Call Dialog Overlay */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@keyframes ripple-ring {
  0% {
    transform: scale(0.9);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.incoming-ring {
  position: relative;
}

.incoming-ring::after {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 9999px;
  border: 3px solid #10B981;
  animation: ripple-ring 1.5s infinite;
}

/* Leaflet Map in Chat and Radar */
.map-embed {
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  z-index: 1;
}

#radar-map {
  height: 280px;
  width: 100%;
  border-radius: 14px;
  z-index: 1;
}

/* Voice Note Waveform simulation */
.voice-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}

.wave-bar {
  width: 3px;
  background-color: currentColor;
  border-radius: 3px;
  animation: pulse-bar 1.2s ease-in-out infinite alternate;
}

@keyframes pulse-bar {
  0% { height: 4px; }
  100% { height: 20px; }
}

.wave-bar:nth-child(1) { animation-delay: 0.1s; height: 8px; }
.wave-bar:nth-child(2) { animation-delay: 0.3s; height: 16px; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; height: 10px; }
.wave-bar:nth-child(4) { animation-delay: 0.5s; height: 22px; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; height: 14px; }
.wave-bar:nth-child(6) { animation-delay: 0.6s; height: 18px; }
.wave-bar:nth-child(7) { animation-delay: 0.2s; height: 9px; }
.wave-bar:nth-child(8) { animation-delay: 0.4s; height: 15px; }

/* Modal Backdrop */
.modal-backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

/* Peer Rating Stars & Chips */
.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}


/* ============================================== */
/* DAY & NIGHT MODE (LIGHT / DARK THEME) */
/* ============================================== */
html.dark {
  color-scheme: dark;
}

html.dark body {
  background-color: #0B1120 !important;
  color: #F8FAFC !important;
}

html.dark .app-container {
  background-color: #020617 !important;
}

html.dark .phone-frame {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
  border-color: #1E293B !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9) !important;
}

html.dark main {
  background-color: #0B1120 !important;
}

html.dark .bg-white {
  background-color: #1E293B !important;
  color: #F8FAFC !important;
  border-color: #334155 !important;
}

html.dark .bg-slate-50 {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
}

html.dark .bg-slate-100 {
  background-color: #1E293B !important;
  color: #F8FAFC !important;
}

html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-slate-700 {
  color: #F1F5F9 !important;
}

html.dark .text-slate-600,
html.dark .text-slate-500 {
  color: #94A3B8 !important;
}

html.dark .border-slate-100,
html.dark .border-slate-200 {
  border-color: #334155 !important;
}

html.dark .bottom-nav {
  background-color: #0F172A !important;
  border-color: #1E293B !important;
}

html.dark .bottom-nav .nav-item {
  color: #94A3B8 !important;
}

html.dark .bottom-nav .nav-item.active {
  color: #38BDF8 !important;
}

html.dark #chat-room-screen {
  background-color: #0B1120 !important;
}

html.dark #chat-room-screen .bg-white {
  background-color: #1E293B !important;
  border-color: #334155 !important;
}

html.dark .modal-backdrop > div {
  background-color: #1E293B !important;
  color: #F8FAFC !important;
  border-color: #334155 !important;
}

html.dark input,
html.dark select,
html.dark textarea {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
  border-color: #334155 !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #64748B !important;
}

/* Back button pulse effect */
#btn-top-back:active {
  transform: scale(0.92);
}
