/*
 * Gravity Forms – Custom Tag-based Multi Select Dropdown
 * File: gf-multiselect-custom.css
 *
 * Enqueue in functions.php:
 *   wp_enqueue_style('gf-ms-style', get_template_directory_uri() . '/gf-multiselect-custom.css');
 *   wp_enqueue_script('gf-ms-script', get_template_directory_uri() . '/gf-multiselect-custom.js', ['jquery'], null, true);
 */

/* Wrapper*/
.gf-ms-wrap {
  position: relative;
  width: 100%;
  font-family: inherit;
}

/* Trigger button*/
.gf-ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 6px 36px 6px 12px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  color: #111827;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  flex-wrap: wrap;
  gap: 4px;
  outline: none !important;
}

/* .gf-ms-trigger:hover {
  border-color: #9ca3af;
}

.gf-ms-wrap.open .gf-ms-trigger {
  border-color: #374151;
  box-shadow: 0 0 0 3px rgba(55, 65, 81, 0.08);
} */

/*Caret icon*/
.gf-ms-caret {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  display: flex;
  align-items: center;
  transition: transform 0.15s ease;
  pointer-events: none;
}

.gf-ms-wrap.open .gf-ms-caret {
  transform: translateY(-50%) rotate(180deg);
}

/*Display area (tags + placeholder)*/
.gform-theme.gform-theme--framework.gform_wrapper .ginput_container_multiselect .gf-ms-display {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.gf-ms-placeholder {
  color: #9ca3af;
  font-size: 15px;
}

/* Tag pills */
.gf-ms-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 13px;
  font-weight: 500;
  padding: 3px 8px 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  max-width: 200px;
}

.gform-theme.gform-theme--framework.gform_wrapper .ginput_container_multiselect .gf-ms-tag{
  display: inline-flex;
    align-items: center;
    gap: 5px;
}

.gf-ms-tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gf-ms-tag-x {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  color: #0369a1;
  opacity: 0.7;
  border-radius: 50%;
  transition: opacity 0.1s, background 0.1s;
  flex-shrink: 0;

  
}

.gform-theme.gform-theme--framework.gform_wrapper .ginput_container_multiselect .gf-ms-tag-x{
  background: transparent !important;
  box-shadow: none !important;
  color: var(--red) !important;
  padding: 0 !important;
  height: auto !important;
  min-height: inherit !important;
}

.gf-ms-tag-x:hover {
  opacity: 1;
  background: rgba(3, 105, 161, 0.15);
}

/* Dropdown list*/
.gf-ms-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  z-index: 9999;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  max-height: 260px;
  overflow-y: auto;
}

.gf-ms-wrap.open .gf-ms-dropdown {
  display: block;
}

/*Each option*/
.gf-ms-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: #111827;
  transition: background 0.1s;
}

.gf-ms-option:hover {
  background: #f9fafb;
}

.gf-ms-option.selected {
  background: #f0f9ff;
}

/* Checkbox square*/
.gf-ms-check {
  width: 17px;
  height: 17px;
  border: 1.5px solid #d1d5db;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #ffffff;
  transition: background 0.12s, border-color 0.12s;
}

.gf-ms-check svg {
  display: none;
}

.gf-ms-option.selected .gf-ms-check {
  background: #0ea5e9;
  border-color: #0ea5e9;
}

.gf-ms-option.selected .gf-ms-check svg {
  display: block;
}

/* Scrollbar styling (webkit)*/
.gf-ms-dropdown::-webkit-scrollbar {
  width: 5px;
}
.gf-ms-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.gf-ms-dropdown::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 10px;
}
/**************** Custom CSS */
/* Container Logic */
.ginput_container_multiselect .gf-ms-wrap {
    position: relative;
    width: 100%;
    font-family: sans-serif;
    border-radius: 12px;
    border: 1px solid #E8E5E5;
    background-color: #FBFBFB;
    min-height: 48px;
    display: flex;
    flex-direction: column;
}

/* The Trigger Button */
.ginput_container_multiselect .gf-ms-trigger {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100%;
    background: transparent !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: left !important;
    height: 100% !important;
    box-shadow: none !important;
    line-height: 24px !important;
    color: #000 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    letter-spacing: 0.26px !important;
    padding: 11px 25px !important;
    font-family: "Proxima Nova Rg" !important;
    max-width: inherit !important;
    border: none !important;
    outline: none !important;
}
.ginput_container_multiselect .gf-ms-wrap.open .gf-ms-trigger{
  outline: none !important;
}
/* 
.ginput_container_multiselect .gf-ms-trigger:hover {
    border-color: #9ca3af;
}

.ginput_container_multiselect .gf-ms-trigger:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
} */

.ginput_container_multiselect .gf-ms-placeholder {
    color: #000;
    font-size: 16px;
}

.ginput_container_multiselect .gf-ms-caret {
    transition: transform 0.2s ease;
    color: #6b7280;
    position: absolute;
    right: 25px;
    top: 15px;
    height: 18px;
    width: 18px;
    border: 1px solid var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.ginput_container_multiselect .gf-ms-caret svg{
  width: 16px;
}

.ginput_container_multiselect .gf-ms-caret svg path{
  stroke: var(--red)
}

/* Dropdown List */
.ginput_container_multiselect .gf-ms-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    margin: 0;
    padding: 6px;
    list-style: none;
    z-index: 100;
    
    /* Hidden by default */
    display: none;
    max-height: 250px;
    overflow-y: auto;
}

/* Handle Open State */
.ginput_container_multiselect .gf-ms-wrap.open .gf-ms-dropdown {
    display: block;
}

.ginput_container_multiselect .gf-ms-wrap.open .gf-ms-caret {
    transform: rotate(180deg);
}

/* Individual Options */
.ginput_container_multiselect .gf-ms-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    font-size: 14px;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.ginput_container_multiselect .gf-ms-option:hover {
    background-color: #f3f4f6;
}

/* Checkbox Icon Logic */
.ginput_container_multiselect .gf-ms-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1px solid var(--red);
    border-radius: 50px;
    margin-right: 12px;
    background: var(--btnBgRed) !important;
    transition: all 0.2s ease;
}

/* Hidden SVG by default */
.ginput_container_multiselect .gf-ms-check svg {
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}
 
/* Selected State Styles */
.ginput_container_multiselect .gf-ms-option.selected {
  background-color: transparent;
  border-color: var(--red);
}

.ginput_container_multiselect .gf-ms-option.selected .gf-ms-check {
    background-color: var(--btnBgRed);
    border-color: var(--red);
}

.ginput_container_multiselect .gf-ms-option.selected .gf-ms-check svg {
    opacity: 1;
    transform: scale(1);
}
.ginput_container_multiselect .gf-ms-option.selected .gf-ms-check svg path{
  stroke: var(--red);
}
/* END */

/*Dark mode support (optional)*/
@media (prefers-color-scheme: dark) {
  .gf-ms-trigger {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
  }
  .gf-ms-wrap.open .gf-ms-trigger {
    border-color: #6b7280;
  }
  .gf-ms-dropdown {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
  .gf-ms-option {
    color: #f9fafb;
  }
  .gf-ms-option:hover {
    background: #374151;
  }
  .gf-ms-option.selected {
    background: #1e3a4f;
  }
  .gf-ms-check {
    background: #374151;
    border-color: #4b5563;
  }
  .gf-ms-tag {
    background: #1e3a4f;
    color: #7dd3fc;
  }
  .gf-ms-tag-x {
    color: #7dd3fc;
  }
  .gf-ms-placeholder {
    color: #6b7280;
  }
}

@media screen and (max-width: 767px){
  .ginput_container_multiselect .gf-ms-trigger{
    padding: 11px 15px 11px 13px !important;
  }
  .ginput_container_multiselect .gf-ms-caret{
    right: 15px;
  }
}