/**
 * Grants Search Module Styles
 * Mobile-first approach
 */

/* CSS Variables */
:root {
  --dropdown-arrow-white: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
  --dropdown-arrow-black: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
}

/* Container */
.grants-search-container {
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

/* Desktop Filter Row */
.grants-filter-desktop {
  display: none; /* Hidden on mobile */
}

/* Mobile Filter Section */
.grants-filter-mobile {
  padding: 1.5rem 0;
}

.grants-filter-mobile-inner {
  width: 90%;
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grants-filter-mobile-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--secondary-color, #333);
}

.grants-filter-mobile-select {
  width: 100%;
  padding: 16px 40px 14px 20px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: #ffffff;
  background-color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: var(--dropdown-arrow-white);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
}

.grants-filter-mobile-select:focus,
.grants-filter-mobile-select:active {
  border-color: var(--tertiary-color);
  background-color: var(--primary-color);
  color: #ffffff;
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Keyword Search Section */
.grants-keyword-search {
  background-color: var(--light-gray, #f2f2f2);
  padding: 2rem 0;
}

.grants-keyword-search-inner {
  width: 90%;
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}

.grants-keyword-label {
  display: block;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--secondary-color, #333);
}

.grants-keyword-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex-grow: 1;
}

.grants-keyword-input {
  width: 100%;
  padding: 0.8rem 3.5rem 0.5rem 1rem;
  font-size: 16px;
  border: 1px solid #d8d8d8;
  border-radius: 0;
  background-color: white;
}

input.grants-keyword-input::-webkit-search-cancel-button {
  -webkit-appearance: auto;
  cursor: pointer;
}

.grants-keyword-input::placeholder {
  color: var(--medium-gray, #979797);
}

.grants-keyword-input:focus {
  outline: 2px solid var(--primary-color, #327f86);
  outline-offset: 2px;
  border-color: var(--primary-color, #327f86);
}

.grants-keyword-submit {
  position: absolute;
  right: 1em;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background-color: #333333;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border-radius: 50%;
}

.grants-keyword-submit::before {
  content: 'U';
  font-family: var(--font-etmodules);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transform: scaleX(-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Results Summary */
.grants-results-summary {
  text-align: center;
  padding: 1.5em 0;
}

.grants-results-summary-inner {
  width: 90%;
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.grants-results-text {
  font-size: 0.8em;
  color: var(--secondary-color, #333);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.5;
}

.grants-total-value {
  color: var(--primary-color, #327f86);
  font-weight: 700;
}

.grants-total-count {
  color: var(--primary-color, #327f86);
  font-weight: 700;
}

.grants-results-separator {
  display: none; /* Hidden on mobile */
}

.grants-results-divider {
  width: 100%;
  height: 1px;
  background-color: var(--primary-color, #327f86);
  position: relative;
  top: -2px;
}

/* Results Wrapper (for loading overlay positioning) */
.grants-results-wrapper {
  position: relative;
  min-height: 200px;
}

/* Loading Indicator */
.grants-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.6);
  z-index: 10;
  pointer-events: none;
}

.grants-loading.hidden {
  display: none;
}

/* Results Container */
.grants-results {
  width: 90%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0;
}

/* No Results Message */
.grants-no-results {
  text-align: center;
  padding: 3rem 1rem;
  font-size: 1.125rem;
  color: var(--medium-gray, #979797);
}

/* Load More Button */
.grants-load-more-container {
  display: flex;
  justify-content: center;
  margin-top: 40px;
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 20px;
}

.grants-load-more-btn {
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  position: relative;
  display: inline-flex;
  align-items: center;
}

.grants-load-more-btn::after {
  font-family: var(--font-etmodules);
  content: '\4c' !important;
  position: absolute;
  right: 1em;
  top: 45%;
  transform: translateY(-50%);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.grants-load-more-btn.hidden {
  display: none;
}

/* Error Message */
.grants-error {
  padding: 1rem;
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  margin: 1rem 0;
}

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

.hidden {
  display: none !important;
}

/* Tablet */
@media (min-width: 768px) {
  /* Keep mobile filters on tablet, just adjust width */
  .grants-filter-mobile-inner {
    width: 80%;
  }

  /* Keyword Search */
  .grants-keyword-search-inner {
    width: 80%;
    flex-direction: row;
    gap: 2em;
    align-items: center;
  }

  /* Results Summary */
  .grants-results-summary-inner {
    width: 80%;
  }

  /* Results */
  .grants-results {
    width: 80%;
  }

  /* Load More */
  .grants-load-more-container {
    width: 80%;
  }

  .grants-results-text {
    font-size: 1em;
  }
}

/* Desktop */
@media (min-width: 981px) {
  /* Hide mobile filters */
  .grants-filter-mobile {
    display: none;
  }

  /* Show desktop filter row */
  .grants-filter-desktop {
    display: block;
  }

  .grants-filter-row {
    background-color: var(--secondary-color, #333);
    padding: 0;
  }

  .grants-filter-inner {
    width: 80%;
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: stretch;
    gap: 0;
    min-height: 80px;
  }

  .grants-filter-label {
    display: flex;
    align-items: center;
    padding: 0 30px 0 0;
    font-weight: 700;
    font-size: 1.5rem;
    color: white;
    white-space: nowrap;
  }

  .grants-filter-select {
    max-width: 30%;
    padding: 0 2em 0 1em;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    background-color: var(--secondary-color);
    border: none;
    cursor: pointer;
    transition:
      background-color 0.3s ease,
      background-image 0.3s ease;
    border-radius: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: var(--dropdown-arrow-white);
    background-repeat: no-repeat;
    background-position: right 0.5em center;
    background-size: 28px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  .grants-filter-select:hover,
  .grants-filter-select:focus {
    background-color: var(--tertiary-color);
    color: var(--secondary-color);
    background-image: var(--dropdown-arrow-black);
    outline: 2px solid var(--tertiary-color);
    outline-offset: 2px;
  }

  .grants-filter-select option {
    background-color: var(--secondary-color);
    color: #ffffff;
  }

  .grants-keyword-label {
    font-size: 1.3em;
  }

  .grants-keyword-input {
    padding: 1rem 4rem 0.8rem 1rem;
  }

  .grants-keyword-submit {
    width: 33px;
    height: 33px;
  }

  .grants-keyword-submit::before {
    font-size: 16px;
  }

  .grants-results-summary-inner {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 1rem;
  }

  .grants-results-text {
    font-size: 1.4em;
    display: inline-block;
  }

  .grants-results-separator {
    display: inline;
    color: var(--medium-gray, #979797);
  }

  .grants-results-divider {
    display: none;
  }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  .grants-filter-mobile-select,
  .grants-filter-select,
  .grants-load-more-btn {
    animation: none;
    transition: none;
  }
}
