/* Searchable Contacts Interface Styles */

/* Searchable Add Item Styles */
.search-wrapper {
    position: relative;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.search-container {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25);
}

/* Dropdown Results */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 1050; /* Higher than Bootstrap modals */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-dropdown.show {
    display: block;
}

.search-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f5f5f5;
}

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

.search-dropdown-item:hover:not(.disabled) {
    background-color: #f5f5f5;
}

.search-dropdown-item.selected {
    background-color: #e3f2fd;
}

.search-dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #fafafa;
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 0.25rem;
}

.item-category {
    font-size: 0.875rem;
    color: #666;
}

.item-designation {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

.added-badge {
    background: #4caf50;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 1rem;
}

/* Add Button - Modern Design */
.add-button {
    /* Reset Bootstrap styles */
    all: unset;
    box-sizing: border-box;

    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;

    /* Sizing - Match input field exactly */
    padding: 0.75rem 1.5rem;
    height: 3.25rem;

    /* Typography */
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    color: white;
    white-space: nowrap;
    text-align: center;

    /* Appearance */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid #667eea;
    border-radius: 8px;

    /* Interaction */
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a67d8 0%, #6a3f8f 100%);
    border-color: #5a67d8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.add-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
}

.add-button:disabled {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
    border-color: #cbd5e0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.add-button i {
    font-size: 1rem;
}

/* Selected Items List */
.selected-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s;
    animation: slideIn 0.3s ease-out;
}

.selected-item:hover {
    border-color: #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.selected-item-info {
    flex: 1;
}

.selected-item-info .item-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 0.25rem;
}

.selected-item-info .item-category {
    font-size: 0.875rem;
    color: #666;
}

/* Action buttons container */
.selected-item-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

/* Common action button styles */
.action-button {
    padding: 0.4rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    color: white;
}

.action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.action-button:active {
    transform: translateY(0);
}

/* Specific action button styles */
.edit-button {
    background: #ff9800;
}

.edit-button:hover {
    background: #f57c00;
}

.remove-button {
    padding: 0.4rem;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
}

.remove-button:hover {
    background: #d32f2f;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.remove-button:active {
    transform: translateY(0);
}

/* No results */
.no-results {
    padding: 1rem;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #999;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
    font-style: italic;
}

/* Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide original select fields visually but keep in DOM for form submission */
.searchable-interface-active .original-select-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-wrapper {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .add-button {
        width: 100%;
        justify-content: center;
    }
    
    .selected-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .selected-item-actions {
        align-self: flex-end;
        gap: 0.25rem;
    }
    
    .action-button,
    .remove-button {
        width: 1.8rem;
        height: 1.8rem;
        font-size: 0.8rem;
    }
}

/* Integration with existing form styles */
.field-group .search-wrapper {
    margin-bottom: 0.5rem;
}

.field-group .selected-list {
    margin-top: 0.5rem;
}

/* Message container */
.searchable-contacts-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1060;
    max-width: 400px;
}

.searchable-contacts-messages .alert {
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Accessibility improvements */
.search-dropdown-item:focus {
    background-color: #e3f2fd;
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

.search-input:focus {
    border-color: #667eea;
}

.add-button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.remove-button:focus {
    outline: 2px solid #f44336;
    outline-offset: 2px;
}

/* Autosave Indicator */
.autosave-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #667eea;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.autosave-indicator i {
    margin-right: 0.5rem;
}

/* Messages Container for searchable contacts */
.searchable-contacts-messages {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    min-width: 300px;
    max-width: 400px;
}

.searchable-contacts-messages .alert {
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
}