/**
 * ITNJ Commission Select Field Styles
 *
 * @package ITNJ_Commission
 * @since 1.0.0
 */

/* Commission Select Field Wrapper */
.itnj-commission-select-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 500px;
}

.itnj-commission-select-wrapper select {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

.itnj-commission-select-wrapper .itnj-refresh-commissions {
    flex-shrink: 0;
    height: 32px;
    line-height: 30px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 3px;
    background: #f1f1f1;
    border: 1px solid #ccc;
    cursor: pointer;
    transition: all 0.2s ease;
}

.itnj-commission-select-wrapper .itnj-refresh-commissions:hover {
    background: #fff;
    border-color: #999;
}

.itnj-commission-select-wrapper .itnj-refresh-commissions:focus {
    outline: 2px solid #007cba;
    outline-offset: -2px;
}

.itnj-commission-select-wrapper .itnj-refresh-commissions:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.itnj-commission-select-wrapper .itnj-refresh-commissions.updating-message {
    position: relative;
}

.itnj-commission-select-wrapper .itnj-refresh-commissions.updating-message::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    margin-top: -8px;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: itnj-spin 1s linear infinite;
}

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

/* ACF Field Container Specifics */
.acf-field[data-type="itnj_commission_select"] .acf-input .itnj-commission-select-wrapper {
    max-width: 100%;
}

.acf-field[data-type="itnj_commission_select"] .acf-input select {
    min-width: 200px;
    width: auto;
    max-width: 400px;
}

/* Message Styles */
.itnj-commission-message {
    margin: 8px 0 0 0;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
    position: relative;
}

.itnj-commission-message.notice-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.itnj-commission-message.notice-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.itnj-commission-message p {
    margin: 0;
    padding: 0;
}

.itnj-commission-message .notice-dismiss {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.itnj-commission-message .notice-dismiss:hover {
    opacity: 1;
}

.itnj-commission-message .notice-dismiss::before {
    content: "×";
    display: block;
    width: 100%;
    height: 100%;
    text-align: center;
    font-weight: bold;
}

.itnj-commission-message .notice-dismiss .screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    word-wrap: normal !important;
    overflow: hidden;
    width: 1px;
    height: 1px;
}

/* Responsive Design */
@media (max-width: 782px) {
    .itnj-commission-select-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    
    .itnj-commission-select-wrapper select {
        width: 100%;
        min-width: auto;
        max-width: none;
    }
    
    .itnj-commission-select-wrapper .itnj-refresh-commissions {
        width: 100%;
        text-align: center;
    }
}

/* Dark Mode Support (for WordPress 5.7+) */
@media (prefers-color-scheme: dark) {
    .itnj-commission-select-wrapper .itnj-refresh-commissions {
        background: #2c3338;
        border-color: #50575e;
        color: #c3c4c7;
    }
    
    .itnj-commission-select-wrapper .itnj-refresh-commissions:hover {
        background: #32373c;
        border-color: #646970;
    }
    
    .itnj-commission-message.notice-success {
        background: #1a4b3a;
        border-color: #2d5a49;
        color: #9dd3a8;
    }
    
    .itnj-commission-message.notice-error {
        background: #4a1a1a;
        border-color: #5a2d2d;
        color: #d39d9d;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .itnj-commission-select-wrapper .itnj-refresh-commissions {
        border-width: 2px;
    }
    
    .itnj-commission-select-wrapper .itnj-refresh-commissions:focus {
        outline-width: 3px;
    }
    
    .itnj-commission-message {
        border-width: 2px;
    }
}

/* RTL Support */
body.rtl .itnj-commission-select-wrapper .itnj-refresh-commissions.updating-message::after {
    right: auto;
    left: 8px;
}

body.rtl .itnj-commission-message .notice-dismiss {
    right: auto;
    left: 4px;
}

/* Multi-select functionality styles */
.itnj-multiple-selection-wrapper {
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    margin-bottom: 10px;
    max-width: none;
}

.itnj-selected-items,
.itnj-available-choices {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.itnj-available-choices {
    border-bottom: none;
    background-color: #fafafa;
}

.itnj-selected-items h4,
.itnj-available-choices h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: #23282d;
}

/* Selected items list */
.itnj-selected-list {
    min-height: 40px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 8px;
    background-color: #fff;
}

.itnj-selected-item {
    display: inline-flex;
    align-items: center;
    background-color: #0073aa;
    color: #fff;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 3px;
    font-size: 12px;
}

.itnj-selected-item .itnj-item-label {
    margin-right: 6px;
}

.itnj-selected-item .itnj-remove-item {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    width: 16px;
    height: 16px;
    text-align: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.itnj-selected-item .itnj-remove-item:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.itnj-no-selection {
    color: #666;
    font-style: italic;
    padding: 8px;
    text-align: center;
}

/* Search input */
.itnj-search {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    margin-bottom: 10px;
    font-size: 13px;
}

.itnj-search:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Available items list */
.itnj-available-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-color: #fff;
}

.itnj-available-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.itnj-available-item:last-child {
    border-bottom: none;
}

.itnj-available-item:hover {
    background-color: #f5f5f5;
}

.itnj-available-item.itnj-selected {
    background-color: #e8f4f8;
    color: #0073aa;
}

.itnj-available-item .itnj-item-label {
    flex: 1;
    font-size: 13px;
}

.itnj-available-item .itnj-add-item {
    background-color: #0073aa;
    color: #fff;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    text-align: center;
    transition: background-color 0.2s;
}

.itnj-available-item .itnj-add-item:hover {
    background-color: #005177;
}

.itnj-available-item .itnj-add-item:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.itnj-available-item .itnj-item-selected {
    color: #0073aa;
    font-size: 12px;
    font-weight: 600;
}

/* Max selections info */
.itnj-max-info {
    padding: 10px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 3px;
    margin-top: 10px;
    font-size: 12px;
    color: #856404;
}

/* Multi-select wrapper adjustments */
.itnj-commission-select-wrapper:has(.itnj-multiple-selection-wrapper) {
    display: block;
    max-width: none;
}

.itnj-commission-select-wrapper .itnj-multiple-selection-wrapper + .itnj-refresh-commissions {
    margin-top: 10px;
    display: inline-block;
}

/* Responsive design for multi-select */
@media (max-width: 782px) {
    .itnj-multiple-selection-wrapper {
        padding: 10px;
    }
    
    .itnj-selected-items,
    .itnj-available-choices {
        padding: 10px;
    }
    
    .itnj-available-item {
        padding: 10px;
    }
    
    .itnj-selected-item {
        margin: 3px;
        padding: 6px 10px;
    }
}

/* Dark mode support for multi-select */
@media (prefers-color-scheme: dark) {
    .itnj-multiple-selection-wrapper {
        background-color: #2c3338;
        border-color: #50575e;
    }
    
    .itnj-selected-list,
    .itnj-available-list {
        background-color: #1d2327;
        border-color: #50575e;
    }
    
    .itnj-available-choices {
        background-color: #23282d;
    }
    
    .itnj-selected-items h4,
    .itnj-available-choices h4 {
        color: #f0f0f1;
    }
    
    .itnj-search {
        background-color: #1d2327;
        color: #f0f0f1;
        border-color: #50575e;
    }
    
    .itnj-available-item {
        border-color: #50575e;
        color: #f0f0f1;
    }
    
    .itnj-available-item:hover {
        background-color: #32373c;
    }
    
    .itnj-no-selection {
        color: #c3c4c7;
    }
}

/* High contrast mode for multi-select */
@media (prefers-contrast: high) {
    .itnj-selected-item {
        border: 2px solid #000;
    }
    
    .itnj-available-item:hover {
        background-color: #000;
        color: #fff;
    }
    
    .itnj-multiple-selection-wrapper {
        border-width: 2px;
    }
}

/* RTL support for multi-select */
body.rtl .itnj-selected-item .itnj-item-label {
    margin-right: 0;
    margin-left: 6px;
}

body.rtl .itnj-selected-item .itnj-remove-item {
    margin-left: 0;
    margin-right: 4px;
}