/**
 * Client Search Autocomplete Styles
 * Location: src/assets/css/clisyc-admin-client-search.css
 * 
 * Or add to: src/assets/css/clisyc-admin-style.css
 *
 * @package ClientSync
 */

/* ==========================================================================
   Client Search Container
   ========================================================================== */

.clisyc-client-search-container {
    position: relative;
    max-width: 100%;
}

/* ==========================================================================
   Selected Client Display
   ========================================================================== */

.clisyc-client-selected {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f0f6fc;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    margin-bottom: 8px;
}

.clisyc-client-selected.has-selection {
    display: flex;
}

.clisyc-client-selected .clisyc-client-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.clisyc-client-selected .clisyc-client-info {
    flex: 1;
    min-width: 0;
}

.clisyc-client-selected .clisyc-client-info strong {
    display: block;
    font-size: 13px;
    color: #1d2327;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clisyc-client-selected .clisyc-client-email {
    display: block;
    font-size: 12px;
    color: #646970;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clisyc-client-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #787c82;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.clisyc-client-clear-btn:hover {
    background: #fff;
    border-color: #c3c4c7;
    color: #d63638;
}

.clisyc-client-clear-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Search Input
   ========================================================================== */

.clisyc-client-search-input-wrapper {
    position: relative;
}

.clisyc-client-search-input-wrapper .dashicons-search {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #8c8f94;
    font-size: 16px;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

#clisyc-client-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 0 0 transparent;
    transition: border-color 0.1s ease, box-shadow 0.1s ease;
}

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

#clisyc-client-search-input::placeholder {
    color: #8c8f94;
}

/* Hide search input when client is selected (optional - show both) */
.clisyc-client-selected.has-selection + .clisyc-client-search-input-wrapper {
    /* Uncomment to hide input when client selected */
    /* display: none; */
}

/* ==========================================================================
   Search Results Dropdown
   ========================================================================== */

#clisyc-client-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 320px;
    overflow-y: auto;
    display: none;
}

#clisyc-client-search-results.is-open {
    display: block;
}

/* ==========================================================================
   Result Items
   ========================================================================== */

.clisyc-client-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
    transition: background-color 0.1s ease;
}

.clisyc-client-search-item:last-child {
    border-bottom: none;
}

.clisyc-client-search-item:hover,
.clisyc-client-search-item.is-highlighted {
    background-color: #f0f6fc;
}

.clisyc-client-search-item .clisyc-client-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.clisyc-client-search-item .clisyc-client-info {
    flex: 1;
    min-width: 0;
}

.clisyc-client-search-item .clisyc-client-name {
    font-size: 13px;
    font-weight: 500;
    color: #1d2327;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clisyc-client-search-item .clisyc-client-email {
    font-size: 12px;
    color: #646970;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clisyc-client-search-item .clisyc-client-role {
    font-size: 11px;
    color: #787c82;
    background: #f0f0f1;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Highlight matching text */
.clisyc-client-search-item mark {
    background: #fff8c5;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.clisyc-client-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: #646970;
    font-size: 13px;
}

.clisyc-client-search-loading .spinner {
    float: none;
    margin: 0;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.clisyc-client-search-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px;
    color: #646970;
    font-size: 13px;
    text-align: center;
}

.clisyc-client-search-empty .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: #8c8f94;
}

/* ==========================================================================
   Error State
   ========================================================================== */

.clisyc-client-search-error {
    padding: 16px;
    color: #d63638;
    font-size: 13px;
    text-align: center;
    background: #fcf0f1;
}

/* ==========================================================================
   Helper Text
   ========================================================================== */

.clisyc-client-search-help {
    margin-top: 6px;
    font-size: 12px;
    color: #646970;
    font-style: italic;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media screen and (max-width: 782px) {
    .clisyc-client-search-item {
        padding: 12px;
    }

    .clisyc-client-search-item .clisyc-client-role {
        display: none;
    }

    .clisyc-client-selected {
        flex-wrap: wrap;
    }

    .clisyc-client-selected .clisyc-client-info {
        flex: 1 1 calc(100% - 80px);
    }
}

/* ==========================================================================
   Dark Mode / High Contrast Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* These will only apply if WP admin has dark mode enabled */
}

/* Focus visible for accessibility */
#clisyc-client-search-input:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

.clisyc-client-search-item:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

.clisyc-client-clear-btn:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}