/* HAP Store Locator Frontend Styles
 * =========================================
 * A clean, modern design matching HAP Daily brand
 * Font: Manrope | Primary: #35676D | Accent: #F05023
 */

/* =========================================
   CSS Custom Properties
   ========================================= */
.hap-store-locator {
  --hap-primary: #35676D;
  --hap-primary-light: #4a8a91;
  --hap-primary-dark: #2a5257;
  --hap-accent: #F05023;
  --hap-accent-hover: #d84520;
  --hap-olive: #616C52;
  --hap-olive-light: #7a8768;
  --hap-cream: #fff8f3;
  --hap-cream-dark: #f3e6db;
  --hap-text: #35676D;
  --hap-text-muted: #5c8a90;
  --hap-border: rgba(53, 103, 109, 0.2);
  --hap-shadow: rgba(53, 103, 109, 0.12);
  --hap-radius: 0.75rem;
  --hap-radius-lg: 1rem;
  --hap-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  width: 100%;
  font-family: 'Manrope', sans-serif;
}

/* =========================================
   Form Layout
   ========================================= */
.store-locator-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  text-align: left;
  align-items: flex-end;
  margin-bottom: 2rem;
}

.store-locator-form .form-row {
  flex: 1 1 200px;
  min-width: 0;
  margin-bottom: 0;
}

.store-locator-form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--hap-primary);
  letter-spacing: 0.01em;
}

/* =========================================
   Select Dropdown Styling
   ========================================= */
.store-locator-form .hap-select {
  width: 100%;
  padding:.5rem;
  border: 2px solid var(--hap-border);
  border-radius: var(--hap-radius);
  background-color: white;
  color: var(--hap-text);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--hap-transition);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2335676D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 3rem;
}

.store-locator-form .hap-select:hover {
  border-color: var(--hap-primary);
}

.store-locator-form .hap-select:focus {
  outline: none;
  border-color: var(--hap-primary);
  box-shadow: 0 0 0 3px rgba(53, 103, 109, 0.15);
}

/* =========================================
   Search Button
   ========================================= */
.store-locator-form .hap-button {
  width: 100%;
  background: linear-gradient(135deg, var(--hap-primary) 0%, var(--hap-primary-dark) 100%);
  color: white;
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: var(--hap-radius);
  cursor: pointer;
  transition: all var(--hap-transition);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px var(--hap-shadow);
}

.store-locator-form .hap-button:hover {
  background: linear-gradient(135deg, var(--hap-accent) 0%, var(--hap-accent-hover) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(240, 80, 35, 0.25);
}

.store-locator-form .hap-button:active {
  transform: translateY(0);
}

/* =========================================
   Results Container
   ========================================= */
.store-results-container {
  width: 100%;
  margin-top: 1.5rem;
  display: none; /* Hidden by default until search is initiated */
}

.store-results-container.is-visible {
  display: block;
}

/* =========================================
   Desktop Table View
   ========================================= */
.store-results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--hap-radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px var(--hap-shadow);
}

.store-results-table thead tr {
  background: linear-gradient(135deg, var(--hap-primary) 0%, var(--hap-primary-dark) 100%);
  color: white;
}

.store-results-table th {
  padding: 1rem 0.875rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: none;
}

.store-results-table th:first-child {
  border-top-left-radius: var(--hap-radius-lg);
}

.store-results-table th:last-child {
  border-top-right-radius: var(--hap-radius-lg);
}

.store-results-table td {
  padding: 1rem 0.875rem;
  text-align: left;
  border-bottom: 1px solid var(--hap-border);
  font-size: 0.9375rem;
  color: var(--hap-text);
}

.store-results-table tbody tr {
  background-color: white;
  transition: background-color var(--hap-transition);
}

.store-results-table tbody tr:nth-child(even) {
  background-color: var(--hap-cream);
}

.store-results-table tbody tr:hover {
  background-color: rgba(53, 103, 109, 0.06);
}

.store-results-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--hap-radius-lg);
}

.store-results-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--hap-radius-lg);
}

.store-results-table .text-center {
  text-align: center;
}

/* View on Map Link - Desktop */
.store-results-table .selectedLocation {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  color: var(--hap-olive);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8125rem;
  margin-left: 0.5rem;
  padding: 0.375rem 0.625rem;
  background-color: rgba(97, 108, 82, 0.1);
  border-radius: 0.375rem;
  transition: all var(--hap-transition);
}

.store-results-table .selectedLocation:hover {
  background-color: var(--hap-olive);
  color: white;
}

/* =========================================
   Mobile Responsive Design
   ========================================= */
@media (max-width: 768px) {
  .store-locator-form {
    flex-direction: column;
    gap: 1rem;
    background: white;
    padding: 1.25rem;
    border-radius: var(--hap-radius-lg);
    box-shadow: 0 4px 20px var(--hap-shadow);
  }

  .store-locator-form .form-row {
    width: 100%;
    flex: none;
  }

  .store-locator-form label {
    font-size: 0.8125rem;
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .store-locator-form .hap-select {
    padding: .5rem .75rem;
    padding-right: 3rem;
    font-size: 16px; /* Prevents iOS zoom on focus */
    border-radius: var(--hap-radius);
    background-color: var(--hap-cream);
    border: 2px solid transparent;
  }

  .store-locator-form .hap-select:focus {
    background-color: white;
    border-color: var(--hap-primary);
  }

  .store-locator-form .hap-button {
    padding: .5rem 1rem;
    font-size: 16px;
    margin-top: 0.5rem;
    border-radius: var(--hap-radius);
  }

  /* Mobile Results Container */
  .store-results-container {
    overflow-x: visible;
    max-height: none;
    margin-top: 1.5rem;
  }

  /* Convert table to block layout */
  .store-results-table,
  .store-results-table thead,
  .store-results-table tbody,
  .store-results-table th,
  .store-results-table td,
  .store-results-table tr {
    display: block;
  }

  .store-results-table {
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .store-results-table thead {
    display: none;
  }

  /* Store Card Design */
  .store-results-table tbody tr {
    background: white;
    border-radius: var(--hap-radius-lg);
    margin-bottom: 1rem;
    padding: 0;
    box-shadow: 0 2px 16px var(--hap-shadow);
    overflow: hidden;
    border: none;
  }

  .store-results-table tbody tr:nth-child(even) {
    background-color: white;
  }

  .store-results-table tbody tr:hover {
    background-color: white;
  }

  /* Hide serial number and shop name on mobile */
  .store-results-table td:first-child,
  .store-results-table td[data-label="Shop Name"] {
    display: none !important;
  }

  /* Card Cell Styling */
  .store-results-table td {
    border: none;
    padding: 0;
    position: relative;
    text-align: left;
    display: block;
    font-size: 0.9375rem;
    border-bottom: 1px solid rgba(53, 103, 109, 0.08);
  }

  .store-results-table td:last-child {
    border-bottom: none;
  }

  /* Parlor Name - Hero Header */
  .store-results-table td[data-label="Parlor Name"] {
    display: block !important;
    background: linear-gradient(135deg, var(--hap-primary) 0%, var(--hap-primary-dark) 100%);
    color: white;
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: 0.01em;
    border-bottom: none;
  }

  .store-results-table td[data-label="Parlor Name"]:before {
    display: none;
  }

  /* If parlor name is empty, show "HAP Daily" as fallback */
  .store-results-table td[data-label="Parlor Name"]:empty {
    display: block !important;
  }

  .store-results-table td[data-label="Parlor Name"]:empty:after {
    content: "HAP Daily";
  }

  /* Regular Data Cells */
  .store-results-table td[data-label="Address"],
  .store-results-table td[data-label="Location"],
  .store-results-table td[data-label="City"],
  .store-results-table td[data-label="Phone"],
  .store-results-table td[data-label="Contact Person"] {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
  }

  .store-results-table td[data-label="Address"]:before,
  .store-results-table td[data-label="Location"]:before,
  .store-results-table td[data-label="City"]:before,
  .store-results-table td[data-label="Phone"]:before,
  .store-results-table td[data-label="Contact Person"]:before {
    content: attr(data-label);
    flex-shrink: 0;
    width: 5.5rem;
    font-weight: 700;
    color: var(--hap-text-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-top: 0.125rem;
  }

  /* Address gets more prominence */
  .store-results-table td[data-label="Address"] {
    background: rgba(53, 103, 109, 0.02);
    color: var(--hap-text);
    line-height: 1.5;
  }

  /* Phone number styling */
  .store-results-table td[data-label="Phone"] {
    font-weight: 600;
    color: var(--hap-primary);
  }

  /* Contact Person with Map Button */
  .store-results-table td[data-label="Contact Person"] {
    flex-wrap: wrap;
    padding-bottom: 1rem;
  }

  /* View on Map Button - Mobile */
  .store-results-table .selectedLocation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: calc(100% + 2.5rem);
    margin: 0.875rem -1.25rem -1rem;
    padding: 0.5rem .5rem;
    background: linear-gradient(135deg, var(--hap-olive) 0%, var(--hap-olive-light) 100%);
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    border-radius: 0;
    transition: all var(--hap-transition);
  }

  .store-results-table .selectedLocation:before {
    content: '';
    width: 1rem;
    height: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'%3E%3C/path%3E%3Ccircle cx='12' cy='10' r='3'%3E%3C/circle%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
  }

  .store-results-table .selectedLocation:hover,
  .store-results-table .selectedLocation:active {
    background: linear-gradient(135deg, var(--hap-accent) 0%, var(--hap-accent-hover) 100%);
    color: white;
  }

  /* Placeholder/Message Row */
  .store-results-table tbody tr.store-placeholder,
  .store-results-table tbody tr.tab-body:only-child {
    text-align: center;
    background: white;
  }

  .store-results-table tbody tr.store-placeholder td,
  .store-results-table tbody tr td[colspan] {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
    font-size: 0.9375rem;
    color: var(--hap-text-muted);
    font-weight: 500;
    background: white;
    min-height: 120px;
  }

  .store-results-table tbody tr.store-placeholder td:before,
  .store-results-table tbody tr td[colspan]:before {
    content: '';
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='none' stroke='%2335676D' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
  }

  /* No Records State */
  .store-results-table tbody tr.tab-body:only-child td {
    color: var(--hap-text-muted);
  }
}

/* =========================================
   Small Mobile Adjustments (< 400px)
   ========================================= */
@media (max-width: 400px) {
  .store-locator-form {
    padding: 1rem;
  }

  .store-locator-form .hap-select {
    padding: .5rem;
    padding-right: 2.5rem;
  }

  .store-results-table td[data-label="Address"]:before,
  .store-results-table td[data-label="Location"]:before,
  .store-results-table td[data-label="City"]:before,
  .store-results-table td[data-label="Phone"]:before,
  .store-results-table td[data-label="Contact Person"]:before {
    width: 4.5rem;
    font-size: 0.625rem;
  }

  .store-results-table td[data-label="Parlor Name"] {
    padding: 0.5rem 1rem;
    font-size: 1rem;
  }

  .store-results-table td[data-label="Address"],
  .store-results-table td[data-label="Location"],
  .store-results-table td[data-label="City"],
  .store-results-table td[data-label="Phone"],
  .store-results-table td[data-label="Contact Person"] {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .store-results-table .selectedLocation {
    width: calc(100% + 2rem);
    margin: 0.75rem -1rem -0.75rem;
    padding: 0.75rem;
    font-size: 0.8125rem;
  }
}

/* =========================================
   Desktop Scrollable Container
   ========================================= */
@media (min-width: 769px) {
  .store-results-container {
    overflow-x: auto;
    max-height: 450px;
    overflow-y: auto;
    border-radius: var(--hap-radius-lg);
  }

  /* Custom Scrollbar */
  .store-results-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  .store-results-container::-webkit-scrollbar-track {
    background: var(--hap-cream);
    border-radius: 4px;
  }

  .store-results-container::-webkit-scrollbar-thumb {
    background: var(--hap-primary);
    border-radius: 4px;
  }

  .store-results-container::-webkit-scrollbar-thumb:hover {
    background: var(--hap-primary-dark);
  }

  /* Sticky Header */
  .store-results-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
  }
}

/* =========================================
   Loading Animation
   ========================================= */
@keyframes hap-pulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

.store-results-table tbody tr.store-placeholder td:has(:contains("Loading")) {
  animation: hap-pulse 1.5s ease-in-out infinite;
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
  .store-locator-form {
    display: none;
  }

  .store-results-table {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .store-results-table thead tr {
    background: #35676D !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
