/**
 * Audience Builder Styles
 * 
 * Universal styling for the audience targeting component.
 * Works in both admin backend and frontend staff management.
 * 
 * @since 3.0.8
 */

/* ==========================================================================
   WRAPPER & HEADER
   ========================================================================== */

.ab-wrapper {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}

.ab-wrapper.compact {
    padding: 15px;
    border-radius: 12px;
}

.ab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.ab-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #1d1d1f;
}

.ab-title-icon {
    font-size: 18px;
}

.ab-count {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: #0369a1;
}

.ab-count-icon {
    font-size: 16px;
}

.ab-count-num {
    font-weight: 800;
    font-size: 15px;
}

.ab-count-label {
    font-weight: 500;
    opacity: 0.8;
}

/* ==========================================================================
   PRESETS
   ========================================================================== */

.ab-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.ab-preset {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: #f5f5f7;
    border: 2px solid transparent;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #424245;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ab-preset:hover {
    background: #e8e8ed;
    transform: translateY(-1px);
}

.ab-preset.active {
    background: linear-gradient(135deg, #0071e3 0%, #0051a3 100%);
    color: #fff;
    border-color: #0071e3;
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.ab-preset-custom {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    color: #16a34a;
    border-color: #bbf7d0;
}

.ab-preset-custom:hover {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
}

.ab-preset-custom.active {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #fff;
    border-color: #16a34a;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

/* ==========================================================================
   CUSTOM BUILDER PANEL
   ========================================================================== */

.ab-custom-panel {
    background: #fafafa;
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}

.ab-rules-container {
    margin-bottom: 16px;
}

.ab-rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
}

.ab-logic-badge {
    background: #e0f2fe;
    color: #0369a1;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ab-rules {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ==========================================================================
   RULE ROW
   ========================================================================== */

.ab-rule {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.ab-rule:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.ab-field,
.ab-operator,
.ab-value {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    color: #1f2937;
    transition: all 0.2s;
}

.ab-field:focus,
.ab-operator:focus,
.ab-value:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.ab-field {
    min-width: 160px;
}

.ab-operator {
    min-width: 100px;
}

.ab-value {
    min-width: 120px;
}

.ab-value.ab-number {
    width: 80px;
    min-width: 80px;
}

.ab-suffix {
    font-size: 12px;
    color: #6b7280;
    margin-left: 4px;
}

.ab-value-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ab-remove-rule {
    width: 28px;
    height: 28px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: auto;
}

.ab-remove-rule:hover {
    background: #dc2626;
    color: #fff;
}

.ab-add-rule-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: transparent;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ab-add-rule-btn:hover {
    border-color: #0071e3;
    color: #0071e3;
    background: rgba(0, 113, 227, 0.05);
}

.ab-add-rule-btn span {
    font-size: 16px;
    font-weight: 700;
}

/* ==========================================================================
   MULTI-SELECT
   ========================================================================== */

.ab-multi-select {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ab-multi-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f5f5f7;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    color: #424245;
    cursor: pointer;
    transition: all 0.2s;
}

.ab-multi-option:hover {
    background: #e8e8ed;
}

.ab-multi-option.selected,
.ab-multi-option:has(input:checked) {
    background: #0071e3;
    border-color: #0071e3;
    color: #fff;
}

.ab-multi-option input {
    display: none;
}

/* ==========================================================================
   USER PICKER
   ========================================================================== */

.ab-user-picker-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.ab-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 12px;
}

.ab-user-search-wrap {
    position: relative;
}

.ab-user-search,
.ab-event-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    transition: all 0.2s;
}

.ab-user-search:focus,
.ab-event-search:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.ab-user-results,
.ab-event-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.ab-user-result,
.ab-event-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.ab-user-result:hover,
.ab-event-result:hover {
    background: #f0f9ff;
}

.ab-user-name,
.ab-event-title {
    font-weight: 600;
    font-size: 13px;
    color: #1f2937;
}

.ab-user-email,
.ab-event-date {
    font-size: 12px;
    color: #6b7280;
}

.ab-user-program {
    font-size: 11px;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.ab-selected-users,
.ab-selected-events {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.ab-user-tag,
.ab-event-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    color: #0369a1;
}

.ab-user-remove,
.ab-event-remove {
    width: 18px;
    height: 18px;
    border: none;
    background: #0369a1;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ab-user-remove:hover,
.ab-event-remove:hover {
    background: #dc2626;
}

/* ==========================================================================
   EVENT PICKER
   ========================================================================== */

.ab-event-picker {
    position: relative;
    min-width: 200px;
}

.ab-event-picker .ab-event-search {
    width: 100%;
}

.ab-event-picker .ab-event-results {
    width: 100%;
}

.ab-event-picker .ab-selected-events {
    margin-top: 8px;
}

.ab-event-tag {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #fcd34d;
    color: #92400e;
}

.ab-event-remove {
    background: #92400e;
}

/* ==========================================================================
   STATES & UTILITIES
   ========================================================================== */

.ab-loading {
    padding: 12px;
    text-align: center;
    color: #6b7280;
    font-size: 13px;
}

.ab-no-results {
    padding: 12px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.ab-error {
    padding: 12px;
    text-align: center;
    color: #dc2626;
    font-size: 13px;
}

.ab-hint {
    padding: 12px;
    text-align: center;
    color: #6b7280;
    font-size: 12px;
    font-style: italic;
}

.ab-note {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .ab-wrapper {
        padding: 15px;
    }
    
    .ab-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .ab-count {
        align-self: flex-end;
    }
    
    .ab-presets {
        justify-content: center;
    }
    
    .ab-rule {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ab-field,
    .ab-operator,
    .ab-value {
        width: 100%;
        min-width: unset;
    }
    
    .ab-remove-rule {
        align-self: flex-end;
        margin-left: 0;
        margin-top: 8px;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT (if needed in future)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* ==========================================================================
   ANIMATION
   ========================================================================== */

@keyframes abFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ab-rule {
    animation: abFadeIn 0.2s ease;
}

.ab-user-tag,
.ab-event-tag {
    animation: abFadeIn 0.15s ease;
}

/* ==========================================================================
   INTEGRATION WITH SEC ADMIN STYLES
   ========================================================================== */

.sec-panel .ab-wrapper {
    background: transparent;
    box-shadow: none;
    padding: 0;
    margin-bottom: 0;
}

.sec-panel .ab-header {
    border-bottom: none;
    padding-bottom: 8px;
}

.sec-panel .ab-custom-panel {
    background: #f8fafc;
}
