/* ===================================================
   OpenAA 华人导航 - style.css
   Mobile-first, iOS App style, OpenAA Blue theme
   =================================================== */

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  background: #f4f4f7;
  color: #1a1a2e;
  min-height: 100vh;
  /* Bottom nav safe area */
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* ---- Layout container ---- */
.main-content {
  max-width: 560px;
  margin: 0 auto;
  background: #f4f4f7;
}

/* ===================================================
   HEADER
   =================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(228, 228, 235, 0.8);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  position: relative;
}

/* Left: location */
.header-location {
  display: flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #3f3f46;
  padding: 6px 4px;
  border-radius: 8px;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.header-location:active { opacity: 0.7; }

.icon-pin {
  width: 14px;
  height: 14px;
  color: #3b82f6;
  flex-shrink: 0;
}
.icon-chevron {
  width: 12px;
  height: 12px;
  color: #a1a1aa;
  margin-top: 1px;
  flex-shrink: 0;
}

/* Center: logo */
.header-logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 6px;
  user-select: none;
}
.header-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
}
.header-logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo-blue { color: #3b82f6; }
.logo-dark { color: #18181b; }

/* Right: share */
.header-share {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.header-share:active { background: #e4e4e7; }
.header-share svg {
  width: 16px;
  height: 16px;
  color: #52525b;
}

/* Spacer below fixed header */
.header-spacer {
  height: 56px;
  max-width: 560px;
  margin: 0 auto;
}

/* ===================================================
   BANNER CAROUSEL
   =================================================== */
.banner-section {
  background: #fff;
  padding: 16px 16px 0;
}

.banner-wrapper {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
  background: #e4e4e7;
  touch-action: pan-y;
  user-select: none;
}

.banner-track {
  display: flex;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.banner-slide {
  flex: 0 0 100%;
  width: 100%;
  cursor: pointer;
  display: block;
  text-decoration: none;
}

.banner-slide img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  background: #e4e4e7;
}

/* Placeholder slide shown when no real images */
.banner-placeholder {
  width: 100%;
  height: 160px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: white;
}
.banner-placeholder span {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.9;
}

/* Dots */
.banner-dots {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 5px;
  z-index: 10;
}
.banner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.banner-dot.active {
  background: #fff;
  width: 18px;
  border-radius: 3px;
}

/* ===================================================
   SEARCH BAR
   =================================================== */
.search-section {
  background: #fff;
  padding: 12px 16px 16px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: #a1a1aa;
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 40px;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 999px;
  font-size: 14px;
  color: #3f3f46;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  font-family: inherit;
}
.search-input::placeholder { color: #a1a1aa; }
.search-input:focus {
  border-color: #bfdbfe;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #fff;
}

.search-clear {
  position: absolute;
  right: 12px;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  background: #a1a1aa;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.search-clear.visible { display: flex; }
.search-clear svg {
  width: 11px;
  height: 11px;
  color: #fff;
}

/* ===================================================
   GRID MENU (8 宫格)
   =================================================== */
.grid-menu-section {
  background: #f4f4f5;
  border-top: 1px solid #e4e4e7;
  border-bottom: 1px solid #e4e4e7;
  padding: 20px 16px;
  margin-top: 0;
}

.grid-menu {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 8px;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
}
.grid-item:active { transform: scale(0.9); }

.grid-icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.grid-icon-wrap svg {
  width: 25px;
  height: 25px;
}

/* Color variants */
.grid-icon-wrap.blue   { background: #eff6ff; border: 1px solid #bfdbfe; color: #3b82f6; }
.grid-icon-wrap.emerald{ background: #ecfdf5; color: #10b981; }
.grid-icon-wrap.violet { background: #f5f3ff; color: #8b5cf6; }
.grid-icon-wrap.amber  { background: #fffbeb; color: #f59e0b; }
.grid-icon-wrap.rose   { background: #fff1f2; color: #f43f5e; }
.grid-icon-wrap.cyan   { background: #ecfeff; color: #06b6d4; }
.grid-icon-wrap.orange { background: #fff7ed; color: #f97316; }
.grid-icon-wrap.teal   { background: #f0fdfa; color: #14b8a6; }

.grid-item span {
  font-size: 13px;
  font-weight: 500;
  color: #18181b;
  text-align: center;
  line-height: 1.2;
  word-break: keep-all;
}

/* ===================================================
   CATEGORY BAR (分类吸顶栏)
   =================================================== */
.category-bar-wrap {
  position: sticky;
  top: 56px;
  z-index: 90;
  background: #fff;
  border-bottom: 1px solid #e4e4e7;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.category-bar {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 4px;
}
.category-bar::-webkit-scrollbar { display: none; }

.cat-tab {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #71717a;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.cat-tab::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 20px;
  height: 2px;
  background: #3b82f6;
  border-radius: 1px;
  transition: transform 0.2s;
}
.cat-tab.active {
  color: #3b82f6;
  font-weight: 600;
}
.cat-tab.active::after { transform: translateX(-50%) scaleX(1); }

/* ===================================================
   NAV MODULES
   =================================================== */
.nav-modules {
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-module {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.nav-module.hidden { display: none; }

.module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #f4f4f5;
}

.module-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.module-icon svg { width: 15px; height: 15px; }

.module-icon.star   { background: #fff9c4; color: #ca8a04; }
.module-icon.gov    { background: #e3f2fd; color: #1565c0; }
.module-icon.bank   { background: #e8f5e9; color: #2e7d32; }
.module-icon.shop   { background: #fff3e0; color: #e65100; }
.module-icon.dmv    { background: #fff9c4; color: #f59e0b; }
.module-icon.tools  { background: #f3e5f5; color: #7b1fa2; }
.module-icon.ai     { background: #e8f5e9; color: #0f766e; }

.module-title {
  font-size: 15px;
  font-weight: 700;
  color: #18181b;
}

/* Module grid: 2 cols on mobile */
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: #f4f4f5;
}

/* Nav cards */
.nav-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  text-decoration: none;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}
.nav-card:active { background: #f8f8f9; }

.nav-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  overflow: hidden;
  position: relative;
}
.nav-card-icon img {
  position: absolute;
  width: 20px;
  height: 20px;
  object-fit: contain;
}
.nav-card-icon span {
  font-size: 18px;
  line-height: 1;
}

.nav-card-name {
  font-size: 13px;
  font-weight: 500;
  color: #27272a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* No results */
.no-results {
  text-align: center;
  padding: 48px 16px;
  color: #a1a1aa;
  background: #fff;
  border-radius: 16px;
}
.no-results svg {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  display: block;
}
.no-results p {
  font-size: 15px;
  font-weight: 500;
  color: #71717a;
  margin-bottom: 4px;
}
.no-results small {
  font-size: 13px;
  color: #a1a1aa;
}

/* ===================================================
   BOTTOM NAV
   =================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid #e4e4e7;
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 10px;
  text-decoration: none;
  color: #a1a1aa;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}
.bottom-nav-item:active { color: #3b82f6; }
.bottom-nav-item.active,
.bottom-nav-item[aria-current="page"] {
  color: #3b82f6;
}

/* ===================================================
   RESPONSIVE — tablet / desktop
   =================================================== */
@media (min-width: 480px) {
  .banner-slide img { height: 180px; }
  .banner-placeholder { height: 180px; }
  .module-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 600px) {
  .banner-slide img { height: 200px; }
  .banner-placeholder { height: 200px; }
  .grid-menu { gap: 20px 12px; }
}

/* ===================================================
   SEARCH HIGHLIGHT
   =================================================== */
.nav-card.search-hidden { display: none; }
.nav-module.search-empty { display: none; }
