/* views/global/ai-tasks/ai-tasks.css
 *
 * Two-column dashboard layout for the AI Tasks popup, with editorial
 * typography and Linear/Stripe-style polish.
 *
 * STRUCTURE
 * ─────────
 *   .ai-tasks-popup                          (modal-body content root)
 *     .ai-tasks-hero-subtitle                (description below modal title)
 *     .ai-tasks-grid                         (CSS Grid: 1fr 320px on desktop)
 *       .ai-tasks-form                       (left column — sections)
 *         .ai-section                        (one per visual group)
 *           .ai-section-title                (UPPERCASE TRACKED heading)
 *           .ai-section-subtitle             (optional)
 *           .ai-field                        (label + input + help)
 *           .ai-switch-list > .ai-switch-row (for the context section)
 *       .ai-tasks-checkout                   (right column, sticky)
 *         .ai-checkout-card                  (cost + plan + CTA + details)
 *         .ai-checkout-cancel                (cancel button under the card)
 *
 * RESPONSIVE
 * ──────────
 *   ≥ 768px → 2 columns, checkout sticky to top.
 *   < 768px → 1 column, checkout drops to end of flow.
 *
 * THEMING
 * ───────
 *   All colors come from CSS vars defined in global.css, with safe fallbacks.
 *   Money amounts use font-variant-numeric: tabular-nums for alignment.
 */


/* ═══════════════════════════════════════════════════════════════════════
   POPUP SHELL
   ═══════════════════════════════════════════════════════════════════════ */

.ai-tasks-popup {
    padding: 0;
}

.ai-tasks-hero-subtitle {
    margin: 0 0 18px 0;
    color: var(--color-label-secondary, #5A6B7A);
    font-size: 14px;
    line-height: 1.5;
    max-width: 680px;
}

.ai-tasks-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: start;
}

.ai-tasks-form {
    min-width: 0;
}


/* ═══════════════════════════════════════════════════════════════════════
   SECTIONS — compacted
   ═══════════════════════════════════════════════════════════════════════ */

.ai-section {
    background: var(--surface-tertiary, #FFFFFF);
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 12px;
}

.ai-section:last-child {
    margin-bottom: 0;
}

.ai-section-title {
    margin: 0 0 14px 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-label-tertiary, #8A9CA8);
}

.ai-section-subtitle {
    margin: -10px 0 14px 0;
    font-size: 12.5px;
    color: var(--color-label-secondary, #5A6B7A);
}


/* ═══════════════════════════════════════════════════════════════════════
   FIELDS — non-checkbox (text, textarea, select, number)
   ═══════════════════════════════════════════════════════════════════════ */

.ai-field {
    margin-bottom: 14px;
}

.ai-field:last-child {
    margin-bottom: 0;
}

.ai-field-label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-label-primary, #2A445A);
}

.ai-field-help {
    margin-top: 5px;
    font-size: 12px;
    color: var(--color-label-tertiary, #8A9CA8);
    line-height: 1.4;
}

.ai-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--separator-strong, rgba(0, 0, 0, 0.18));
    border-radius: 7px;
    background: var(--surface-primary, #FFFFFF);
    color: var(--color-label-primary, #2A445A);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.ai-input:focus {
    border-color: var(--color-brand-primary, #417F9E);
    box-shadow: 0 0 0 3px var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.15));
}

.ai-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--surface-secondary, #F5F7F8);
}

.ai-textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.5;
}

.ai-select-wrap {
    position: relative;
}

.ai-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%235A6B7A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}


/* ═══════════════════════════════════════════════════════════════════════
   SWITCH ROWS — compacted
   ═══════════════════════════════════════════════════════════════════════ */

.ai-switch-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 12px;
    background: var(--surface-secondary, #F5F7F8);
    border: 1px solid transparent;
    border-radius: 8px;
    transition: border-color 120ms ease, background 120ms ease;
}

.ai-switch-row:has(input:checked) {
    background: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.08));
    border-color: rgba(65, 127, 158, 0.20);
}

.ai-switch-row-text {
    flex: 1;
    min-width: 0;
}

.ai-switch-row-label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-label-primary, #2A445A);
    line-height: 1.3;
    cursor: pointer;
}

.ai-switch-row-help {
    margin-top: 2px;
    font-size: 12px;
    color: var(--color-label-tertiary, #8A9CA8);
    line-height: 1.4;
}

.ai-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}

.ai-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.ai-switch-track {
    position: absolute;
    inset: 0;
    background: #C9D2D8;
    border-radius: 22px;
    transition: background 160ms ease;
}

.ai-switch-track::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #FFFFFF;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    transition: transform 160ms ease;
}

.ai-switch input:checked~.ai-switch-track {
    background: var(--color-brand-primary, #417F9E);
}

.ai-switch input:checked~.ai-switch-track::before {
    transform: translateX(16px);
}

.ai-switch input:focus-visible~.ai-switch-track {
    box-shadow: 0 0 0 3px var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.30));
}


/* ═══════════════════════════════════════════════════════════════════════
   CHECKOUT (right column) — compacted, model picker added
   ═══════════════════════════════════════════════════════════════════════ */

.ai-tasks-checkout {
    position: sticky;
    top: 4px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-checkout-card {
    background: var(--surface-tertiary, #FFFFFF);
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.10));
    border-radius: 12px;
    padding: 18px 18px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ai-checkout-loading {
    color: var(--color-label-tertiary, #8A9CA8);
    font-style: italic;
    font-size: 13px;
    text-align: center;
    padding: 12px 0;
}

.ai-checkout-error {
    color: #9A3441;
    background: rgba(178, 58, 72, 0.06);
    border: 1px solid rgba(178, 58, 72, 0.25);
    border-radius: 7px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
}

/* Cost block — the headline */
.ai-checkout-cost {
    text-align: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
    margin-bottom: 14px;
}

.ai-checkout-cost-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-label-tertiary, #8A9CA8);
    margin-bottom: 4px;
}

.ai-checkout-cost-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-label-primary, #2A445A);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

/* Model picker block — between cost and plan, separated by hairlines */
.ai-checkout-model {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
    margin-bottom: 14px;
}

.ai-checkout-model-label {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-label-tertiary, #8A9CA8);
    margin-bottom: 6px;
}

/* Plan block — sits between model and CTA */
.ai-checkout-plan {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    border-left: 3px solid;
}

.ai-checkout-plan.ok {
    background: rgba(46, 125, 50, 0.05);
    border-left-color: #2E7D32;
}

.ai-checkout-plan.muted {
    background: var(--surface-secondary, #F5F7F8);
    border-left-color: var(--color-label-tertiary, #8A9CA8);
}

.ai-checkout-plan.warn {
    background: rgba(204, 153, 51, 0.08);
    border-left-color: rgba(204, 153, 51, 0.65);
}

.ai-checkout-plan.danger {
    background: rgba(178, 58, 72, 0.06);
    border-left-color: rgba(178, 58, 72, 0.65);
}

.ai-checkout-plan-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-label-primary, #2A445A);
    margin-bottom: 3px;
}

.ai-checkout-plan-body {
    font-size: 12.5px;
    color: var(--color-label-secondary, #5A6B7A);
    line-height: 1.45;
}

.ai-checkout-plan-body strong {
    color: var(--color-label-primary, #2A445A);
    font-variant-numeric: tabular-nums;
}

.ai-checkout-cta {
    width: 100%;
    margin-top: 0;
    font-size: 14px;
    padding: 10px 14px;
}

.ai-btn-warn {
    background: #D69826 !important;
    border-color: #B98620 !important;
}

.ai-btn-warn:hover:not(:disabled) {
    background: #C28819 !important;
    border-color: #A37214 !important;
}

.ai-checkout-details {
    margin-top: 12px;
    font-size: 12px;
}

.ai-checkout-details>summary {
    cursor: pointer;
    color: var(--color-label-tertiary, #8A9CA8);
    user-select: none;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    transition: color 120ms ease;
}

.ai-checkout-details>summary::-webkit-details-marker {
    display: none;
}

.ai-checkout-details>summary::before {
    content: '▸';
    font-size: 9px;
    transition: transform 120ms ease;
}

.ai-checkout-details[open]>summary::before {
    transform: rotate(90deg);
}

.ai-checkout-details>summary:hover {
    color: var(--color-label-secondary, #5A6B7A);
}

.ai-checkout-dl {
    margin: 8px 0 0 14px;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 5px 14px;
    font-variant-numeric: tabular-nums;
}

.ai-checkout-dl dt {
    font-weight: 500;
    color: var(--color-label-tertiary, #8A9CA8);
}

.ai-checkout-dl dd {
    margin: 0;
    color: var(--color-label-secondary, #5A6B7A);
}

.ai-checkout-cancel {
    width: 100%;
}


/* ═══════════════════════════════════════════════════════════════════════
   PLANS POPUP (popup #2 — plan picker)
   ═══════════════════════════════════════════════════════════════════════ */

.ai-plans-popup {
    padding: 0;
}

.ai-plans-intro {
    margin: 0 0 24px 0;
    color: var(--color-label-secondary, #5A6B7A);
    font-size: 14.5px;
    line-height: 1.55;
}

.ai-plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

/* Each plan is a clickable card. The native radio is visually hidden but
   we use :has(input:checked) to highlight the card. */
.ai-plan-card {
    position: relative;
    display: block;
    background: var(--surface-tertiary, #FFFFFF);
    border: 2px solid var(--separator-default, rgba(0, 0, 0, 0.10));
    border-radius: 12px;
    padding: 18px 18px 16px;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.ai-plan-card:hover {
    border-color: rgba(65, 127, 158, 0.40);
    transform: translateY(-1px);
}

.ai-plan-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ai-plan-card.is-selected,
.ai-plan-card:has(input:checked) {
    border-color: var(--color-brand-primary, #417F9E);
    background: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.04));
}

.ai-plan-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-label-primary, #2A445A);
    margin-bottom: 6px;
}

.ai-plan-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-label-primary, #2A445A);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    margin-bottom: 10px;
}

.ai-plan-period {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-label-tertiary, #8A9CA8);
    margin-left: 2px;
}

.ai-plan-desc {
    font-size: 13px;
    color: var(--color-label-secondary, #5A6B7A);
    line-height: 1.5;
}

.ai-plan-badge {
    position: absolute;
    top: -10px;
    right: 14px;
    background: var(--color-brand-primary, #417F9E);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 999px;
    box-shadow: 0 2px 4px rgba(65, 127, 158, 0.25);
}

/* Terms block — re-uses .ai-switch-row but slightly different padding */
.ai-plans-terms {
    margin-bottom: 24px;
}

.ai-plans-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
}


/* ═══════════════════════════════════════════════════════════════════════
   SUGGESTION COMPARE (used on detail / review pages)
   ═══════════════════════════════════════════════════════════════════════ */

.ai-suggestion-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.ai-suggestion-compare-cell {
    border: 1px solid rgba(42, 68, 90, 0.15);
    border-radius: 8px;
    padding: 0.75rem;
    background: white;
}

.ai-suggestion-compare-label {
    color: var(--color-label-secondary, #5A6B7A);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.ai-suggestion-compare-image {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* Body text inside a comparison cell. Default styling for the description
   prose. Title variant gets heavier weight and slightly larger size so the
   visual hierarchy matches the conceptual one (title is the heading of a
   product page; description is the body). */
.ai-suggestion-text {
    font-size: 14px;
    color: var(--color-label-primary, #2A445A);
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-suggestion-text-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
}


/* ═══════════════════════════════════════════════════════════════════════
   BATCH QUEUE — shown between review modals when others are still running
   ═══════════════════════════════════════════════════════════════════════ */

.ai-batch-queue {
    padding: 0;
}

.ai-batch-intro {
    margin: 0 0 14px 0;
    color: var(--color-label-secondary, #5A6B7A);
    font-size: 13.5px;
    line-height: 1.5;
}

.ai-batch-list {
    list-style: none;
    margin: 0 0 14px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.ai-batch-item {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface-secondary, #F5F7F8);
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 13.5px;
    transition: background 160ms ease;
}

.ai-batch-item-icon {
    font-size: 16px;
    text-align: center;
    line-height: 1;
}

.ai-batch-item-label {
    color: var(--color-label-primary, #2A445A);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-batch-item-status {
    color: var(--color-label-tertiary, #8A9CA8);
    font-size: 12.5px;
}

/* State variants */
.ai-batch-item-reviewed {
    background: rgba(46, 125, 50, 0.04);
    color: var(--color-label-tertiary, #8A9CA8);
}

.ai-batch-item-reviewed .ai-batch-item-icon {
    color: #2E7D32;
}

.ai-batch-item-reviewed .ai-batch-item-label {
    color: var(--color-label-secondary, #5A6B7A);
}

.ai-batch-item-done {
    background: rgba(46, 125, 50, 0.08);
    border-color: rgba(46, 125, 50, 0.18);
}

.ai-batch-item-done .ai-batch-item-icon {
    color: #2E7D32;
}

.ai-batch-item-done .ai-batch-item-status {
    color: #2E7D32;
    font-weight: 600;
}

.ai-batch-item-running {
    background: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.07));
    border-color: rgba(65, 127, 158, 0.16);
}

.ai-batch-item-running .ai-batch-item-icon {
    animation: ai-batch-pulse 1.4s ease-in-out infinite;
}

@keyframes ai-batch-pulse {

    0%,
    100% {
        opacity: 0.45;
    }

    50% {
        opacity: 1;
    }
}

.ai-batch-item-pending .ai-batch-item-icon {
    color: var(--color-label-tertiary, #8A9CA8);
}

.ai-batch-item-failed {
    background: rgba(178, 58, 72, 0.06);
    border-color: rgba(178, 58, 72, 0.22);
}

.ai-batch-item-failed .ai-batch-item-icon {
    color: #9A3441;
}

.ai-batch-item-failed .ai-batch-item-status {
    color: #9A3441;
}

.ai-batch-summary {
    margin: 0 0 14px 0;
    font-size: 12.5px;
    color: var(--color-label-tertiary, #8A9CA8);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ai-batch-actions {
    display: flex;
    justify-content: center;
    padding-top: 12px;
    border-top: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
}


/* ═══════════════════════════════════════════════════════════════════════
   UNRESOLVED WARNING — opens before config modal when pending exist
   ═══════════════════════════════════════════════════════════════════════ */

.ai-unresolved-popup {
    padding: 0;
}

.ai-unresolved-intro {
    margin: 0 0 16px 0;
    color: var(--color-label-primary, #2A445A);
    font-size: 14.5px;
    line-height: 1.5;
}

.ai-unresolved-list {
    list-style: none;
    margin: 0 0 14px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.ai-unresolved-item {
    padding: 12px 14px;
    background: var(--surface-secondary, #F5F7F8);
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.06));
    border-radius: 8px;
    transition: border-color 120ms ease, background 120ms ease;
}

.ai-unresolved-item.is-clickable {
    cursor: pointer;
}

.ai-unresolved-item.is-clickable:hover {
    background: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.06));
    border-color: var(--color-brand-primary, rgba(65, 127, 158, 0.35));
}

.ai-unresolved-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-label-primary, #2A445A);
    line-height: 1.35;
    margin-bottom: 2px;
}

.ai-unresolved-item-title em {
    color: var(--color-label-tertiary, #8A9CA8);
    font-style: italic;
    font-weight: 400;
}

.ai-unresolved-item-meta {
    font-size: 12.5px;
    color: var(--color-label-tertiary, #8A9CA8);
}

.ai-unresolved-hint {
    margin: 0 0 18px 0;
    font-size: 12.5px;
    color: var(--color-label-tertiary, #8A9CA8);
    line-height: 1.45;
}

.ai-unresolved-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
}

.ai-unresolved-actions-right {
    display: flex;
    gap: 8px;
}

@media (max-width: 540px) {
    .ai-unresolved-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-unresolved-actions-right {
        flex-direction: column-reverse;
    }
}


/* ═══════════════════════════════════════════════════════════════════════
   REVIEW MODAL — opens after a successful single-task generation
   ═══════════════════════════════════════════════════════════════════════ */

.ai-review-popup {
    padding: 0;
}

.ai-review-intro {
    margin: 0 0 18px 0;
    color: var(--color-label-secondary, #5A6B7A);
    font-size: 14px;
    line-height: 1.55;
}

/* Product context panel — appears above the diffs so the admin can
   evaluate whether the IA's output makes sense given what THE IA SAW.
   Drift-proof: this data is the snapshot at generation time, not live. */
.ai-review-context {
    background: var(--surface-secondary, #F5F7F8);
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.06));
    border-radius: 10px;
    margin-bottom: 22px;
    overflow: hidden;
}

.ai-review-context-header {
    padding: 8px 14px;
    background: rgba(65, 127, 158, 0.08);
    border-bottom: 1px solid rgba(65, 127, 158, 0.14);
}

.ai-review-context-eyebrow {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-brand-primary, #417F9E);
}

.ai-review-context-body {
    display: flex;
    gap: 16px;
    padding: 14px;
    align-items: flex-start;
}

.ai-review-context-image {
    flex-shrink: 0;
    width: 140px;
    height: 140px;
    background: #FFFFFF;
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    box-sizing: border-box;
}

.ai-review-context-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.ai-review-context-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-review-context-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.ai-review-context-row-specs {
    flex-direction: column;
    gap: 4px;
}

.ai-review-context-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-label-tertiary, #8A9CA8);
    flex-shrink: 0;
    min-width: 96px;
    padding-top: 2px;
}

.ai-review-context-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-label-primary, #2A445A);
    font-variant-numeric: tabular-nums;
}

.ai-review-context-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

.ai-review-chip {
    display: inline-block;
    padding: 3px 9px;
    background: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.10));
    color: var(--color-brand-primary, #417F9E);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.ai-review-specs-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    width: 100%;
}

.ai-review-spec-row {
    display: flex;
    gap: 8px;
    font-size: 12.5px;
    min-width: 0;
}

.ai-review-spec-name {
    color: var(--color-label-tertiary, #8A9CA8);
    flex-shrink: 0;
}

.ai-review-spec-name::after {
    content: ':';
    margin-right: 4px;
}

.ai-review-spec-value {
    color: var(--color-label-primary, #2A445A);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .ai-review-context-body {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-review-context-image {
        width: 100%;
        height: 160px;
    }

    .ai-review-context-row {
        flex-wrap: wrap;
    }

    .ai-review-specs-list {
        grid-template-columns: 1fr;
    }
}

.ai-review-section {
    margin-bottom: 24px;
}

.ai-review-section:last-of-type {
    margin-bottom: 18px;
}

.ai-review-section-title {
    margin: 0 0 10px 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-label-tertiary, #8A9CA8);
}

/* 2-column diff grid. Left = actual (read-only quieter), right = editable. */
.ai-review-diff {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: stretch;
}

.ai-review-diff-cell {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ai-review-diff-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-label-tertiary, #8A9CA8);
    margin-bottom: 6px;
}

/* Actual cell — quieter, with a subtle background to differentiate from
   the editable right side. Padded box to match the rough height of the
   input on the right. */
.ai-review-diff-actual .ai-review-diff-value {
    flex: 1;
    background: var(--surface-secondary, #F5F7F8);
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.06));
    border-radius: 7px;
    padding: 10px 13px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-label-secondary, #5A6B7A);
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 42px;
}

/* Title variant — heavier weight, slightly larger, single-line feel */
.ai-review-diff-value-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--color-label-primary, #2A445A) !important;
}

.ai-review-diff-empty {
    color: var(--color-label-tertiary, #8A9CA8);
    font-style: italic;
}

/* Editable cell — uses the same .ai-input styling as the config modal,
   no additional rules needed beyond making it stretch to match. */
.ai-review-input {
    flex: 1;
}

.ai-review-input-title {
    font-size: 15px;
    font-weight: 600;
}

/* Action bar — split: Descartar isolated on left (destructive intent),
   Regenerar + Aplicar grouped on right. Discard styled as ghost so it
   reads as "no-op for the product, just cleanup". */
.ai-review-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
}

.ai-review-actions-right {
    display: flex;
    gap: 8px;
}

.ai-review-discard {
    color: #9A3441;
}

.ai-review-discard:hover {
    background: rgba(178, 58, 72, 0.06);
    color: #9A3441;
}

@media (max-width: 700px) {
    .ai-review-diff {
        grid-template-columns: 1fr;
    }

    .ai-review-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-review-actions-right {
        flex-direction: column-reverse;
    }
}


/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .ai-tasks-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .ai-tasks-checkout {
        position: static;
    }

    .ai-suggestion-compare {
        grid-template-columns: 1fr;
    }
}
/* ═══════════════════════════════════════════════════════════════════════
   REMOVE BACKGROUND — picker grid + review modal
   ═══════════════════════════════════════════════════════════════════════ */

/* Files grid in the config popup ───────────────────────────────────────── */

.ai-task-files-grid-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-task-files-grid-loading,
.ai-task-files-grid-empty {
    padding: 24px;
    text-align: center;
    color: var(--color-label-tertiary, #8A9CA8);
    font-size: 13.5px;
    background: var(--surface-secondary, #F5F7F8);
    border-radius: 8px;
}

.ai-task-files-group {
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.06));
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--surface-secondary, #F5F7F8);
}

.ai-task-files-group-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-label-primary, #2A445A);
    margin-bottom: 10px;
}

.ai-task-files-group-empty {
    font-size: 12.5px;
    color: var(--color-label-tertiary, #8A9CA8);
    font-style: italic;
}

.ai-task-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.ai-task-files-thumb {
    position: relative;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    background: #FFFFFF;
    transition: border-color 0.15s ease, transform 0.15s ease;
    display: block;
}

.ai-task-files-thumb:hover {
    border-color: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.25));
}

.ai-task-files-thumb-check {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-brand-primary, #417F9E);
}

.ai-task-files-thumb-check:checked ~ .ai-task-files-thumb-img,
.ai-task-files-thumb:has(.ai-task-files-thumb-check:checked) {
    border-color: var(--color-brand-primary, #417F9E);
}

.ai-task-files-thumb:has(.ai-task-files-thumb-check:checked) {
    border-color: var(--color-brand-primary, #417F9E);
}

.ai-task-files-thumb-img {
    position: absolute;
    inset: 0;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #FFFFFF;
}

.ai-task-files-thumb-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 13px;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.ai-task-files-thumb-pending {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(245, 158, 11, 0.95);
    color: #FFFFFF;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
    line-height: 1.2;
}

.ai-task-files-thumb.has-pending {
    opacity: 0.7;
}

/* Image review modal ───────────────────────────────────────────────────── */

.ai-image-review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 8px;
}

.ai-image-review-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-image-review-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--color-label-tertiary, #8A9CA8);
}

.ai-image-review-frame {
    aspect-ratio: 1 / 1;
    width: 100%;
    background: #FFFFFF;
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-image-review-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ai-image-review-empty {
    color: var(--color-label-tertiary, #8A9CA8);
    font-size: 13px;
    font-style: italic;
}

@media (max-width: 720px) {
    .ai-image-review-grid {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   RECENT CONFIGS — button in form header + picker modal
   ═══════════════════════════════════════════════════════════════════════ */

.ai-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.ai-section-header .ai-section-title {
    margin-bottom: 0;
}

.ai-recent-configs-btn {
    background: transparent;
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.12));
    color: var(--color-brand-primary, #417F9E);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.ai-recent-configs-btn:hover {
    background: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.08));
    border-color: var(--color-brand-primary, #417F9E);
}

/* Picker modal ────────────────────────────────────────────────────────── */

.ai-recent-configs-popup {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-recent-configs-intro {
    font-size: 13px;
    color: var(--color-label-secondary, #5A6B7A);
    margin: 0;
}

.ai-recent-configs-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 420px;
    overflow-y: auto;
}

.ai-recent-config-item {
    padding: 10px 12px;
    border: 1px solid var(--separator-default, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.ai-recent-config-item:hover {
    border-color: var(--color-brand-primary, #417F9E);
    background: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.05));
}

.ai-recent-config-item.is-mine {
    border-color: var(--color-brand-primary-subtle, rgba(65, 127, 158, 0.4));
    background: rgba(65, 127, 158, 0.03);
}

.ai-recent-config-line1 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--color-label-primary, #2A445A);
    margin-bottom: 4px;
}

.ai-recent-config-star {
    color: #F5A623;
    font-size: 14px;
    line-height: 1;
}

.ai-recent-config-user {
    font-weight: 600;
}

.ai-recent-config-sep {
    color: var(--color-label-tertiary, #8A9CA8);
}

.ai-recent-config-when,
.ai-recent-config-model {
    color: var(--color-label-secondary, #5A6B7A);
}

.ai-recent-config-prompt {
    font-size: 12.5px;
    color: var(--color-label-secondary, #5A6B7A);
    line-height: 1.45;
    font-style: italic;
}

.ai-recent-configs-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
