/* CPC Search Styles */
.cpc-search-form {
    position: relative;
    display: flex;
    gap: 8px;
    font-family: var(--cpc-font-primary, inherit);
}

.cpc-search-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    overflow: hidden;
    border: 2px solid #000;
    border-radius:30px;
    width: 100%;
    position: relative;
}

/* Style for select and option in search dropdown (note: option:hover only works on Chrome/Edge/Firefox, not Safari) */
.cpc-search-type {
    font-size: 14px;
    color: #000;
    border: 0;
    padding: 5px 16px;
    background: #fff;
    height: 38px;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background-color: transparent;
    padding-right: 25px; /* Thêm padding để mũi tên không đè lên chữ */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-chevron-down' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
}
.cpc-search-type option {
  background: #f8fafc;
  color: #222;
  padding: 5px 16px;
  border-radius:7px;
  font-family: inherit;
}

.cpc-search-field {
    flex: 1 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.cpc-search-field::-webkit-search-clear-button,
.cpc-search-field::-webkit-clear-button,
.cpc-search-field::-webkit-input-clear-button,
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  display: none !important;
  -webkit-appearance: none;
}
.cpc-search-field::-ms-clear { display: none; }
.cpc-search-field::-o-clear { display: none; }
.cpc-search-clear {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.13s;
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  outline: none;
  color: #999;
  font-size: 22px;
  padding: 0;
  cursor: pointer;
  z-index: 4;
  height: 30px; width: 30px;
  display: flex; align-items: center; justify-content: center;
}
.cpc-search-field:focus + .cpc-search-clear,
.cpc-search-field:not(:placeholder-shown) + .cpc-search-clear {
  opacity: 1;
  pointer-events: auto;
}
.cpc-search-clear:hover {
  color: #d32f2f;
  background: #f8fafc;
}


.cpc-search-results {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    box-shadow: 0px 5px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    font-family: var(--cpc-font-primary, inherit);
}
.cpc-search-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  outline: none;
  background: transparent;
  color: #000;
  padding: 3px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.7;
  z-index: 5;
  transition: background 0.13s, opacity 0.13s;
}
.cpc-search-close:hover,.cpc-search-close:focus {
  background: #f3f4f6;
  opacity: 1;
}

.search-results-header {
    background: #f8fafc;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    margin: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-results-header:first-child {
    border-radius: 6px 6px 0 0;
}

.search-results-header:not(:first-child) {
    border-top: 2px solid #e5e7eb;
    margin-top: 8px;
}

.search-results-header:last-child {
    border-radius: 0 0 6px 6px;
}

/* Loading animation */
.cpc-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6b7280;
    font-size: 14px;
}

.cpc-search-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #e21736;
    border-radius: 50%;
    animation: cpc-spin 1s linear infinite;
    margin-right: 8px;
}

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

/* No results message */
.cpc-search-no-results {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6b7280;
    font-size: 14px;
    text-align: center;
    flex-direction: column;
    gap: 8px;
}

.cpc-search-no-results::before {
    content: 'search';
    font-family: 'Material Icons';
    font-size: 18px;
    opacity: 0.6;
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
}

.cpc-search-no-results-text {
    font-weight: 500;
    color: #000;
}

/* Search History */
.cpc-search-history {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cpc-search-history-clear {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 11px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.cpc-search-history-clear:hover {
    background: #e5e7eb;
    color: #000;
}

.cpc-search-history-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s ease;
    gap: 8px;
}

.cpc-search-history-item:hover {
    background: #f8fafc;
}

.cpc-search-history-item:last-child {
    border-bottom: none;
}

.cpc-search-history-item::before {
    content: 'history';
    font-family: 'Material Icons';
    font-size: 16px;
    opacity: 0.6;
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
}

.cpc-search-history-text {
    flex: 1;
    color: #000;
    font-size: 14px;
}

.cpc-search-history-remove {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 2px;
    opacity: 0;
    transition: all 0.2s ease;
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
}

.cpc-search-history-item:hover .cpc-search-history-remove {
    opacity: 1;
}

.cpc-search-history-remove:hover {
    background: #f3f4f6;
    color: #ef4444;
}

/* Popular searches */
.cpc-popular-wrapper {
    padding: 12px 16px 14px;
}
.cpc-popular-title {
    font-size: 13px;
    font-weight: 600;
    color: #000;
    margin-bottom: 10px;
}
.cpc-popular-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
}
.cpc-chip {
    background: #e21736;
    border: 0;
    border-radius: 9999px;
    padding: 6px 12px;
    font-size: 13px;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.cpc-chip .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffffff;
    margin-right: 8px;
}
.cpc-chip:hover {
    background: #000;
    border-color: #c7d2fe;
}

.cpc-suggest {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cpc-suggest li {
    border-bottom: 1px solid #f3f4f6;
}

.cpc-suggest li:last-child {
    border-bottom: 1px solid #e5e7eb;
}

.cpc-suggest:last-child li:last-child {
    border-bottom: none;
}
.cpc-search-field:focus{
  border:0;
  outline: none;
  background: #fff;
}
.cpc-search-type:focus {
    outline: none;
    box-shadow: none;
    border:0;
    background:#fff;
}
.cpc-suggest a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #000;
    gap: 12px;
    transition: background-color 0.2s ease;
}

.cpc-suggest a:hover {
    background: #f8fafc;
}

.cpc-suggest a:active {
    background: #f1f5f9;
}

.cpc-suggest img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.cpc-suggest span {
    flex: 1;
    font-weight: 700;
}

.cpc-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cpc-specifications {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    line-height: 1.3;
    margin-top: 2px;
}

.cpc-suggest .price {
    color: #ef4444;
    font-weight: 700;
    margin-left: auto;
    font-size: 16px;
    font-style: normal;
}

.cpc-suggest .count {
    color: #6b7280;
    font-size: 12px;
    margin-left: 8px;
    font-style: italic;
}


/* Responsive */
@media (max-width: 768px) {
    .cpc-search-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cpc-search-type {
        min-width: auto;
    }
}
