/**
 * AbbVie Find a Pharmacy - Frontend Styles
 * Version 2.0.1 - Updated layout system
 */

/* CSS Custom Properties for consistent theming */
:root {
  --afap-primary-color: #e65400;
  --afap-secondary-color: #f5f5f5;
  --afap-text-color: #333;
  --afap-border-color: #ddd;
  --afap-success-color: #28a745;
  --afap-error-color: #dc3545;
  --afap-warning-color: #ffc107;
  --afap-info-color: #76bd22;
  --afap-shadow: 0 2px 4px rgba(0,0,0,0.1);
  --afap-border-radius: 4px;
  --afap-transition: all 0.3s ease;
  --afap-font-family: "DIN Next LT Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Container Styles */
.afap-container {
  max-width: 100%;
  margin: 0 auto;
  font-family: var(--afap-font-family) !important;
}

/* .afap-pharmacy-finder {
  margin: 20px 0;
} */

/* .afap-search-section {
  margin-bottom: 20px;
} */

.afap-results-wrapper {
  display: flex;
  flex-direction: row;
  gap: 20px;
}

.afap-pharmacy-finder.layout-sidebar .afap-results-wrapper {
  display: grid !important;
  grid-template-columns: 33% 67% !important;
  gap: 20px;
  align-items: start;
}

/* List only layout */
.afap-pharmacy-finder.layout-list-only .afap-results-wrapper {
  display: block !important;
}

.afap-pharmacy-finder.layout-list-only .afap-list-section {
  width: 100%;
  height: auto;
  /* max-height: 80vh; */
  /* overflow-y: auto; */
}

/* Map only layout */
.afap-pharmacy-finder.layout-map-only .afap-results-wrapper {
  display: block !important;
}

.afap-pharmacy-finder.layout-map-only .afap-map-section {
  width: 100%;
  height: 80vh;
}

/* Search only layout */
.afap-pharmacy-finder.layout-search-only .afap-results-wrapper {
  display: none;
}

@media (max-width: 992px) {
  .afap-pharmacy-finder.layout-sidebar .afap-results-wrapper {
    grid-template-columns: 100%;
  }
  
  .afap-pharmacy-finder.layout-map-only .afap-map-section,
  .afap-pharmacy-finder.layout-sidebar .afap-map-section {
    width: 100%;
  }
}

.afap-list-section {
  border-top: 10px solid var(--afap-secondary-color);
  border-bottom: 10px solid var(--afap-secondary-color);
  border-radius: 5px;
  margin-bottom: 20px;
  height: auto;
  max-height: 80vh;
}

@media (max-width: 992px) {
  .afap-list-section {
    max-height: 50vh;
  }
}

.afap-map-section {
  height: 80vh;
  width: 67%;
}

.afap-map-container {
  position: sticky;
  top: 20px;
  height: 100%;
}

/* Search Form Styles */
.afap-search-form {
  background: #fff;
  padding: 20px;
  border-radius: var(--afap-border-radius);
  box-shadow: var(--afap-shadow);
  /* margin-bottom: 20px; */
}

.afap-search-form .form-group {
  margin-bottom: 15px;
}

.afap-search-form label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: var(--afap-primary-color);
  text-transform: none;
}

.afap-search-form input[type="text"],
.afap-search-form input[type="search"],
.afap-search-form select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--afap-border-color);
  border-radius: var(--afap-border-radius);
  font-size: 14px;
  transition: var(--afap-transition);
  box-sizing: border-box;
}

.afap-search-form input:focus,
.afap-search-form select:focus {
  outline: none;
  border-color: var(--afap-primary-color);
  box-shadow: 0 0 0 2px rgba(230, 84, 0, 0.1);
}

.afap-search-form .form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

@media (max-width: 576px) {
  .afap-search-form .form-row {
    grid-template-columns: 1fr;
  }
}

.afap-search-form .btn {
  padding: 13px 24px;
  background: var(--afap-primary-color);
  color: white;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--afap-transition);
  white-space: nowrap;
}

.afap-search-form .btn:hover {
  background: #d14800;
}

.afap-search-form .btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.afap-search-form .btn-secondary {
  background: var(--afap-secondary-color);
  color: var(--afap-text-color);
}

.afap-search-form .btn-secondary:hover {
  background: #e0e0e0;
}

/* Location List Styles */
.afap-location-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background-color: var(--afap-secondary-color);
  border-radius: var(--afap-border-radius);
  height: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--afap-shadow);
}

/* Custom scrollbar for location list */
.afap-location-list::-webkit-scrollbar {
  width: 8px;
}

.afap-location-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.afap-location-list::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.afap-location-list::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.afap-location-item {
  background: white;
  margin: 10px;
  padding: 20px;
  border-radius: var(--afap-border-radius);
  box-shadow: var(--afap-shadow);
  transition: var(--afap-transition);
  cursor: pointer;
}

.afap-location-list > .afap-location-item {
  margin-top: 0;
}

.afap-location-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.afap-location-item.selected {
  border-left: 4px solid var(--afap-info-color);
}

.afap-location-name {
  font-family: var(--afap-font-family);
  text-transform: uppercase;
  margin: 0 0 10px 0;
  font-stretch: condensed;
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--afap-text-color);
  cursor: pointer;
}

.afap-location-address {
  margin-bottom: 10px;
  text-transform: uppercase;
}

.afap-location-address p {
  font-size: inherit;
  margin-bottom: 5px;
  line-height: 1.4;
  margin-top: 8px;
  font-size: 14px;
  color: #666;
}

.afap-location-address .afap-phone {
  margin-top: 8px;
  font-size: 14px;
  color: #666;
}

.afap-location-address .afap-phone a {
  color: var(--afap-primary-color);
  text-decoration: none;
  font-weight: 500;
}

.afap-location-address .afap-phone a:hover {
  text-decoration: underline;
}

.afap-location-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--afap-border-color);
}

.afap-distance {
  font-weight: 600;
  color: var(--afap-primary-color);
  font-size: 14px;
}

.afap-status {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.afap-status-open {
  background: rgba(40, 167, 69, 0.1);
  color: var(--afap-success-color);
}

.afap-status-closed {
  background: rgba(220, 53, 69, 0.1);
  color: var(--afap-error-color);
}

.afap-actions {
  display: flex;
  gap: 8px;
}

.afap-action-btn {
  padding: 8px 12px 6px;
  background: var(--afap-primary-color);
  color: white;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: var(--afap-transition);
}

.afap-action-btn:hover {
  background: #d14800;
  color: white;
  text-decoration: none;
}

.afap-action-btn.secondary {
  background: var(--afap-info-color);
}

.afap-action-btn.secondary:hover {
  background: #649f1c;
}

/* Map Styles */
.afap-map-container {
  background: white;
  border-radius: var(--afap-border-radius);
  overflow: hidden;
  box-shadow: var(--afap-shadow);
  height: 100%;
}

.afap-map-container iframe,
.afap-map-container #afap-map {
  width: 100%;
  height: 100%;
  min-height: 400px;
  border: none;
}

@media (max-width: 992px) {
  .afap-map-section {
    height: 60vh !important;
  }
  
  .afap-map-container iframe,
  .afap-map-container #afap-map {
    height: 60vh;
    min-height: 300px;
  }
}

/* Map Info Window Styles */
.afap-info-window {
  max-width: 300px;
}

.afap-info-window h4 {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--afap-text-color);
}

.afap-info-window p {
  margin: 5px 0;
  font-size: 14px;
  color: #666;
}

.afap-info-window a {
  color: var(--afap-primary-color);
  text-decoration: none;
  outline: none !important;
  border: none !important;
}

.afap-info-window a:hover {
  text-decoration: underline;
  outline: none !important;
  border: none !important;
}

.afap-info-window a:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.afap-info-window a:active {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.afap-info-window .afap-directions-link {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 12px 6px;
  background-color: var(--afap-primary-color);
  color: #fff !important;
  font-weight: 600;
  text-decoration: none !important;
  transition: var(--afap-transition);
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.afap-info-window .afap-directions-link:hover {
  background-color: #cc4a00;
  text-decoration: none !important;
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.afap-info-window .afap-directions-link:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.afap-info-window .afap-directions-link:active {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.afap-info-window .afap-location-name {
  margin-bottom: 8px;
  font-size: 16px;
}

.afap-info-window .afap-location-address {
  margin-bottom: 10px;
  font-size: 14px;
}

.afap-info-window .afap-actions {
  justify-content: center;
}

/* Loading States */
.afap-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  font-size: 16px;
  color: #666;
}

.afap-loading::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--afap-primary-color);
  border-radius: 50%;
  margin-right: 10px;
  animation: afap-spin 1s linear infinite;
}

@keyframes afap-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error States */
.afap-error {
  background: rgba(220, 53, 69, 0.1);
  color: var(--afap-error-color);
  padding: 15px;
  border-radius: var(--afap-border-radius);
  border-left: 4px solid var(--afap-error-color);
  margin: 20px 0;
  font-size: 12px;
  font-weight: 600;
}

.afap-no-results {
  text-align: center;
  padding: 40px;
  color: #666;
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* .afap-location-meta {
    flex-direction: column;
    align-items: flex-start;
  } */
  
  /* .afap-actions {
    width: 100%;
    justify-content: center;
  } */
  
  .afap-search-form .form-row {
    grid-template-columns: 1fr;
  }
  
  .afap-search-form .btn {
    width: 100%;
  }
}

/* Accessibility */
.afap-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for keyboard navigation */
.afap-location-item:focus,
.afap-action-btn:focus,
.afap-search-form input:focus,
.afap-search-form select:focus,
.afap-search-form .btn:focus {
  outline: 2px solid var(--afap-primary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --afap-shadow: 0 2px 4px rgba(0,0,0,0.3);
    --afap-border-color: #000;
  }
  
  .afap-location-item {
    border: 1px solid var(--afap-border-color);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 992px) {
  .fap-location-list {
    height: 50vh;
    margin-bottom: 20px;
  }
}

.fap-location-list li {
  margin: 0;
  border-bottom: 1px solid #939295;
  padding-top: 10px;
  padding-bottom: 10px;
}

.fap-location-list .fap-location-name {
  text-transform: uppercase !important;
  font-stretch: condensed;
  font-weight: 600;
}

.fap-location-list .fap-location-address {
  position: relative;
  padding-right: 30px;
  font-size: 1rem;
}

.fap-location-list .fap-location-address p {
  font-size: 1rem;
  text-transform: uppercase;
}

.fap-location-list .fap-location-address .fap-location-distance {
  position: absolute;
  right: 0;
  top: 0;
}

.fap-location-list .fap-location-address .fap-location-directions {
  position: relative;
  text-decoration: none;
  font-size: 1rem;
  padding-left: 40px;
  height: 30px;
  display: flex;
  align-items: center;
}

.fap-location-address a.fap-location-directions {
  text-decoration: underline;
  outline: 0;
}

.fap-location-list .fap-location-address .fap-location-directions:before {
  content: "→";
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 27px;
  height: 28px;
  color: #fff;
  font-weight: 800;
  z-index: 1;
  left: 0;
  top: 0;
}

.fap-location-list .fap-location-address .fap-location-directions:after {
  content: "";
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 21px;
  height: 21px;
  margin: 2px;
  background-color: #76bd22;
  transform: rotate(45deg);
  z-index: 0;
  left: 0;
  top: 0;
  border-radius: 3px;
}

.fap-find-location-btn {
  display: flex !important;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0.4rem 3rem;
  font-size: calc(1.255rem + 0.06vw);
  font-weight: 600;
  line-height: 1.5;
  background-color: transparent;
  border-width: 2px;
  border-radius: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 1px 1px rgba(0, 0, 0, 0.075);
  font-stretch: condensed;
  color: #e65400;
  user-select: none;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  border: 2px solid #e65400;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out,
    -webkit-box-shadow 0.15s ease-in-out;
  white-space: nowrap !important;
  text-transform: uppercase !important;
  width: 100%;
  box-sizing: border-box;
  outline: none !important;
}

.fap-find-location-btn:active {
  color: #fff;
  background-color: #e65400;
  border-color: #e65400;
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
  outline: none;
}

.fap-find-location-btn:first-child:active {
  color: #000;
  background-color: #e65400;
  border-color: #e65400;
  outline: none;
}

.fap-find-location-btn:focus,
.fap-find-location-btn:active {
  outline: none !important;
  box-shadow: none !important;
}

.fap-find-location-btn:focus-visible {
  color: #000;
  background-color: #e65400;
  border-color: #e65400;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(230, 84, 0, 0.5);
  -webkit-box-shadow: 0 0 0 0.25rem rgba(230, 84, 0, 0.5);
}

.fap-find-location-btn:focus:not(:focus-visible) {
  outline: 0;
}

.fap-find-location-btn:hover {
  color: #fff;
  text-decoration: none;
  background-color: #e65400;
  border-color: #e65400;
}

.fap-find-location-btn:not(:disabled) {
  cursor: pointer;
}

.fap-find-location-btn:disabled {
  opacity: 0.65;
  color: #e65400;
  pointer-events: none;
  background-color: transparent;
  border-color: #e65400;
}

.fap-find-location-btn:focus {
  box-shadow: 0 0 0 0.25rem rgba(230, 84, 0, 0.5);
}

.fap-find-location-btn i {
  margin-bottom: 5px;
}

.fap-error-msg {
  display: none;
  color: rgba(252, 77, 89) !important;
  font-weight: 500 !important;
}

.fap-find-location-btn-icon {
  margin-bottom: 4px;
}

.fap-form-label {
  margin-bottom: 0.5rem;
  display: inline-block;
  cursor: default;
}

.fap-row {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-right: -15px;
  margin-left: -15px;
}

.fap-row > * {
  max-width: 100%;
  padding-right: calc(1.25rem * 0.5);
  padding-left: calc(1.25rem * 0.5);
  margin-top: 0;
}

@media (min-width: 992px) {
  .fap-col-md {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    flex-basis: 0;
    flex-grow: 1;
    min-width: 0;
    max-width: 100%;
  }

  .fap-col-md-4 {
    position: relative;
    padding-right: 15px;
    padding-left: 15px;
    flex: 0 0 auto !important;
    width: 33.333%;
    max-width: 33.333333% !important;
  }
}

@media (max-width: 575px) {
  .fap-col-md,
  .fap-col-md-4 {
    flex: 1 1 100% !important;
    max-width: 100%;
  }
}

.fap-col-12 {
  position: relative;
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  -ms-flex: 1 0 0%;
  flex: 1 0 0%;
  max-width: 100%;
}

.fap-mb-2 {
  margin-bottom: 1.25rem !important;
}

.fap-form-control {
  margin: 0;
  font-family: inherit;
  box-sizing: border-box;
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #f4f4f4;
  appearance: none;
  background-color: #f4f4f4;
  background-clip: padding-box;
  border: 2px solid #f4f4f4;
  min-height: 50px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out,
    -webkit-box-shadow 0.15s ease-in-out;
}

.fap-form-control:focus {
  color: #495057;
  background-color: #fff;
  border-color: #80bdff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
