/**
 * Nhà Ở Việt (NÓV) — Base Stylesheet
 * Modern Design Tokens, Typography, Resets, Tactile Haptics & Responsive Layout Shell
 */

:root {
  color-scheme: light;
  
  /* Primary & Brand Colors */
  --brand: #155eef;
  --brand-hover: #1249c5;
  --brand-light: #eff4ff;
  --teal: #087e73;
  --teal-hover: #06675e;
  --coral: #b83e31;
  --vip-bg: #fff0b3;
  --vip-ink: #5c4100;
  
  /* Surfaces & Backgrounds */
  --page: #f5f8fb;
  --surface: #ffffff;
  --surface-blue: #eef4ff;
  --surface-mint: #e6f7f2;
  --surface-coral: #fff1ef;
  --border: #dbe4ef;
  --border-light: #edf2f7;
  
  /* Typography Colors */
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  
  /* Status Colors */
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  
  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --shadow: 0 12px 34px rgba(23, 36, 58, 0.08);
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* Typography */
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

html, body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--page);
  color: var(--ink);
}

button, input, select, textarea {
  font: inherit;
  max-width: 100%;
}

button, select {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

code {
  word-break: break-all;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

/* =====================================================================
   Tactile Touch & Physical Click Sensations ("Lần chạm phải cảm giác")
   ===================================================================== */
button, .button, .nav-link, .area-chip, .blog-cat-btn, .favorite-button,
.compare-dock-cta, .state-tab, .quick-link, .chat-floating-btn {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button:active, .button:active, .area-chip:active, .blog-cat-btn:active,
.favorite-button:active, .compare-dock-cta:active, .state-tab:active,
.nav-link:active, .chat-quick-pill:active {
  transform: scale(0.958) !important;
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Top Demo Ribbon */
.demo-ribbon {
  min-height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: #e5f6f1;
  color: #075c54;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.demo-ribbon strong {
  color: var(--brand);
}

/* Sticky Topbar with Glassmorphic Blur */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(216, 226, 238, 0.85);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  transition: all 0.2s ease;
}

.topbar-inner, .container {
  width: min(1280px, calc(100% - 48px));
  margin-inline: auto;
}

.topbar-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brandmark {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}
.brandmark:active {
  transform: scale(0.97);
}

.brand-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand) 0%, #0045c7 100%);
  color: white;
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(21, 94, 239, 0.28);
}

.brand-logo-img {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid rgba(180, 140, 50, 0.4);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.14);
}

.brand-copy {
  display: grid;
  line-height: 1.1;
}
.brand-copy strong {
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--ink);
  font-weight: 800;
}
.brand-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Main Navigation */
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link, .account-toggle {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  background: transparent;
  color: #334155;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover, .account-toggle:hover {
  background: var(--surface-blue);
  color: var(--brand);
}

.nav-link.active {
  color: var(--brand);
  background: var(--surface-blue);
  font-weight: 700;
}

/* Header Top Actions & User Account Menu */
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-menu {
  position: relative;
}

.account-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-mint);
  color: var(--teal);
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.account-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: white;
  box-shadow: var(--shadow-lg);
  animation: reveal 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
}

.account-popover p {
  margin: 6px 9px 8px;
  color: var(--muted);
  font-size: 12px;
}

.account-popover button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.12s ease;
}

.account-popover button:hover {
  background: var(--surface-blue);
  color: var(--brand);
}

/* Layout Main Content & Views */
main {
  padding-bottom: 72px;
}

.page-view {
  animation: reveal 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.intro {
  padding: 28px 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 4px #dcfce7;
}

h1, h2, h3, h4, p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin: 8px 0 6px;
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 32px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 800;
}

.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.intro-note {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 270px;
  padding: 10px 14px;
  border: 1px solid #cce8de;
  border-radius: var(--radius-sm);
  background: #f0fdf7;
  color: #115e52;
  font-size: 11.5px;
  font-weight: 600;
}

/* Animations */
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Mobile Fixed Bottom Navigation Bar */
.mobile-nav {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive Shell Breakpoints */
@media (max-width: 1050px) {
  .topbar-inner, .container {
    width: min(100% - 32px, 940px);
  }
  .topbar-inner {
    gap: 16px;
  }
  .main-nav {
    gap: 2px;
  }
  .nav-link {
    padding-inline: 8px;
    font-size: 12.5px;
  }
}

@media (max-width: 740px) {
  .demo-ribbon {
    min-height: 28px;
    font-size: 10px;
    padding: 4px 10px;
  }
  .topbar {
    position: sticky;
    top: 0;
  }
  .topbar-inner, .container {
    width: calc(100% - 24px);
    max-width: 100%;
  }
  .topbar-inner {
    min-height: 58px;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: space-between;
  }
  .brandmark {
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }
  .brand-icon, .brand-logo-img {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 9px;
  }
  .brand-copy {
    min-width: 0;
  }
  .brand-copy strong {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-copy small {
    font-size: 7.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .main-nav {
    display: none;
  }
  .top-actions {
    margin-left: auto;
    gap: 6px;
    flex: 0 0 auto;
  }
  .account-toggle {
    padding: 4px;
  }
  .account-toggle .account-label, .account-toggle .account-arrow {
    display: none;
  }
  .account-popover {
    position: fixed;
    top: 60px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: 340px;
    margin-left: auto;
    z-index: 50;
  }
  .top-actions > .button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 11px;
    white-space: nowrap;
  }
  main {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 12px));
  }
  input, select, textarea {
    font-size: 16px; /* Prevents auto-zoom on iOS */
  }
  .intro {
    display: block;
    padding: 18px 0 12px;
  }
  .eyebrow {
    flex-wrap: wrap;
    font-size: 10px;
  }
  h1 {
    margin: 8px 0 6px;
    font-size: 22px;
    line-height: 1.3;
    word-break: break-word;
  }
  .intro p {
    max-width: 100%;
    font-size: 12.5px;
    line-height: 1.5;
  }
  .intro-note {
    display: none;
  }

  /* Bottom Tab Bar for Mobile */
  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px max(6px, env(safe-area-inset-bottom, 8px));
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }
  .mobile-nav button {
    min-height: 48px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 9.5px;
    font-weight: 700;
  }
  .mobile-nav button span:first-child {
    font-size: 18px;
    line-height: 1;
  }
  .mobile-nav button.active {
    background: var(--surface-blue);
    color: var(--brand);
  }
}

@media (max-width: 420px) {
  .topbar-inner, .container {
    width: calc(100% - 18px);
  }
  .brand-copy small {
    display: none;
  }
  .top-actions > .button {
    padding-inline: 8px;
    font-size: 10px;
  }
  #top-auth-status-label {
    font-size: 10px;
  }
}

@media (max-width: 380px) {
  .topbar-inner, .container {
    width: calc(100% - 14px);
  }
  .brand-copy strong {
    font-size: 13px !important;
  }
  .brand-icon, .brand-logo-img {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
  }
  .top-actions > .button {
    padding: 5px 6px !important;
    font-size: 9.5px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
