/**
 * ITNJ Event Select Field Styles
 */

.itnj-event-select-wrapper {
    position: relative;
}

.itnj-event-select-wrapper select.itnj-event-select-field {
    width: 100%;
    min-height: 32px;
}

.itnj-event-select-wrapper select.itnj-event-select-field[multiple] {
    min-height: 120px;
}

/* Loading state */
.itnj-event-select-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 30px;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: itnj-event-select-spin 1s linear infinite;
}

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

.itnj-event-select-wrapper.loading select {
    opacity: 0.7;
}

/* Field notices */
.itnj-field-notice {
    margin: 5px 0 0 0;
    padding: 0;
    font-size: 12px;
    line-height: 1.4;
    color: #666;
    font-style: italic;
}

.itnj-field-notice.error {
    color: #d63638;
}

.itnj-field-notice.success {
    color: #00a32a;
}

/* Refresh button (for future implementation) */
.itnj-refresh-events {
    margin-left: 8px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.2;
    vertical-align: top;
}

/* Better spacing for multiple select */
.acf-field-itnj-event-select select[multiple] option {
    padding: 4px 8px;
    line-height: 1.4;
}

/* Highlight selected options in multiple select */
.acf-field-itnj-event-select select[multiple] option:checked {
    background-color: #0073aa !important;
    color: white !important;
}

/* Field wrapper adjustments */
.acf-field-itnj-event-select .acf-input {
    position: relative;
}

/* Status indicators */
.itnj-event-select-wrapper .status-indicator {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-indicator.scheduled {
    background-color: #e7f3ff;
    color: #0073aa;
}

.status-indicator.in-progress {
    background-color: #fff2e7;
    color: #d68216;
}

.status-indicator.completed {
    background-color: #e7f7e7;
    color: #00a32a;
}

.status-indicator.cancelled {
    background-color: #ffeaea;
    color: #d63638;
}

/* Responsive adjustments */
@media (max-width: 782px) {
    .itnj-event-select-wrapper select.itnj-event-select-field {
        font-size: 16px; /* Prevent zoom on mobile */
    }
    
    .itnj-refresh-events {
        display: block;
        margin: 8px 0 0 0;
        width: 100%;
    }
}

/* ACF Pro compatibility */
.acf-field-itnj-event-select .acf-label {
    font-weight: 600;
}

.acf-field-itnj-event-select .acf-input .acf-fields {
    border: 0;
    padding: 0;
}

/* Field group styling */
.acf-field-itnj-event-select.acf-field {
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
    padding-bottom: 15px;
}

.acf-field-itnj-event-select.acf-field:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Instructions styling */
.acf-field-itnj-event-select .acf-label .description {
    font-weight: normal;
    color: #666;
    font-size: 13px;
    margin-top: 3px;
}

/* Error state styling */
.acf-field-itnj-event-select.acf-error .acf-input {
    border-color: #d63638;
}

.acf-field-itnj-event-select .acf-error-message {
    color: #d63638;
    font-size: 12px;
    margin-top: 5px;
}

/* Loading overlay for AJAX operations */
.itnj-event-select-wrapper .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-overlay .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: itnj-event-select-spin 1s linear infinite;
}

/* Accessibility improvements */
.itnj-event-select-wrapper select:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.itnj-event-select-wrapper .screen-reader-text {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .itnj-field-notice {
        border: 1px solid currentColor;
        padding: 5px;
    }
    
    .status-indicator {
        border: 1px solid currentColor;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .itnj-field-notice {
        color: #ccc;
    }
    
    .itnj-field-notice.error {
        color: #ff6b6b;
    }
    
    .itnj-field-notice.success {
        color: #51cf66;
    }
}