/* ============================================================
   Business Directory - Town of Sylvan Lake
   Styles matching Town Map look and feel
   ============================================================ */

:root {
  /* Town of Sylvan Lake brand colours */
  --primary: #4B87C7;          /* Blue from Town Map header */
  --primary-light: #6BA3D6;
  --primary-dark: #2D5F8A;
  --accent: #E88D2A;           /* Orange from Town Map */
  --accent-light: #F5A623;
  --accent-dark: #C67318;
  --header-bg: #4B87C7;        /* Blue header background */
  --header-accent: #E88D2A;    /* Orange accents */

  /* UI colours */
  --bg: #f0f0f0;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #777777;
  --border: #cccccc;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.18);
  --radius: 4px;

  /* Layout */
  --header-height: 65px;
  --panel-width: 380px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
}

/* ============================================================
   Header — matches Town Map blue/orange bar
   ============================================================ */
.header {
  height: var(--header-height);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  padding: 0;
  z-index: 100;
  position: relative;
  overflow: hidden;
}

.header-logo-area {
  background: #ffffff;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 20px;
  min-width: var(--panel-width);
  max-width: var(--panel-width);
  border-right: 1px solid var(--border);
}

.header-logo {
  height: 45px;
}

.header-title-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow: hidden;
}

.header-title {
  color: #ffffff;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.header-help {
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 24px;
  cursor: pointer;
  text-decoration: none;
}

.header-help:hover {
  color: #ffffff;
}

/* ============================================================
   Main Layout
   ============================================================ */
.main-container {
  display: flex;
  height: calc(100vh - var(--header-height));
}

/* ============================================================
   Side Panel
   ============================================================ */
.side-panel {
  width: var(--panel-width);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}

.search-container {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  overflow: hidden;
}

.search-input-wrapper {
  position: relative;
  margin-bottom: 8px;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 2px solid #ffffff;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: #ffffff;
}

.search-input:focus {
  border-color: var(--primary);
}

.search-input::placeholder {
  color: #999999;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-dark);
  font-size: 14px;
}

.filter-row {
  display: flex;
  gap: 6px;
  align-items: center;
  max-width: 100%;
}

.filter-select {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border: 2px solid #ffffff;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-select:focus {
  border-color: var(--primary);
}

.clear-btn {
  padding: 7px 14px;
  background: var(--accent-dark);
  color: #ffffff;
  border: 2px solid var(--accent-dark);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.clear-btn:hover {
  background: #a55f10;
  border-color: #a55f10;
}

.panel-close-btn {
  display: none;
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.03em;
}

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

.results-summary {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.results-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.result-item {
  padding: 12px 14px;
  border-bottom: 1px solid #e8e8e8;
  cursor: pointer;
  transition: background 0.15s;
  border-top: 1px solid transparent;
}

.result-item:first-child {
  border-top: none;
}

.result-item:hover {
  background: #f0f5fa;
}

.result-item.active {
  background: #dce8f4;
  border-left: 4px solid var(--primary);
}

.result-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.result-type {
  font-size: 11px;
  color: var(--accent-dark);
  font-weight: 600;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.result-address {
  font-size: 12px;
  color: var(--text-light);
}

.result-home-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  background: var(--accent);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 3px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ============================================================
   Map Container
   ============================================================ */
.map-container {
  flex: 1;
  position: relative;
}

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

/* ============================================================
   Business Popup Panel
   ============================================================ */
.business-popup {
  display: none;
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 360px;
  max-height: 520px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 60;
  overflow: hidden;
  border: 2px solid var(--primary);
}

.business-popup.visible {
  display: block;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.popup-header {
  background: var(--primary);
  color: #ffffff;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.popup-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  flex: 1;
  padding-right: 10px;
}

.popup-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.popup-close:hover {
  color: #ffffff;
}

.popup-body {
  padding: 14px;
  overflow-y: auto;
  max-height: 380px;
}

.popup-field {
  margin-bottom: 10px;
}

.popup-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 1px;
}

.popup-value {
  font-size: 13px;
  color: var(--text);
}

.popup-value a {
  color: var(--primary);
  text-decoration: none;
}

.popup-value a:hover {
  text-decoration: underline;
}

.popup-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.streetview-container {
  width: 100%;
  height: 180px;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid var(--border);
}

.streetview-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 13px;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.loading-spinner {
  display: none;
  text-align: center;
  padding: 30px;
  color: var(--text-light);
}

.loading-spinner.visible {
  display: block;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px;
}

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

/* ============================================================
   Mobile Toggle Button
   ============================================================ */
.panel-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 70;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
}

.panel-toggle:hover {
  background: var(--accent-dark);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .header {
    height: 45px;
  }

  .header-logo-area {
    display: none;
  }

  .header-title {
    font-size: 18px;
  }

  .help-button {
    width: 26px;
    height: 26px;
    min-width: 26px;
    font-size: 14px;
    margin-left: 8px;
  }

  .main-container {
    height: calc(100vh - 45px);
  }

  .side-panel {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .side-panel.open {
    transform: translateX(0);
  }

  .panel-toggle {
    display: block;
  }

  .panel-close-btn {
    display: block;
  }

  .business-popup {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }

  .search-container {
    padding: 10px;
  }

  .search-input {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* ============================================================
   Esri Widget Overrides
   ============================================================ */
.esri-ui-corner .esri-component {
  box-shadow: var(--shadow);
}

/* ============================================================
   Help Button — matches Town Map style
   ============================================================ */
.help-button {
  background-color: white;
  color: #4B87C7;
  border: 2px solid white;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  margin-left: 15px;
  vertical-align: middle;
}

.help-button:hover {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ============================================================
   Help Guide — matches Town Map style
   ============================================================ */
.help-guide {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 550px;
  max-height: 90vh;
  background-color: #ffffe6;
  border: 3px solid #4B87C7;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

.help-guide.hidden {
  animation: help-fade-out 0.4s ease-in forwards;
}

@keyframes help-fade-out {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

.help-header {
  background-color: #4B87C7;
  color: white;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  padding: 12px;
  border-bottom: 3px solid var(--accent);
  flex-shrink: 0;
}

.help-close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(255,255,255,0.3);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10000;
}

.help-close-button:hover {
  background-color: var(--accent);
  transform: rotate(90deg);
}

.help-content {
  padding: 15px 20px;
  overflow-y: auto;
  max-height: calc(90vh - 100px);
  color: #333;
  font-size: 13px;
  line-height: 1.5;
}

.help-content::-webkit-scrollbar {
  width: 10px;
}

.help-content::-webkit-scrollbar-track {
  background: #e0e0d0;
  border-radius: 5px;
}

.help-content::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 5px;
  border: 2px solid #e0e0d0;
}

.help-content::-webkit-scrollbar-thumb:hover {
  background-color: #4B87C7;
}

.help-section {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #ddd;
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.help-section-title {
  font-size: 15px;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 8px;
}

.help-section p {
  margin: 5px 0;
}

.help-item {
  padding: 3px 0 3px 5px;
  margin: 3px 0;
}

.help-subitem {
  padding: 2px 0 2px 25px;
  color: #555;
  font-size: 12px;
}

.help-subitem::before {
  content: "• ";
  color: var(--accent);
}

.help-icon {
  margin-right: 6px;
}

@media screen and (max-width: 600px) {
  .help-guide {
    width: 95%;
    max-height: 85vh;
  }

  .help-header {
    font-size: 18px;
    padding: 10px;
  }

  .help-content {
    padding: 12px 15px;
    font-size: 12px;
    max-height: calc(85vh - 55px);
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
  }

  .help-content::-webkit-scrollbar {
    width: 12px;
  }

  .help-content::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: 6px;
    border: 2px solid #e0e0d0;
  }
}

/* ============================================================
   Help Guide - Do Not Show Again
   ============================================================ */
.help-donotshow {
  padding: 10px 20px 14px;
  border-top: 1px solid #ddd;
  background: #f5f5e0;
  text-align: center;
}

.help-donotshow-label {
  font-size: 13px;
  color: #666;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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