/* screen.css — Layout global, variáveis, header, nav */

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --color-primary: #1a73e8;
  --color-primary-dark: #1557b0;
  --color-surface: #ffffff;
  --color-background: #f8f9fa;
  --color-text: #202124;
  --color-text-secondary: #5f6368;
  --color-border: #dadce0;
  --color-error: #d93025;
  --color-success: #188038;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --font-size-sm: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.12);
  --shadow-md: 0 2px 8px rgba(0,0,0,.15);

  --nav-height: 60px;
}

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

html, body {
  height: 100%;
  font: var(--font-size-md)/1.5 var(--font);
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
}

/* ── Nav bottom ───────────────────────────────────────────── */
#app-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  height: var(--nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -1px 8px rgba(0,0,0,.08);
  z-index: 100;
  display: flex;
  align-items: stretch;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.7rem;
  font-family: inherit;
  cursor: pointer;
  padding: var(--space-xs) 0;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .15s;
}

.nav-btn span { line-height: 1; }

.nav-btn.active       { color: var(--color-primary); }
.nav-btn.active svg   { stroke: var(--color-primary); stroke-width: 2.5; }

/* ── Main ─────────────────────────────────────────────────── */
#app-main {
  height: 100%;
}

#map-container {
  width: 100%;
  height: calc(100dvh - var(--nav-height));
}

#fragment-container {
  padding: var(--space-md) var(--space-md) calc(var(--nav-height) + var(--space-md));
  max-width: 720px;
  margin: 0 auto;
}

#fragment-container[hidden] { display: none; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-sm));
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-text);
  color: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bottom sheet */
#bottom-sheet {
  position: fixed;
  bottom: var(--nav-height);
  inset-inline: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.18);
  z-index: 200;
  max-height: 70dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .25s ease;
  will-change: transform;
}

#bottom-sheet[hidden] { display: none; }

#bottom-sheet.sheet--open { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: var(--space-sm) auto;
  cursor: pointer;
}

.sheet-content { padding: var(--space-md) var(--space-md) var(--space-xl); }

/* Estabelecimento — detalhes no sheet */
.sheet-est-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.sheet-est-name {
  font-size: var(--font-size-xl);
  font-weight: 700;
  line-height: 1.2;
}

.sheet-est-category {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.sheet-est-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.sheet-est-icon { flex-shrink: 0; font-size: var(--font-size-md); }

.sheet-est-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.sheet-est-schedule p {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: 2px 0;
}

.sheet-est-coords {
  font-size: 0.75rem;
  color: var(--color-border);
  font-family: monospace;
  margin: var(--space-sm) 0;
}

.sheet-maps-btn {
  display: inline-block;
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

/* ─── Sheet grupo ─────────────────────────────────────────── */
.sheet-group-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .2s;
}
.sheet-group-card:last-child { margin-bottom: 0; }
.sheet-group-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 12px rgba(26, 115, 232, .15);
}

.sheet-group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sheet-group-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-group-grouper {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.sheet-group-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Botão voltar no sheet ───────────────────────────────── */
.sheet-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0;
  margin: 4px 0 0 0;
}
.sheet-back-btn:hover { color: var(--color-primary); }

/* Seletor de cidade flutuante sobre o mapa */
.city-selector {
  position: absolute;
  top: var(--space-sm);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 6px var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font: var(--font-size-sm)/1.5 inherit;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  min-width: 160px;
  max-width: 220px;
}

#map-container { position: relative; }

/* ─── Header flutuante sobre o mapa (mesmo padrão voaentregador) ── */
#map-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: clamp(8px, 2vw, 16px);
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,.95) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
}
#map-header > * { pointer-events: auto; }

/* ─── Search bar ──────────────────────────────────────────── */
#map-search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: clamp(10px, 2vw, 12px);
  padding: clamp(8px, 1.5vw, 10px) clamp(10px, 2vw, 14px);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  gap: 8px;
}

#map-search {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: clamp(14px, 2vw, 16px);
  color: var(--color-text);
  background: transparent;
  min-width: 0;
  padding: 0 clamp(6px, 1vw, 8px);
  -webkit-user-select: none;
  user-select: none;
}

#map-search::placeholder { color: #A0AEC0; }

.search-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 clamp(4px, 0.5vw, 6px);
  flex-shrink: 0;
}

.icon-btn {
  width: clamp(32px, 8vw, 36px);
  height: clamp(32px, 8vw, 36px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: color .2s;
  flex-shrink: 0;
}

.icon-btn:hover { color: var(--color-primary); }
.icon-btn.filter-active { color: var(--color-primary); }

.icon-btn svg {
  width: clamp(16px, 3vw, 18px);
  height: clamp(16px, 3vw, 18px);
}

#map-autocomplete {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  border: 1px solid var(--color-border);
  overflow: hidden;
  z-index: 11;
}

.ac-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background .15s;
}

.ac-row:last-child { border-bottom: none; }
.ac-row:hover { background: var(--color-background); }
.ac-row:active { background: #EBF1FB; }

.ac-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.ac-name {
  font-size: clamp(13px, 2vw, 14px);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-grouper {
  font-size: clamp(11px, 1.5vw, 12px);
  color: var(--color-text-secondary);
  margin-top: 1px;
  font-weight: 500;
}

.ac-end {
  font-size: clamp(11px, 1.5vw, 12px);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ─── Filter panel ────────────────────────────────────────── */
#filter-panel {
  position: absolute;
  top: clamp(72px, 14vw, 92px);
  right: clamp(12px, 2vw, 16px);
  z-index: 50;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
  border: 1px solid var(--color-border);
  width: clamp(220px, 80vw, 280px);
  transform-origin: top right;
  transform: scale(.9);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s cubic-bezier(.32,.72,0,1), opacity .2s ease;
}

#filter-panel.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.filter-panel-header {
  padding: clamp(10px, 2vw, 14px) clamp(12px, 2vw, 16px) clamp(8px, 1.5vw, 10px);
  font-size: clamp(10px, 1.5vw, 12px);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--color-border);
}

.filter-list { padding: clamp(6px, 1vw, 8px) 0; }

.filter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: clamp(8px, 1.5vw, 10px) clamp(12px, 2vw, 16px);
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}

.filter-item:hover { background: var(--color-background); }

.filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-label {
  flex: 1;
  font-size: clamp(12px, 2vw, 14px);
  font-weight: 500;
  color: var(--color-text);
}

.filter-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}

.filter-item.active .filter-check {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.filter-check svg {
  width: 10px;
  height: 10px;
  color: white;
  opacity: 0;
  transition: opacity .15s;
}

.filter-item.active .filter-check svg { opacity: 1; }
