/* =========================================
   Design Tokens
   ========================================= */
:root {
  --primary: #2f39d0;
  --primary-dark: #2330b8;
  --success: #0f9e6e;
  --error: #e24b4a;
  --bg: #f8f9fc;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1a1a2e;
  --muted: #6b7280;
  --header-bg: #12122a;
  --footer-bg: #12122a;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --header-h: 56px;
  --footer-h: 38px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 13px;
  line-height: 1.5;
}

/* =========================================
   Header
   ========================================= */
.header {
  background: var(--header-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: var(--header-h);
  flex-shrink: 0;
  z-index: 200;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  height: 36px;
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.header-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

.app-tool-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
}

.app-tagline {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 4px 11px;
  white-space: nowrap;
}

/* =========================================
   Main — full-screen two-column
   ========================================= */
.main {
  display: flex;
  height: calc(100vh - var(--header-h) - var(--footer-h));
}

/* ── Map column ──────────────────────── */
.map-col {
  flex: 0 0 70%;
  position: relative;
  background: #e8eaed;
}

#map {
  width: 100%;
  height: 100%;
}

/* Hint bar on top of map */
.map-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18,18,42,0.82);
  color: #fff;
  font-size: 11.5px;
  padding: 5px 14px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

/* API key overlay */
.map-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18,18,42,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(6px);
}

.map-overlay.hidden { display: none; }

.api-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px 36px;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.api-card-icon { font-size: 36px; margin-bottom: 12px; }
.api-card h3   { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.api-card p    { font-size: 13.5px; color: var(--muted); line-height: 1.65; margin-bottom: 16px; }

.api-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.api-note {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 0 !important;
}

/* ── Controls column ─────────────────── */
.controls-col {
  flex: 0 0 30%;
  overflow-y: auto;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* =========================================
   Panel Sections
   ========================================= */
.panel-section {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-section:last-child { border-bottom: none; }

.section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.field-group { margin-bottom: 10px; }
.field-group:last-child { margin-bottom: 0; }

/* =========================================
   Inputs
   ========================================= */
.input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47,57,208,0.1);
}

.input::placeholder { color: #b8bec8; }

.select-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 01.753 1.659l-4.796 5.48a1 1 0 01-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}

.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47,57,208,0.1);
}

.textarea::placeholder { color: #b8bec8; }

/* Auto-generate button */
.auto-btn {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  letter-spacing: 0.03em;
  transition: background 0.15s;
  flex-shrink: 0;
}

.auto-btn:hover { background: var(--primary-dark); }

/* =========================================
   Search
   ========================================= */
.search-row {
  display: flex;
  gap: 7px;
}

.search-row .input { flex: 1; }

.search-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}

.search-dropdown.hidden { display: none; }

.search-result {
  padding: 8px 11px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg); }

/* =========================================
   Category hint
   ========================================= */
.category-hint {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--primary);
  background: rgba(47,57,208,0.06);
  border-radius: 4px;
  padding: 5px 8px;
  line-height: 1.4;
}

.category-hint.hidden { display: none; }

/* =========================================
   Coordinates
   ========================================= */
.coord-row {
  display: flex;
  gap: 8px;
}

.coord-field { flex: 1; }

.location-label {
  font-size: 11.5px;
  color: var(--primary);
  margin-top: 5px;
  font-weight: 500;
  min-height: 0;
}

/* =========================================
   Drop Zone
   ========================================= */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--muted);
  background: var(--surface);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(47,57,208,0.03);
  color: var(--primary);
}

.drop-zone svg {
  margin-bottom: 7px;
  opacity: 0.45;
}

.drop-zone p {
  font-size: 12.5px;
  line-height: 1.55;
}

.drop-zone-sm { padding: 12px; }
.drop-zone-sm p { font-size: 12px; }
.drop-zone-sm svg { margin-bottom: 5px; }

.format-note {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.65;
}

.muted { color: var(--muted); }

/* =========================================
   Thumbnail Strip
   ========================================= */
.thumbnail-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.thumb-item {
  position: relative;
  width: 64px;
  height: 64px;
  cursor: pointer;
  flex-shrink: 0;
}

.thumb-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 5px;
  border: 2px solid transparent;
  display: block;
  transition: border-color 0.15s;
}

.thumb-item.active .thumb-img { border-color: var(--primary); }

.thumb-check {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  pointer-events: none;
}

.thumb-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  background: var(--error);
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.1s;
}

.thumb-remove:hover { transform: scale(1.15); }

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  outline: none;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) { background: var(--bg); }

/* =========================================
   Action Bar
   ========================================= */
.apply-all-row { margin-bottom: 9px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--primary);
}

.action-buttons {
  display: flex;
  gap: 7px;
  margin-bottom: 8px;
}

.zip-row { margin-bottom: 6px; }
.zip-row.hidden { display: none; }

.zip-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--primary);
  font-size: 12.5px;
  text-decoration: none;
  font-weight: 500;
}

.zip-link:hover { text-decoration: underline; }

.usage-row { margin-top: 6px; }
.usage-text { font-size: 11.5px; color: var(--muted); }

.limit-warning {
  font-size: 11.5px;
  color: var(--error);
  margin-top: 5px;
  font-weight: 500;
}

.limit-warning.hidden { display: none; }

/* =========================================
   Clear section
   ========================================= */
.clear-section { padding: 10px 16px; }

.clear-link {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.15s;
}

.clear-link:hover { color: var(--error); text-decoration: underline; }

/* =========================================
   WebP Converter
   ========================================= */
.webp-quality-row { margin-top: 8px; }

.quality-slider {
  width: 100%;
  margin-top: 4px;
  accent-color: var(--primary);
  cursor: pointer;
}

.webp-queue {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.webp-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.webp-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.webp-info { flex: 1; min-width: 0; }

.webp-name {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.webp-size { font-size: 11px; color: var(--muted); margin-top: 2px; }
.webp-size .size-saving { color: var(--success); font-weight: 600; }
.webp-converting { font-style: italic; }

.webp-dl-btn {
  flex-shrink: 0;
  padding: 4px 9px;
  font-size: 11.5px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
  transition: background 0.15s;
}

.webp-dl-btn:hover { background: var(--primary-dark); }
.webp-dl-btn:disabled { background: var(--border); color: var(--muted); cursor: default; }

/* =========================================
   Toast
   ========================================= */
.toast-container {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  pointer-events: auto;
  max-width: 300px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }
.toast.info    { background: var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateX(16px); }
}

.toast.removing { animation: toastOut 0.2s ease forwards; }

/* =========================================
   Modal
   ========================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px 30px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 9px; }
.modal-body  { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; line-height: 1.6; }

/* =========================================
   Loading state
   ========================================= */
.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   Footer
   ========================================= */
.footer {
  background: var(--footer-bg);
  color: rgba(255,255,255,0.45);
  height: var(--footer-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  flex-shrink: 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  flex-wrap: wrap;
}

.footer-brand strong { color: rgba(255,255,255,0.85); }
.footer a { color: rgba(255,255,255,0.6); text-decoration: none; }
.footer a:hover { color: #fff; }
.footer-sep { opacity: 0.25; }

/* =========================================
   Google Maps overrides
   ========================================= */
/* Keep Google Maps UI clean */
.gm-style-iw-d { max-height: 200px !important; }
.gm-ui-hover-effect { display: none !important; }

.place-infowindow { font-family: var(--font) !important; }
.place-infowindow h4 { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.place-infowindow p  { font-size: 11.5px; color: #555; margin: 2px 0; }
.place-infowindow .use-btn {
  margin-top: 7px;
  padding: 4px 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
}

/* =========================================
   Mobile
   ========================================= */
@media (max-width: 768px) {
  html, body { overflow: auto; }

  .main {
    flex-direction: column;
    height: auto;
  }

  .map-col {
    flex: none;
    height: 280px;
    width: 100%;
  }

  #map { height: 280px; }

  .controls-col {
    flex: none;
    width: 100%;
    overflow-y: visible;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .header { padding: 0 12px; }
  .app-tagline { display: none; }
  .header-logo { height: 28px; }

  .footer {
    height: auto;
    padding: 10px 14px;
  }

  .footer-inner { gap: 6px; }
}
