/* ==========================================================================
   GWA Custom Search Widget Styles
   Prefix: gwa-cs-
   Note: All base styles have low CSS specificity (0,1,0) so Elementor
   generated controls (0,2,0) cleanly override them without !important.
   ========================================================================== */

/* Main Wrapper */
.gwa-cs-wrapper {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  margin: 0;
  padding: 0;
}

.gwa-cs-wrapper *,
.gwa-cs-wrapper *::before,
.gwa-cs-wrapper *::after {
  box-sizing: border-box;
}

/* Main Search Bar Pill Container - ALWAYS 1 HORIZONTAL ROW */
.gwa-cs-bar {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  width: 100%;
  height: 54px;
  min-height: 54px;
  background-color: #ffffff;
  border: 1.5px solid #1f533a;
  border-radius: 28px;
  position: relative;
  overflow: visible !important; /* Prevents theme container from clipping floating dropdowns */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.25s ease;
  padding: 0;
  margin: 0;
}

.gwa-cs-bar:focus-within {
  box-shadow: 0 6px 18px rgba(31, 83, 58, 0.15);
}

/* --- Left Side Page Selector --- */
.gwa-cs-selector {
  position: relative;
  display: flex;
  align-items: center;
  width: 200px;
  flex-basis: 200px;
  flex-shrink: 0;
  height: 100%;
  background-color: #eef5f0;
  border-right: 1px solid #dcdcdc;
  user-select: none;
  margin: 0;
  padding: 0;
  border-top-left-radius: 26px;
  border-bottom-left-radius: 26px;
}

.gwa-cs-selector-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0 12px;
  cursor: pointer;
  gap: 8px;
  outline: none;
  transition: background-color 0.2s ease;
  margin: 0;
  border-top-left-radius: 26px;
  border-bottom-left-radius: 26px;
}

.gwa-cs-selector-toggle:hover {
  background-color: #e2ede5;
}

/* Selector Location Icon Base */
.gwa-cs-selector-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #1f533a;
  fill: #1f533a;
  flex-shrink: 0;
  line-height: 1;
}

.gwa-cs-selector-icon svg {
  width: 1em;
  height: 1em;
  display: block;
}

.gwa-cs-selector-icon i {
  font-size: inherit;
  color: inherit;
  line-height: 1;
}

.gwa-cs-selector-label-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
  overflow: hidden;
  line-height: 1.2;
}

.gwa-cs-selector-top-label {
  font-size: 11px;
  font-weight: 600;
  color: #555555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gwa-cs-selector-current {
  font-size: 15px;
  font-weight: 700;
  color: #111111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selector Chevron Arrow */
.gwa-cs-selector-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #333333;
  transition: transform 0.25s ease;
  flex-shrink: 0;
  margin-left: auto;
  line-height: 1;
}

.gwa-cs-selector-arrow svg {
  width: 12px;
  height: 12px;
  display: block;
  stroke: currentColor;
  fill: none;
}

.gwa-cs-selector.is-open .gwa-cs-selector-arrow {
  transform: rotate(180deg);
}

/* Clear Page Button */
.gwa-cs-clear-page-btn {
  background: none;
  border: none;
  color: #888888;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 50%;
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.gwa-cs-clear-page-btn:hover {
  color: #cc0000;
}

/* Page Selector Dropdown Menu */
.gwa-cs-selector-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 260px;
  max-width: 90vw;
  max-height: 320px;
  overflow-y: auto;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 999999 !important;
  display: none !important;
  padding: 6px 0;
  animation: gwaCsFadeIn 0.2s ease-out;
}

.gwa-cs-selector.is-open .gwa-cs-selector-dropdown {
  display: block !important;
}

.gwa-cs-dropdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gwa-cs-dropdown-item {
  position: relative;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #333333;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.gwa-cs-dropdown-item:hover,
.gwa-cs-dropdown-item.is-active {
  background-color: #f0f7f3;
  color: #1f533a;
  font-weight: 600;
}

.gwa-cs-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #1f533a;
}

.gwa-cs-item-icon svg {
  width: 1em;
  height: 1em;
  display: block;
}

.gwa-cs-submenu-arrow {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  color: #888888;
}

.gwa-cs-submenu-arrow svg {
  width: 10px;
  height: 10px;
  display: block;
  stroke: currentColor;
}

/* Child pages nested submenu */
.gwa-cs-dropdown-item .gwa-cs-dropdown-list {
  padding-left: 12px;
  border-left: 2px solid #e2e8f0;
  margin-top: 4px;
}

/* --- Middle Search Input Box --- */
.gwa-cs-input-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  height: 100%;
  padding: 0 16px;
  margin: 0;
  border: none;
  background: transparent;
  min-width: 0;
}

/* Reset Native Browser & Theme Field Outlines */
.gwa-cs-wrapper input[type="text"].gwa-cs-input,
.gwa-cs-wrapper input.gwa-cs-input,
.gwa-cs-bar .gwa-cs-input,
.gwa-cs-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: inherit;
  font-size: 15px;
  line-height: normal;
  color: #222222;
  border-radius: 0;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
}

.gwa-cs-wrapper input[type="text"].gwa-cs-input:focus,
.gwa-cs-wrapper input.gwa-cs-input:focus,
.gwa-cs-input:focus {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.gwa-cs-input::placeholder {
  color: #888888;
  opacity: 0.9;
}

/* Clear Input Button */
.gwa-cs-clear-input-btn {
  background: none;
  border: none;
  color: #888888;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  margin-left: 4px;
  transition: color 0.2s ease;
}

.gwa-cs-clear-input-btn:hover {
  color: #222222;
}

/* --- Right Search Button --- */
.gwa-cs-button-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 60px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

.gwa-cs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: #1f533a;
  color: #ffffff;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  margin: 0;
  transition: background-color 0.2s ease, transform 0.1s ease;
  border-top-right-radius: 26px;
  border-bottom-right-radius: 26px;
}

.gwa-cs-button:hover {
  background-color: #173f2c;
}

.gwa-cs-button:active {
  transform: scale(0.98);
}

.gwa-cs-button svg {
  width: 1em;
  height: 1em;
  display: block;
}

.gwa-cs-button i {
  font-size: inherit;
  color: inherit;
  line-height: 1;
}

/* Dynamic Live Search Results Dropdown Popup */
.gwa-cs-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: 420px;
  overflow-y: auto;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  z-index: 999999 !important;
  padding: 12px;
  animation: gwaCsSlideDown 0.22s ease-out;
}

.gwa-cs-results-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Single Result Item */
.gwa-cs-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.gwa-cs-result-item:hover,
.gwa-cs-result-item:focus {
  background-color: #f4f8f5;
  outline: none;
}

/* Result Thumbnail */
.gwa-cs-result-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #f0f0f0;
}

/* Result Body */
.gwa-cs-result-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
}

.gwa-cs-result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #1f533a;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.gwa-cs-result-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 2px 0;
  line-height: 1.3;
}

.gwa-cs-result-excerpt {
  font-size: 13px;
  color: #666666;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Highlighted Search Keyword */
mark.gwa-cs-highlight {
  background-color: #ffe066;
  color: #111111;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* Loader & Status Messages */
.gwa-cs-loading-box,
.gwa-cs-no-results-box,
.gwa-cs-msg-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  font-size: 14px;
  color: #555555;
  text-align: center;
}

.gwa-cs-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #1f533a;
  border-radius: 50%;
  animation: gwaCsSpin 0.7s linear infinite;
}

/* Recent Searches Section */
.gwa-cs-recent-searches {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gwa-cs-recent-header {
  font-size: 12px;
  font-weight: 600;
  color: #888888;
  text-transform: uppercase;
  padding: 4px 8px;
  letter-spacing: 0.5px;
}

.gwa-cs-recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: #333333;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.gwa-cs-recent-item:hover {
  background-color: #f0f7f3;
  color: #1f533a;
}

.gwa-cs-recent-item svg {
  width: 14px;
  height: 14px;
  stroke: #888888;
}

/* View All Link */
.gwa-cs-view-all-box {
  border-top: 1px solid #edf2f7;
  padding-top: 8px;
  margin-top: 6px;
  text-align: center;
}

.gwa-cs-view-all-btn {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: #1f533a;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.gwa-cs-view-all-btn:hover {
  background-color: #eef5f0;
}

/* Keyframes */
@keyframes gwaCsFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes gwaCsSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes gwaCsSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE DESIGN (Mobile & Tablet - ALWAYS SINGLE ROW PILL LAYOUT)
   ========================================================================== */
@media (max-width: 767px) {
  .gwa-cs-bar {
    flex-direction: row !important;
    height: 48px;
    min-height: 48px;
    border-radius: 24px;
  }

  .gwa-cs-selector {
    width: auto;
    max-width: 38%;
    min-width: 90px;
    flex-basis: auto;
    flex-shrink: 0;
    border-top-left-radius: 22px;
    border-bottom-left-radius: 22px;
  }

  .gwa-cs-selector-toggle {
    padding: 0 8px;
    gap: 4px;
    border-top-left-radius: 22px;
    border-bottom-left-radius: 22px;
  }

  .gwa-cs-selector-icon {
    font-size: 15px;
  }

  .gwa-cs-selector-top-label {
    font-size: 9px;
  }

  .gwa-cs-selector-current {
    font-size: 13px;
  }

  .gwa-cs-input-box {
    padding: 0 8px;
  }

  .gwa-cs-wrapper input[type="text"].gwa-cs-input,
  .gwa-cs-wrapper input.gwa-cs-input,
  .gwa-cs-bar .gwa-cs-input,
  .gwa-cs-input {
    font-size: 13px;
  }

  .gwa-cs-button-box {
    width: 46px;
    min-width: 46px;
  }

  .gwa-cs-button {
    font-size: 16px;
    border-top-right-radius: 22px;
    border-bottom-right-radius: 22px;
  }

  .gwa-cs-selector-dropdown {
    width: 240px;
    max-width: 88vw;
  }
}
