/* ===== RESET & VARS ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1923;
  --bg2:       #162232;
  --bg3:       #1e2f42;
  --bg4:       #253650;
  --border:    #2a3d52;
  --border2:   #3a5068;
  --text:      #e8edf2;
  --text2:     #8fa8c0;
  --text3:     #5a7a94;
  --orange:    #f07030;
  --orange2:   #ff8c50;
  --orange-bg: rgba(240,112,48,0.12);
  --green:     #30c07a;
  --green-bg:  rgba(48,192,122,0.1);
  --blue:      #4a9eff;
  --blue-bg:   rgba(74,158,255,0.1);
  --yellow:    #f0c030;
  --yellow-bg: rgba(240,192,48,0.1);
  --red:       #e05050;
  --red-bg:    rgba(224,80,80,0.1);
  --radius:    12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ===== APP SHELL ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
}

/* ===== HEADER ===== */
.app-header {
  background: var(--bg);
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.app-header-title { font-size: 17px; font-weight: 700; color: var(--text); }
.app-header-sub { font-size: 11px; color: var(--text3); font-family: var(--mono); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  padding: 11px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
}
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab:active { background: var(--bg3); }

/* ===== LOCATION BAR ===== */
.loc-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.loc-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
}
.loc-input-wrap svg { color: var(--text3); flex-shrink: 0; }
.loc-input-wrap input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  flex: 1;
  padding: 10px 0;
  min-width: 0;
}
.loc-input-wrap input::placeholder { color: var(--text3); }
.btn-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  transition: all 0.15s;
}
.btn-icon:active { transform: scale(0.93); }
.btn-locate { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(74,158,255,0.25); }
.btn-go { background: var(--orange); color: white; }



/* ===== CARD PHONE NUMBER ===== */
.pc-phone {
  font-size: 12px;
  color: var(--green);
  font-family: var(--mono);
  margin-bottom: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 2px 0;
}
.pc-phone:active { opacity: 0.7; }
.pc-hours {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 5px;
  font-family: var(--mono);
}

/* ===== FEEDBACK BUTTON ===== */
.feedback-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 10px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text3);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.feedback-btn:active { background: var(--bg3); color: var(--text2); }

/* ===== RESOURCES TAB ===== */
.res-section-hdr {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.res-ts-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.res-link-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s;
}
.res-link-card:active { border-color: var(--orange); }
/* ===== SUPPLIER NAME FILTER BAR ===== */
.name-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px 8px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.name-bar .loc-input-wrap {
  flex: 1;
  background: var(--bg3);
  border-color: var(--border);
}
.name-bar .loc-input-wrap input {
  font-size: 13px;
}
.name-bar .loc-input-wrap svg {
  color: var(--text3);
  flex-shrink: 0;
}
/* ===== RADIUS ROW ===== */
.radius-row {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.radius-row::-webkit-scrollbar { display: none; }
.radius-lbl { font-size: 11px; color: var(--text3); font-family: var(--mono); flex-shrink: 0; }
.radius-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg3);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text2);
  flex-shrink: 0;
  transition: all 0.15s;
  user-select: none;
}
.radius-chip.active { background: var(--orange-bg); color: var(--orange); border-color: var(--orange); }
.radius-chip:active { opacity: 0.7; }

/* ===== FILTER ROW ===== */
.filter-row {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg3);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text2);
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}
.filter-chip.active { background: var(--orange-bg); color: var(--orange); border-color: rgba(240,112,48,0.4); }
.filter-chip:active { opacity: 0.7; }

/* ===== SCROLL AREA ===== */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ===== PLACE CARDS ===== */
.results-list { padding: 8px; display: flex; flex-direction: column; gap: 8px; }

.place-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.place-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.15s;
}
.place-card.selected { border-color: var(--orange); }
.place-card.selected::before { background: var(--orange); }
.place-card:active { background: var(--bg3); }

.pc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.pc-name { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.pc-dist { font-size: 12px; color: var(--text3); font-family: var(--mono); flex-shrink: 0; }
.pc-addr { font-size: 13px; color: var(--text2); margin-bottom: 8px; line-height: 1.4; }

.pc-badges { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; padding: 3px 8px;
  border-radius: 999px; flex-shrink: 0;
}
.badge-hvac       { background: rgba(74,158,255,0.15); color: #7ab8ff; }
.badge-refrig     { background: rgba(48,192,192,0.15); color: #40d0d0; }
.badge-plumb      { background: rgba(48,192,122,0.15); color: var(--green); }
.badge-elec       { background: rgba(240,192,48,0.15); color: var(--yellow); }
.badge-text       { background: rgba(48,192,122,0.2); color: var(--green); border: 1px solid rgba(48,192,122,0.3); }
.badge-match      { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(240,112,48,0.3); }
.badge-filters    { background: rgba(167,139,250,0.2); color: #a78bfa; }
.badge-ice        { background: rgba(103,232,249,0.2); color: #67e8f9; }
.badge-general    { background: rgba(156,163,175,0.15); color: var(--g400); }
.badge-open       { background: var(--green-bg); color: var(--green); }
.badge-closed     { background: var(--red-bg); color: var(--red); }

/* ===== DETAIL SHEET ===== */
.detail-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  max-height: 82vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: var(--safe-bottom);
}
.detail-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.sheet-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; padding: 16px; }

.sheet-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.sheet-addr { font-size: 13px; color: var(--text2); margin-bottom: 12px; }

.sheet-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 14px; }

.info-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--text2); font-size: 14px; }
.info-row svg { color: var(--text3); flex-shrink: 0; }
.info-row a { color: var(--text2); text-decoration: none; }

.sheet-section-lbl {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text3); font-family: var(--mono);
  margin: 16px 0 8px;
}

.brand-list { display: flex; gap: 5px; flex-wrap: wrap; }
.brand-tag {
  font-size: 11px; font-weight: 600;
  background: var(--bg4); color: var(--text2);
  border: 1px solid var(--border);
  padding: 4px 9px; border-radius: 5px;
  font-family: var(--mono);
}
.brand-tag.match { background: var(--orange-bg); color: var(--orange); border-color: rgba(240,112,48,0.3); }

/* ===== ACTION BUTTONS ===== */
.action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.action-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 12px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  font-family: var(--font);
  user-select: none;
}
.action-btn:active { transform: scale(0.95); }
.action-btn svg { width: 20px; height: 20px; }
.action-btn.call { background: var(--green-bg); color: var(--green); border-color: rgba(48,192,122,0.3); }
.action-btn.sms  { background: var(--blue-bg); color: var(--blue); border-color: rgba(74,158,255,0.3); }
.action-btn.dir  { background: var(--orange-bg); color: var(--orange); border-color: rgba(240,112,48,0.3); }
.action-btn.web  { background: var(--bg4); color: var(--text2); }

/* ===== BACKDROP ===== */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  display: none;
  backdrop-filter: blur(2px);
}
.backdrop.show { display: block; }

/* ===== BRAND SEARCH ===== */
.brand-search-panel { padding: 12px; }
.brand-search-info { font-size: 13px; color: var(--text2); margin-bottom: 12px; line-height: 1.5; }
.brand-search-info strong { color: var(--text); }

.brand-grid { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.brand-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg3);
  font-size: 12px; font-weight: 600;
  cursor: pointer; color: var(--text2);
  font-family: var(--mono);
  transition: all 0.15s;
  user-select: none;
}
.brand-pill.sel { background: var(--orange-bg); color: var(--orange); border-color: rgba(240,112,48,0.4); }
.brand-pill:active { opacity: 0.7; }

.brand-custom-row { display: flex; gap: 8px; margin-bottom: 14px; }
.brand-custom-row input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  padding: 10px 12px;
  outline: none;
}
.brand-custom-row input:focus { border-color: var(--orange); }
.brand-custom-row input::placeholder { color: var(--text3); }
.btn-add {
  width: 44px; height: 44px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-add:active { background: var(--bg4); }

.btn-full {
  width: 100%;
  padding: 13px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.15s;
}
.btn-full:active { background: #c85c20; transform: scale(0.98); }
.btn-full:disabled { background: var(--bg4); color: var(--text3); cursor: not-allowed; transform: none; }

.sel-brands-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; min-height: 10px; }
.sel-brand-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--orange-bg); color: var(--orange);
  border: 1px solid rgba(240,112,48,0.3);
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  font-family: var(--mono);
}
.sel-brand-tag button {
  background: none; border: none; color: var(--orange);
  font-size: 16px; cursor: pointer; padding: 0; line-height: 1;
  opacity: 0.7;
}

.brand-results-header {
  font-size: 11px; color: var(--text3); font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 14px 0 8px;
}

/* ===== EMPTY / LOADING ===== */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 48px 24px;
  text-align: center; color: var(--text3);
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 14px; line-height: 1.6; max-width: 220px; }

.loading-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 48px 24px; color: var(--text2);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-txt { font-size: 14px; font-family: var(--mono); }

/* ===== RATINGS ===== */
.rating-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.stars { color: var(--yellow); font-size: 13px; letter-spacing: 1px; }
.rating-count { font-size: 12px; color: var(--text3); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg4);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--border2);
  z-index: 999;
  transition: transform 0.25s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== DIVIDER ===== */
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ===== INSTALL BANNER ===== */
.install-banner {
  background: var(--blue-bg);
  border-bottom: 1px solid rgba(74,158,255,0.2);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.install-banner p { font-size: 13px; color: var(--blue); flex: 1; }
.install-banner button {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  flex-shrink: 0;
}
.install-banner .dismiss {
  background: none;
  color: var(--blue);
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .detail-sheet { max-width: 480px; left: 50%; transform: translateX(-50%) translateY(100%); right: auto; width: 100%; }
  .detail-sheet.open { transform: translateX(-50%) translateY(0); }
}
