/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* CSS Variables for design system */
:root {
  /* Common variables */
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-speed: 0.25s;
  
  /* Indian License Plate Badge color styling */
  --plate-bg: #facc15;
  --plate-text: #1e293b;
  --plate-border: #0f172a;
}

/* Dark Theme variables */
[data-theme="dark"] {
  --bg-color: #030712;
  --bg-gradient: radial-gradient(circle at 50% 0%, #111827 0%, #030712 100%);
  --panel-bg: rgba(17, 24, 39, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  
  --primary: #38bdf8;
  --primary-rgb: 56, 189, 248;
  --primary-hover: #0ea5e9;
  
  --accent: #f43f5e;
  --accent-hover: #e11d48;
  
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --card-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.25);
  
  --input-bg: rgba(31, 41, 55, 0.6);
  --input-border: rgba(255, 255, 255, 0.12);
  --input-text: #f3f4f6;
}

/* Light Theme variables */
[data-theme="light"] {
  --bg-color: #f8fafc;
  --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  --panel-bg: rgba(255, 255, 255, 0.8);
  --panel-border: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #475569;
  
  --primary: #0284c7;
  --primary-rgb: 2, 132, 199;
  --primary-hover: #0369a1;
  
  --accent: #e11d48;
  --accent-hover: #be123c;
  
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
  --card-shadow: 0 4px 15px 0 rgba(148, 163, 184, 0.12);
  
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-border: rgba(0, 0, 0, 0.15);
  --input-text: #0f172a;
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: 90px; /* Space for sticky bottom navigation */
}

a {
  text-decoration: none;
  color: inherit;
}

/* Layout Shell */
.app-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 16px 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #030712;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
}

.logo-text h1 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: block;
  margin-top: -2px;
}

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

.theme-toggle-btn {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed) ease;
}

.theme-toggle-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
}

/* Views & Routing container */
.view {
  transition: opacity var(--transition-speed) ease;
}

.hidden {
  display: none !important;
}

/* Animation utilities */
.fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* HOME VIEW */
.home-hero {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 30px;
}

.hero-title {
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -1px;
}

.hero-title span {
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 500px;
  margin: 0 auto 30px auto;
}

/* Home Quick Search */
.home-search-container {
  display: flex;
  max-width: 600px;
  margin: 0 auto;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 8px;
  border-radius: 14px;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(12px);
}

.home-search-container input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 16px;
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--font-body);
}

.home-search-container input:focus {
  outline: none;
}

.home-search-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #030712;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-speed) ease;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.2);
}

.home-search-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(var(--primary-rgb), 0.3);
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  box-shadow: var(--card-shadow);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card:nth-child(2) .stat-icon {
  background: rgba(168, 85, 247, 0.1);
  color: #a855f7;
}

.stat-card:nth-child(3) .stat-icon {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 4px;
}

/* District Badge list */
.section-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.districts-section {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--glass-shadow);
}

.districts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.district-badge-card {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.district-badge-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.05);
}

.district-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.district-count {
  background: var(--primary);
  color: #030712;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
}

/* SEARCH & FAVORITES PAGE VIEW */
.search-controls {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  align-items: center;
  backdrop-filter: blur(12px);
  box-shadow: var(--glass-shadow);
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-icon-inside {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.control-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--input-text);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  transition: all var(--transition-speed) ease;
}

.control-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

.search-input-wrapper .control-input {
  padding-left: 42px;
}

.select-wrapper {
  position: relative;
}

.control-select {
  width: 100%;
  appearance: none;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--input-text);
  border-radius: 10px;
  padding: 12px 34px 12px 16px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.control-select:focus {
  outline: none;
  border-color: var(--primary);
}

.select-wrapper::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}

/* Results header */
.results-header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 0 6px;
}

.results-count {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* RTO Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.rto-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
}

.rto-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.3), 0 4px 10px -5px rgba(var(--primary-rgb), 0.1);
}

/* License Plate styling for Card Badge */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--panel-border);
  padding-bottom: 12px;
}

.code-badge {
  background: var(--plate-bg);
  color: var(--plate-text);
  border: 2px solid var(--plate-border);
  border-radius: 6px;
  padding: 4px 12px;
  font-family: monospace;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 1px;
  box-shadow: inset 0 1px 3px rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.15);
  position: relative;
  text-shadow: 0.5px 0.5px 0px rgba(255, 255, 255, 0.3);
}

/* License plate rivets effect */
.code-badge::before, .code-badge::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #64748b;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0.5px 0.5px 0px rgba(0,0,0,0.3);
}

.code-badge::before { left: 4px; }
.code-badge::after { right: 4px; }

.fav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed) ease;
}

.fav-btn:hover {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent);
}

.fav-btn.active {
  color: var(--accent);
}

.heart-icon {
  width: 22px;
  height: 22px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fav-btn:active .heart-icon {
  transform: scale(1.3);
}

/* Card Body */
.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  margin-bottom: 16px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

.info-row.align-start {
  align-items: flex-start;
}

.info-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 65px;
}

.info-value {
  color: var(--text-main);
  text-align: right;
}

.font-bold {
  font-weight: 700;
  color: var(--text-main);
}

.font-medium {
  font-weight: 600;
}

.address-value {
  text-align: right;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 220px;
}

.disabled-text {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* Info links */
.info-link {
  color: var(--primary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s ease;
}

.info-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* Card Footer actions */
.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid var(--panel-border);
  padding-top: 14px;
}

.action-btn {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-speed) ease;
}

.action-btn:hover {
  background: rgba(var(--primary-rgb), 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.map-btn {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.15), rgba(var(--primary-rgb), 0.05));
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  color: var(--primary);
}

.map-btn:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #030712;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.15);
}

/* Empty State component */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 450px;
  margin: 40px auto;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.empty-state h3 {
  font-family: var(--font-title);
  font-size: 1.35rem;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.empty-state button {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #030712;
  border: none;
  padding: 10px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.empty-state button:hover {
  transform: translateY(-1px);
}

/* Floating Bottom Navigation Bar (mirrors mobile tab layout) */
.bottom-nav {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: calc(100% - 40px);
  max-width: 500px;
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  display: flex;
  justify-content: space-around;
  padding: 8px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all var(--transition-speed) ease;
}

/* Adjust navigation colors depending on the active theme */
[data-theme="light"] .bottom-nav {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 20px 40px rgba(31, 38, 135, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 16px;
  transition: all var(--transition-speed) ease;
  min-width: 70px;
}

.nav-item-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.nav-item-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.nav-item:hover {
  color: var(--text-main);
}

.nav-item:hover .nav-item-icon {
  transform: translateY(-2px);
}

.nav-item.active {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.1);
}

/* Custom Toast Container */
#toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

[data-theme="light"] .toast {
  background: #0f172a;
  color: #f8fafc;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Card Load in micro-animations */
.animate-card {
  animation: cardEntrance 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* Stagger card load effects using JS or CSS list children */
.animate-card:nth-child(1) { animation-delay: 0.03s; }
.animate-card:nth-child(2) { animation-delay: 0.06s; }
.animate-card:nth-child(3) { animation-delay: 0.09s; }
.animate-card:nth-child(4) { animation-delay: 0.12s; }
.animate-card:nth-child(5) { animation-delay: 0.15s; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .search-controls {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 0.95rem;
  }
  
  .app-container {
    padding: 12px;
  }
  
  .app-header {
    margin-bottom: 20px;
  }
}

@media (max-width: 480px) {
  .bottom-nav {
    width: calc(100% - 24px);
    bottom: 12px;
  }
  
  #toast-container {
    bottom: 90px;
  }
}
