/* ===================================================================
   TournevenT Store Locator Widget — Styles
   All classes prefixed with tv- to avoid Shopify conflicts
   =================================================================== */

:root {
  --tv-primary: #2E7D32;
  --tv-primary-light: #4CAF50;
  --tv-primary-dark: #1B5E20;
  --tv-bg: #ffffff;
  --tv-bg-alt: #f5f5f5;
  --tv-text: #333333;
  --tv-text-light: #666666;
  --tv-border: #e0e0e0;
  --tv-radius: 8px;
  --tv-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Container */
#tv-store-locator {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--tv-text);
  line-height: 1.5;
  position: relative;
  width: 100%;
  min-height: 600px;
  box-sizing: border-box;
}
#tv-store-locator *, #tv-store-locator *::before, #tv-store-locator *::after {
  box-sizing: border-box;
}

/* Loading */
.tv-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  flex-direction: column;
  gap: 16px;
  color: var(--tv-text-light);
}
.tv-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--tv-border);
  border-top-color: var(--tv-primary);
  border-radius: 50%;
  animation: tv-spin 0.8s linear infinite;
}
@keyframes tv-spin {
  to { transform: rotate(360deg); }
}

/* Error */
.tv-error {
  text-align: center;
  padding: 40px 20px;
  color: #c62828;
}
.tv-error-retry {
  margin-top: 12px;
  padding: 8px 20px;
  background: var(--tv-primary);
  color: #fff;
  border: none;
  border-radius: var(--tv-radius);
  cursor: pointer;
  font-size: 14px;
}

/* Header: search + geolocate */
.tv-header {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--tv-bg);
  border-bottom: 1px solid var(--tv-border);
  flex-wrap: wrap;
}
.tv-search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.tv-search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.tv-search-input:focus {
  border-color: var(--tv-primary);
}
.tv-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tv-text-light);
  font-size: 20px;
  pointer-events: none;
}
.tv-btn-geo {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--tv-primary);
  color: #fff;
  border: none;
  border-radius: var(--tv-radius);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.2s;
}
.tv-btn-geo:hover {
  background: var(--tv-primary-dark);
}
.tv-btn-geo .material-icons {
  font-size: 18px;
}

/* Category chips */
.tv-categories {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  background: var(--tv-bg);
  border-bottom: 1px solid var(--tv-border);
  flex-wrap: wrap;
}
.tv-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--tv-border);
  background: var(--tv-bg);
  color: var(--tv-text);
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}
.tv-chip:hover {
  background: var(--tv-bg-alt);
}
.tv-chip.tv-chip-active {
  color: #fff;
  border-color: transparent;
}
.tv-chip .material-icons {
  font-size: 16px;
}
.tv-chip-count {
  font-size: 11px;
  opacity: 0.8;
  margin-left: 2px;
}

/* Main layout */
.tv-main {
  display: flex;
  height: 500px;
  position: relative;
}

/* Store list panel */
.tv-panel {
  width: 380px;
  min-width: 380px;
  overflow-y: auto;
  background: var(--tv-bg);
  border-right: 1px solid var(--tv-border);
}
.tv-panel-count {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--tv-text-light);
  background: var(--tv-bg-alt);
  border-bottom: 1px solid var(--tv-border);
}

/* Store card */
.tv-store {
  padding: 12px;
  border-bottom: 1px solid var(--tv-border);
  cursor: pointer;
  transition: background 0.15s;
}
.tv-store:hover {
  background: var(--tv-bg-alt);
}
.tv-store-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--tv-text);
}
.tv-store-addr {
  font-size: 13px;
  color: var(--tv-text-light);
  margin-bottom: 4px;
}
.tv-store-phone {
  font-size: 13px;
  color: var(--tv-text-light);
}
.tv-store-phone a {
  color: var(--tv-primary);
  text-decoration: none;
}
.tv-store-dist {
  font-size: 12px;
  color: var(--tv-primary);
  font-weight: 500;
  margin-top: 4px;
}
.tv-store-types {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.tv-store-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  color: #fff;
}
.tv-store-type-badge .material-icons {
  font-size: 13px;
}
.tv-store-actions {
  margin-top: 8px;
}
.tv-btn-directions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--tv-primary);
  background: none;
  border: 1px solid var(--tv-primary);
  border-radius: var(--tv-radius);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.tv-btn-directions:hover {
  background: var(--tv-primary);
  color: #fff;
}
.tv-btn-directions .material-icons {
  font-size: 15px;
}

/* Map */
.tv-map {
  flex: 1;
  min-height: 300px;
}

/* Empty state */
.tv-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--tv-text-light);
  font-size: 14px;
  height: 100%;
}

/* Leaflet popup override */
.tv-popup .leaflet-popup-content-wrapper {
  border-radius: var(--tv-radius);
  padding: 0;
}
.tv-popup .leaflet-popup-content {
  margin: 12px;
  font-size: 13px;
  line-height: 1.4;
}
.tv-popup-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.tv-popup-addr {
  color: var(--tv-text-light);
  margin-bottom: 6px;
}
.tv-popup-link {
  color: var(--tv-primary);
  text-decoration: none;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ===================================================================
   Responsive — mobile (<768px): stack layout
   =================================================================== */
@media (max-width: 767px) {
  .tv-main {
    flex-direction: column;
    height: auto;
  }
  .tv-panel {
    width: 100%;
    min-width: 100%;
    max-height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--tv-border);
    order: 2;
  }
  .tv-map {
    height: 350px;
    order: 1;
  }
  .tv-header {
    flex-direction: column;
  }
  .tv-categories {
    flex-wrap: nowrap;
  }
}
