/* ================================
   GM REFERANS AI — MOBILE FIRST
================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Roboto', system-ui, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  line-height: 1.5;
}

:root {
  --primary: #174ea6;
  --primary-hover: #0f3b82;
  --primary-light: #e8eef6;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --text: #0f172a;
  --text-soft: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.07);
  --shadow-md: 0 6px 20px rgba(0,0,0,.10);
}

/* ========= TOPBAR ========= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}

.brand-wrap { line-height: 1.2; }
.brand-title  { font-size: 17px; font-weight: 700; color: var(--primary); }
.brand-subtitle { font-size: 11px; color: var(--text-soft); }

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

.search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
#aiInput {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  padding: 0 12px 0 34px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  outline: none;
  transition: .15s;
}
#aiInput:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px #174ea618;
}

/* ========= BUTTONS ========= */
.btn {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  transition: .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary  { background: var(--primary); color: white; }
.btn-primary:active  { background: var(--primary-hover); transform: scale(.97); }
.btn-secondary { background: var(--primary-light); color: var(--primary); padding: 0 10px; }
.btn-secondary:active { background: #d0dff2; transform: scale(.97); }

/* ========= PAGE LAYOUT ========= */
.page-layout {
  display: flex;
  flex-direction: column;
}

/* ========= MAP SIDE ========= */
.map-side {
  display: flex;
  flex-direction: column;
}

/* MAP TOGGLE BAR */
.map-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.map-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  padding: 6px 0;
  font-family: inherit;
}
.result-count {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}

/* MAP WRAPPER */
.map-wrapper {
  width: 100%;
  overflow: hidden;
  transition: height .3s cubic-bezier(.4,0,.2,1),
              min-height .3s cubic-bezier(.4,0,.2,1);
  height: 44vw;
  min-height: 200px;
  max-height: 360px;
  position: relative;
  background: #e8eef6;
}
.map-wrapper.map-hidden {
  height: 0 !important;
  min-height: 0 !important;
}
#map { width: 100%; height: 100%; }
#mapLoading {
  position: absolute; inset: 0; z-index: 10;
  display: none; align-items: center; justify-content: center;
  background: #f0f4fa;
}

/* ========= CONTENT SIDE ========= */
.content-side {
  padding: 12px 12px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========= SECTION ========= */
.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section-head h2 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 0 2px;
}

/* ========= CARD GRID ========= */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ========= CARD ========= */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
  cursor: pointer;
  animation: fadeUp .2s ease both;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: box-shadow .15s;
}
.card:active { box-shadow: var(--shadow); transform: scale(.99); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  line-height: 1.35;
}
.card-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.card-dist {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}
.fav {
  font-size: 22px;
  color: #f59e0b;
  cursor: pointer;
  line-height: 1;
  padding: 2px 0;
  transition: transform .12s;
}
.fav:active { transform: scale(1.3); }

/* ========= CARD DETAIL ROWS ========= */
.card-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.card-detail-row:last-of-type { border-bottom: none; }

.card-detail-icon {
  font-size: 16px;
  margin-top: 1px;
  flex-shrink: 0;
}
.card-detail-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.card-detail-val {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}

.card-tech-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 3px;
}
.card-tech-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.card-tech-key {
  color: var(--text-soft);
  min-width: 65px;
}
.card-tech-val {
  font-weight: 600;
  color: var(--text);
}

/* ========= CARD FOOTER ========= */
.card-footer {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.btn-nav {
  flex: 1;
  height: 40px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.btn-nav:active { background: var(--primary-hover); }

/* ========= STATE CARD ========= */
.state-card {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-soft);
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ========= LOADER ========= */
.loader {
  width: 34px; height: 34px;
  border: 3px solid #dde4ef;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========= MODAL — bottom sheet ========= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}
.modal[style*="block"] { display: flex !important; }

.modal-content {
  background: white;
  border-radius: 22px 22px 0 0;
  padding: 8px 20px 40px;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp .25s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-content::before {
  content: "";
  display: block;
  width: 40px; height: 4px;
  background: #cbd5e1;
  border-radius: 4px;
  margin: 10px auto 18px;
}

.modal-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-soft);
  display: flex; align-items: center; justify-content: center;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  padding-right: 36px;
  line-height: 1.3;
}
.modal-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.modal-row:last-of-type { border-bottom: none; }

.modal-row-icon {
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}
.modal-row-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 3px;
}
.modal-row-val {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}

.modal-tech-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}
.modal-tech-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.modal-tech-key {
  color: var(--text-soft);
  min-width: 70px;
}
.modal-tech-val {
  font-weight: 600;
  color: var(--text);
}
.modal-nav-btn {
  width: 100%;
  height: 52px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
  -webkit-tap-highlight-color: transparent;
}
.modal-nav-btn:active { background: var(--primary-hover); transform: scale(.98); }

/* ========= SCROLL TO TOP ========= */
.scroll-top-btn {
  position: fixed;
  right: 16px; bottom: 24px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  font-size: 18px;
  z-index: 150;
  align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ========= SCROLLBAR ========= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }

/* ========= DESKTOP (≥900px) ========= */
@media (min-width: 900px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    padding: 14px 24px;
  }

  .map-toggle-bar { display: none; }

  .page-layout {
    flex-direction: row;
    align-items: flex-start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px 60px;
    gap: 20px;
  }

  .map-side {
    flex: 1.5;
    position: sticky;
    top: 86px;
  }
  .map-wrapper {
    height: 520px;
    max-height: 520px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    transition: none;
  }
  .map-wrapper.map-hidden {
    height: 520px !important;
    min-height: 520px !important;
  }

  .content-side {
    flex: 1;
    padding: 0;
    min-width: 340px;
    max-width: 480px;
  }

  .modal { align-items: center; padding: 20px; }
  .modal-content {
    border-radius: 22px;
    max-height: 80vh;
    margin: auto;
  }
  .modal-content::before { display: none; }
}

/* ========= BRAND LOGO ========= */
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
