// AI Bulk Post - Admin Styles

// Variables.
$primary: #2271b1;
$primary-hover: #135e96;
$success: #00a32a;
$success-light: #d4edda;
$warning: #dba617;
$danger: #d63638;
$border: #e0e0e0;
$border-light: #f0f0f1;
$bg-light: #f6f7f7;
$bg-white: #fff;
$text: #1d2327;
$text-light: #787c82;
$radius: 12px;
$radius-sm: 6px;
$shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 1px 2px rgba(0, 0, 0, 0.06);
$shadow-hover:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04);

// Reset WP default margin.
.aibp-admin-app {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;

    > .wrap {
        margin: 0;
        padding: 0;
    }
}

// Navigation tabs.
.aibp-nav {
    display: inline-flex;
    gap: 0;
    margin-bottom: 28px;
    border-bottom: 2px solid $border;
}

.aibp-nav-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: $text-light;
    transition: all 0.15s ease;
    position: relative;

    &:hover {
        color: $text;
        background: $bg-light;
    }

    &.aibp-nav-tab-active {
        color: $primary;
        font-weight: 600;
        border-bottom-color: $primary;
    }
}

// Header row.
.aibp-header {
    display: flex;
    align-items: end;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;

    h1 {
        margin: 0;
        font-size: 24px;
        font-weight: 700;
        color: $text;
    }

    .wp-header-end {
        display: none;
    }
}

// Toolbar.
.aibp-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    align-items: center;
}

.aibp-search {
    flex: 1;
    max-width: 320px;
    padding: 8px 14px;
    border: 1px solid $border;
    border-radius: $radius-sm;
    font-size: 14px;
    background: $bg-white;
    transition: border-color 0.15s ease;

    &:focus {
        border-color: $primary;
        box-shadow: 0 0 0 1px $primary;
        outline: none;
    }

    &::placeholder {
        color: #a7aaad;
    }
}

.aibp-filter-select {
    padding: 8px 14px;
    border: 1px solid $border;
    border-radius: $radius-sm;
    font-size: 14px;
    background: $bg-white;
    color: $text;
    cursor: pointer;

    &:focus {
        border-color: $primary;
        outline: none;
    }
}

// Agents grid.
.aibp-agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

// Agent card.
.aibp-agent-card {
    background: $bg-white;
    border: 1px solid $border;
    border-radius: $radius;
    overflow: hidden;
    transition:
        box-shadow 0.2s ease,
        border-color 0.2s ease;

    &:hover {
        box-shadow: $shadow-hover;
        border-color: darken($border, 5%);
    }

    &.aibp-agent-active {
        border-top: 3px solid $success;
    }

    &.aibp-agent-passive {
        border-top: 3px solid $border;
    }
}

.aibp-agent-card-top {
    padding: 20px 20px 16px;
}

.aibp-agent-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.aibp-agent-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    flex-shrink: 0;
}

.aibp-agent-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: $text;
    line-height: 1.3;
}

.aibp-agent-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.aibp-agent-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: $radius-sm;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.aibp-agent-model-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: $radius-sm;
    font-size: 12px;
    font-weight: 500;
    color: $text-light;
    background: $bg-light;
}

.aibp-agent-card-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aibp-agent-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: $text-light;

    strong {
        color: $text;
        font-weight: 600;
    }
}

.aibp-agent-detail-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}

// Card actions.
.aibp-agent-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid $border-light;
    background: $bg-light;
}

.aibp-agent-actions-primary {
    display: flex;
    gap: 6px;
}

.aibp-agent-actions-secondary {
    display: flex;
    gap: 2px;
}

.aibp-agent-card-actions {
    .button {
        font-size: 12px;
        padding: 5px 12px;
        border-radius: $radius-sm;
        font-weight: 500;
        line-height: 1.4;
    }
}

.aibp-btn-icon {
    padding: 4px 8px !important;
    font-size: 16px !important;
    color: $text-light !important;
    background: transparent !important;
    border: none !important;
    min-width: 28px;
    text-align: center;
    box-shadow: none !important;

    &:hover {
        color: $text !important;
        background: rgba(0, 0, 0, 0.06) !important;
    }
}

.aibp-btn-danger-text {
    &:hover {
        color: $danger !important;
    }
}

// Buttons.
.aibp-btn-primary {
    background: $primary !important;
    color: #fff !important;
    border-color: $primary !important;

    &:hover {
        background: $primary-hover !important;
        border-color: $primary-hover !important;
    }
}

.aibp-btn-success {
    color: $success !important;
    border-color: $success !important;
}

.aibp-btn-success-outline {
    color: $success !important;
    border-color: $success !important;
    background: $success-light !important;

    &:hover {
        background: darken($success-light, 5%) !important;
    }
}

.aibp-btn-danger {
    color: $danger !important;
    border-color: $danger !important;
}

// Modal.
.aibp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: aibp-fade-in 0.15s ease;
}

@keyframes aibp-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.aibp-modal {
    background: $bg-white;
    border-radius: $radius;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: aibp-slide-up 0.2s ease;
}

@keyframes aibp-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.aibp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid $border;

    h2 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
    }
}

.aibp-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: $text-light;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;

    &:hover {
        color: $text;
        background: $bg-light;
    }
}

.aibp-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;

    h3 {
        margin: 24px 0 14px;
        padding-bottom: 10px;
        border-bottom: 1px solid $border-light;
        font-size: 15px;
        font-weight: 600;
        color: $text;

        &:first-child {
            margin-top: 0;
        }
    }
}

.aibp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid $border;
    background: $bg-light;
}

// Form fields.
.aibp-form-field {
    margin-bottom: 16px;

    label {
        display: block;
        margin-bottom: 6px;
        font-weight: 600;
        font-size: 13px;
        color: $text;
    }

    input[type="text"],
    input[type="number"],
    input[type="time"],
    textarea,
    select {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid $border;
        border-radius: $radius-sm;
        font-size: 14px;
        transition:
            border-color 0.15s ease,
            box-shadow 0.15s ease;

        &:focus {
            border-color: $primary;
            box-shadow: 0 0 0 1px $primary;
            outline: none;
        }
    }

    textarea {
        resize: vertical;
        min-height: 80px;
    }
}

.aibp-form-row {
    display: flex;
    gap: 16px;

    .aibp-form-field {
        flex: 1;
    }
}

.aibp-form-field-suffix {
    margin-left: 8px;
    font-size: 13px;
    color: $text-light;
}

.aibp-input-error {
    border-color: $danger !important;
    box-shadow: 0 0 0 1px $danger !important;
}

.aibp-error {
    display: block;
    color: $danger;
    font-size: 12px;
    margin-top: 4px;
}

.aibp-checkbox-label {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    font-weight: normal !important;
    font-size: 13px !important;
    margin-right: 12px;
    margin-bottom: 6px;
    cursor: pointer;
}

.aibp-category-list {
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid $border;
    border-radius: $radius-sm;
    background: $bg-light;
}

.aibp-radio-group {
    display: flex;
    gap: 20px;
}

.aibp-radio-label {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    font-weight: normal !important;
    cursor: pointer;
}

.aibp-day-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.aibp-day-btn {
    padding: 7px 14px;
    border: 1px solid $border;
    border-radius: $radius-sm;
    background: $bg-white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;

    &:hover {
        border-color: $primary;
        color: $primary;
        background: lighten($primary, 42%);
    }

    &.aibp-day-active {
        background: $primary;
        border-color: $primary;
        color: #fff;

        &:hover {
            background: $primary-hover;
            border-color: $primary-hover;
            color: #fff;
        }
    }
}

// Notifications.
.aibp-notice {
    padding: 12px 16px;
    border-radius: $radius-sm;
    margin-bottom: 16px;
    font-size: 14px;
    animation: aibp-fade-in 0.2s ease;
}

.aibp-notice-success {
    background: $success-light;
    border: 1px solid darken($success-light, 5%);
    color: #155724;
}

.aibp-notice-error {
    background: #fce4e4;
    border: 1px solid darken(#fce4e4, 5%);
    color: #721c24;
}

// Empty state.
.aibp-empty-state {
    text-align: center;
    padding: 80px 40px;
    background: $bg-white;
    border: 2px dashed $border;
    border-radius: $radius;

    h2 {
        margin: 0 0 10px;
        color: $text;
        font-size: 20px;
    }

    p {
        color: $text-light;
        margin: 0 0 24px;
        font-size: 15px;
    }

    .aibp-btn-primary {
        padding: 10px 24px;
        font-size: 14px;
    }
}

// Loading.
.aibp-loading {
    text-align: center;
    padding: 60px;
    color: $text-light;
    font-size: 14px;

    .spinner {
        float: none;
        margin: 0 10px 0 0;
    }
}

// Settings.
.aibp-settings {
    max-width: 700px;

    h1 {
        margin: 0 0 24px;
        font-size: 24px;
    }
}

.aibp-settings-card {
    background: $bg-white;
    border: 1px solid $border;
    border-radius: $radius;
    padding: 24px;
    margin-bottom: 16px;

    h2 {
        margin: 0 0 18px;
        font-size: 16px;
        font-weight: 600;
        padding-bottom: 10px;
        border-bottom: 1px solid $border-light;
    }
}

.aibp-settings-field {
    margin-bottom: 18px;

    label {
        display: block;
        margin-bottom: 6px;
        font-weight: 600;
        font-size: 13px;
    }

    .regular-text {
        width: 100%;
    }

    .small-text {
        width: 80px;
    }
}

.aibp-settings-input-row {
    display: flex;
    gap: 8px;
    align-items: center;

    input {
        flex: 1;
    }
}

.aibp-settings-actions {
    padding: 16px 0;
}

// Responsive.
@media (max-width: 782px) {
    .aibp-agents-grid {
        grid-template-columns: 1fr;
    }

    .aibp-form-row {
        flex-direction: column;
        gap: 0;
    }

    .aibp-modal {
        max-height: 95vh;
    }

    .aibp-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .aibp-search {
        max-width: 100%;
    }

    .aibp-agent-card-actions {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .aibp-agent-actions-primary {
        justify-content: center;
    }

    .aibp-agent-actions-secondary {
        justify-content: center;
    }
}

// Multi-step form styles.
.aibp-modal-lg {
    max-width: 780px;
}

.aibp-progress-bar {
    height: 4px;
    background: $border-light;
    border-radius: 2px;
    margin-bottom: 20px;
    overflow: hidden;
}

.aibp-progress-fill {
    height: 100%;
    background: $primary;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.aibp-step-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.aibp-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: $primary;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.aibp-step-name {
    font-size: 16px;
    font-weight: 600;
    color: $text;
}

.aibp-step-content {
    min-height: 240px;
}

.aibp-label-value {
    margin-left: 8px;
    font-weight: 400;
    font-size: 13px;
    color: $text-light;
}

.aibp-creativity-slider {
    margin-top: 4px;

    input[type="range"] {
        width: 100%;
        height: 6px;
        -webkit-appearance: none;
        appearance: none;
        background: linear-gradient(
            to right,
            $primary 0%,
            lighten($primary, 20%) 50%,
            $primary 100%
        );
        border-radius: 3px;
        outline: none;
        cursor: pointer;

        &::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: $primary;
            cursor: pointer;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
            transition: transform 0.15s ease;
        }

        &::-webkit-slider-thumb:hover {
            transform: scale(1.1);
        }

        &::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: $primary;
            cursor: pointer;
            border: none;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
        }
    }
}

.aibp-creativity-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: $text-light;
}

.aibp-preset-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.aibp-preset-btn {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: $radius-sm;
    transition: all 0.15s ease;

    &:hover {
        background: $primary;
        color: #fff;
        border-color: $primary;
    }
}

.aibp-modal-footer-right {
    display: flex;
    gap: 8px;
    margin-left: auto;
}
