/* ============================================================
   ApplyRaft — AI writing help (builder steps 3 and 6)
   Loaded only while AI help is on (layouts/builder.blade.php). Uses the
   --ar-* tokens builder.css defines. Everything stacks at phone width.
   ============================================================ */

.ai-help { margin: 0 0 var(--sp-3, .75rem); }

.ai-help-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
}

.ai-help-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 40px;
    padding: .45rem .9rem;
    border: 1px solid var(--ar-accent, #2F6BF0);
    border-radius: 999px;
    background: var(--ar-accent-soft, #E8F0FE);
    color: var(--ar-accent-ink, #1E4FBF);
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.ai-help-btn:hover:not(:disabled) { background: var(--ar-accent, #2F6BF0); color: #fff; }
.ai-help-btn:focus-visible { outline: 3px solid var(--ar-accent, #2F6BF0); outline-offset: 2px; }
.ai-help-btn:disabled { opacity: .65; cursor: progress; }
.ai-help-btn--small { min-height: 36px; padding: .35rem .8rem; font-size: .85rem; }
.ai-help-btn .ai-help-spark { font-size: 1em; line-height: 1; }

.ai-help-remaining {
    font-size: .82rem;
    color: var(--ar-muted, #5B6B7F);
}
.ai-help-remaining:empty { display: none; }

.ai-help-note {
    margin: .35rem 0 0;
    font-size: .8rem;
    line-height: 1.4;
    color: var(--ar-muted, #5B6B7F);
}
.ai-help-note a { color: var(--ar-accent-ink, #1E4FBF); }

.ai-help-status {
    margin-top: .4rem;
    font-size: .85rem;
    line-height: 1.4;
    color: var(--ar-muted, #5B6B7F);
}
.ai-help-status:empty { display: none; }
.ai-help-status.is-error { color: var(--ar-danger, #B42318); }

.ai-help-spinner {
    display: inline-block;
    width: .9em;
    height: .9em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ai-help-spin .7s linear infinite;
}
@keyframes ai-help-spin { to { transform: rotate(360deg); } }

.ai-help-results {
    margin-top: .75rem;
    padding: .85rem;
    border: 1px solid var(--ar-line, #E2DED6);
    border-radius: var(--ar-radius, 12px);
    background: var(--ar-surface, #fff);
}
.ai-help-results[hidden] { display: none; }

.ai-help-results-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: .25rem .75rem;
    margin-bottom: .6rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ar-ink, #10233A);
}

.ai-help-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--ar-muted, #5B6B7F);
    font: inherit;
    font-size: .82rem;
    text-decoration: underline;
    cursor: pointer;
}
.ai-help-link:hover { color: var(--ar-ink, #10233A); }

.ai-help-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .5rem;
}

.ai-help-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .75rem;
    border: 1px solid var(--ar-line, #E2DED6);
    border-radius: 10px;
    background: var(--ar-bg, #F7F6F2);
    font-size: .9rem;
    line-height: 1.45;
    color: var(--ar-ink, #10233A);
}
.ai-help-card.is-added { border-color: var(--ar-success, #1B7F4C); background: #EEF8F1; }
.ai-help-card-text { flex: 1 1 auto; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ai-help-card--summary { flex-direction: column; align-items: stretch; }

.ai-help-add {
    flex: 0 0 auto;
    min-height: 36px;
    padding: .3rem .85rem;
    border: 1px solid var(--ar-ink, #10233A);
    border-radius: 999px;
    background: var(--ar-ink, #10233A);
    color: #fff;
    font: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}
.ai-help-add:hover:not(:disabled) { background: var(--ar-accent-ink, #1E4FBF); border-color: var(--ar-accent-ink, #1E4FBF); }
.ai-help-add:focus-visible { outline: 3px solid var(--ar-accent, #2F6BF0); outline-offset: 2px; }
.ai-help-add:disabled { background: transparent; color: var(--ar-success, #1B7F4C); border-color: transparent; cursor: default; }
.ai-help-card--summary .ai-help-add { align-self: flex-start; }

.ai-help-results-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    margin-top: .75rem;
}
.ai-help-results-foot .ai-help-note { margin: 0; }

/* Phones: stack the row and give every control the full width to tap. */
@media (max-width: 575.98px) {
    .ai-help-row { align-items: stretch; flex-direction: column; }
    .ai-help-row .ai-help-btn { justify-content: center; }
    .ai-help-card { flex-direction: column; align-items: stretch; }
    .ai-help-add { width: 100%; text-align: center; }
    .ai-help-results-foot .ai-help-btn { width: 100%; justify-content: center; }
}
