/**
 * HivePress Conditional Fields - Frontend Styles
 */

/* Parent-Child Field Container */
.hpcf-field-container {
    position: relative;
}

/* Loading State */
.hpcf-loading {
    position: relative;
    pointer-events: none;
}

.hpcf-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: hpcf-spin 0.8s linear infinite;
}

@keyframes hpcf-spin {
    to { transform: rotate(360deg); }
}

/* Select2-like Search Box */
.hpcf-searchable-select {
    position: relative;
}

.hpcf-search-wrapper {
    position: relative;
}

.hpcf-search-input {
    width: 100%;
    padding: 8px 12px;
    padding-right: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.hpcf-search-input:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

.hpcf-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
}

.hpcf-dropdown.active {
    display: block;
}

.hpcf-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.hpcf-dropdown-item:hover,
.hpcf-dropdown-item.highlighted {
    background: #f0f6fc;
}

.hpcf-dropdown-item.selected {
    background: #2271b1;
    color: #fff;
}

.hpcf-no-results {
    padding: 10px 12px;
    color: #666;
    font-style: italic;
}

/* Listing Display */
.hpcf-listing-field {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.hpcf-listing-field .hpcf-label {
    font-weight: 500;
    color: #333;
}

.hpcf-listing-field .hpcf-value {
    color: #666;
}

.hpcf-listing-field .hpcf-separator {
    color: #999;
}

/* Disabled State */
.hpcf-disabled {
    opacity: 0.6;
    pointer-events: none;
    background: #f5f5f5;
}

/* HivePress Integration Overrides */
.hp-form .hpcf-parent-field,
.hp-form .hpcf-child-field {
    width: 100%;
}

.hp-form select.hpcf-enhanced {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* Filter/Search Form Integration */
.hp-form--listing-filter .hpcf-field-pair,
.hp-form--listing-search .hpcf-field-pair {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hp-form--listing-filter .hpcf-field-pair > *,
.hp-form--listing-search .hpcf-field-pair > * {
    flex: 1;
    min-width: 150px;
}

/* Responsive */
@media (max-width: 768px) {
    .hpcf-dropdown {
        max-height: 200px;
    }
    
    .hp-form--listing-filter .hpcf-field-pair,
    .hp-form--listing-search .hpcf-field-pair {
        flex-direction: column;
    }
    
    .hp-form--listing-filter .hpcf-field-pair > *,
    .hp-form--listing-search .hpcf-field-pair > * {
        min-width: 100%;
    }
}
