/* ============================================================
   RetouchWP — editor.css
   Clean, responsive editor UI.
   ============================================================ */

:root {
    --rwp-accent:       #4F6EF7;
    --rwp-accent-dark:  #3a57e0;
    --rwp-accent-light: #EEF1FE;
    --rwp-bg:           #FAFAFA;
    --rwp-surface:      #FFFFFF;
    --rwp-border:       #E2E5ED;
    --rwp-text:         #1A1D23;
    --rwp-muted:        #6B7280;
    --rwp-error-bg:     #FEF2F2;
    --rwp-error-text:   #B91C1C;
    --rwp-success:      #059669;
    --rwp-radius:       12px;
    --rwp-shadow:       0 2px 12px rgba(0,0,0,.07);
}

/* ── Wrapper ─────────────────────────────────────────────── */
.rwp-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--rwp-text);
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    box-sizing: border-box;
}

.rwp-wrap *, .rwp-wrap *::before, .rwp-wrap *::after {
    box-sizing: border-box;
}

/* ── Upload zone ─────────────────────────────────────────── */
.rwp-upload-zone {
    border: 2px dashed var(--rwp-border);
    border-radius: var(--rwp-radius);
    background: var(--rwp-bg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    outline: none;
}
.rwp-upload-zone:hover,
.rwp-upload-zone:focus,
.rwp-upload-zone.rwp-drag-over {
    border-color: var(--rwp-accent);
    background: var(--rwp-accent-light);
}
.rwp-upload-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
}
.rwp-upload-label {
    font-size: 16px;
    color: var(--rwp-muted);
    margin: 0 0 6px;
}
.rwp-upload-label span {
    color: var(--rwp-accent);
    text-decoration: underline;
    cursor: pointer;
}
.rwp-upload-hint {
    font-size: 13px;
    color: #9CA3AF;
    margin: 0;
}

/* ── Canvas section ──────────────────────────────────────── */
.rwp-canvas-section {
    background: var(--rwp-surface);
    border: 1px solid var(--rwp-border);
    border-radius: var(--rwp-radius);
    overflow: hidden;
    box-shadow: var(--rwp-shadow);
    margin-bottom: 16px;
}
.rwp-canvas-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--rwp-border);
    background: var(--rwp-bg);
}
.rwp-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.rwp-file-name {
    font-size: 13px;
    color: var(--rwp-muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rwp-mask-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.rwp-toggle-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
}
.rwp-toggle-label input { cursor: pointer; }

.rwp-brush-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--rwp-muted);
}
.rwp-brush-controls input[type=range] {
    width: 90px;
    accent-color: var(--rwp-accent);
}

.rwp-canvas-container {
    background: #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    overflow: hidden;
}
.rwp-canvas-container canvas {
    display: block;
    max-width: 100%;
}

.rwp-mask-hint {
    font-size: 13px;
    color: var(--rwp-muted);
    padding: 10px 18px;
    border-top: 1px solid var(--rwp-border);
    margin: 0;
    background: #fffbeb;
}

/* ── Prompt section ──────────────────────────────────────── */
.rwp-prompt-section {
    margin-bottom: 16px;
}
.rwp-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}
.rwp-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--rwp-border);
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--rwp-text);
    background: var(--rwp-surface);
    resize: vertical;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}
.rwp-textarea:focus {
    outline: none;
    border-color: var(--rwp-accent);
    box-shadow: 0 0 0 3px rgba(79,110,247,.12);
}
.rwp-submit-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
}
.rwp-char-count {
    font-size: 12px;
    color: #9CA3AF;
    margin-left: auto;
}

/* ── Buttons ─────────────────────────────────────────────── */
.rwp-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 24px;
    background: var(--rwp-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s, transform .1s, box-shadow .18s;
    font-family: inherit;
    white-space: nowrap;
}
.rwp-btn-primary:hover {
    background: var(--rwp-accent-dark);
    box-shadow: 0 4px 14px rgba(79,110,247,.3);
}
.rwp-btn-primary:active { transform: scale(.98); }
.rwp-btn-primary:disabled {
    background: #A5B0C8;
    cursor: not-allowed;
    box-shadow: none;
}
.rwp-btn-secondary {
    padding: 9px 18px;
    background: var(--rwp-surface);
    color: var(--rwp-accent);
    border: 1.5px solid var(--rwp-accent);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .18s;
    font-family: inherit;
}
.rwp-btn-secondary:hover { background: var(--rwp-accent-light); }
.rwp-btn-ghost {
    background: none;
    border: none;
    color: var(--rwp-accent);
    font-size: 13px;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: inherit;
    text-decoration: underline;
}
.rwp-btn-ghost:hover { background: var(--rwp-accent-light); }
.rwp-btn-icon { font-size: 16px; }

/* ── Loading ─────────────────────────────────────────────── */
.rwp-loading {
    text-align: center;
    padding: 40px 24px;
    background: var(--rwp-surface);
    border: 1px solid var(--rwp-border);
    border-radius: var(--rwp-radius);
    margin-bottom: 16px;
}
.rwp-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--rwp-border);
    border-top-color: var(--rwp-accent);
    border-radius: 50%;
    animation: rwp-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes rwp-spin { to { transform: rotate(360deg); } }
.rwp-loading-text {
    color: var(--rwp-muted);
    font-size: 15px;
    margin: 0 0 16px;
}
.rwp-progress-bar {
    max-width: 280px;
    height: 4px;
    background: var(--rwp-border);
    border-radius: 99px;
    overflow: hidden;
    margin: 0 auto;
}
.rwp-progress-fill {
    height: 100%;
    background: var(--rwp-accent);
    border-radius: 99px;
    width: 0%;
    transition: width .4s ease;
}

/* ── Refined prompt ──────────────────────────────────────── */
.rwp-refined-prompt {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    font-size: 13px;
}
.rwp-refined-prompt summary {
    cursor: pointer;
    font-weight: 600;
    color: #166534;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rwp-refined-prompt summary::-webkit-details-marker { display: none; }
.rwp-refined-prompt p {
    margin: 10px 0 0;
    color: #166534;
    line-height: 1.6;
}
.rwp-badge {
    background: #dcfce7;
    color: #166534;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── Results ─────────────────────────────────────────────── */
.rwp-results {
    margin-top: 8px;
}
.rwp-results-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--rwp-muted);
    margin-bottom: 14px;
}
.rwp-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.rwp-result-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--rwp-border);
    background: #000;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
    group: true;
}
.rwp-result-item:hover {
    border-color: var(--rwp-accent);
    box-shadow: 0 6px 20px rgba(79,110,247,.2);
}
.rwp-result-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: opacity .2s;
}
.rwp-result-item:hover img {
    opacity: .85;
}
.rwp-result-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
    background: rgba(79,110,247,.15);
}
.rwp-result-item:hover .rwp-result-overlay {
    opacity: 1;
}
.rwp-result-download-btn {
    background: var(--rwp-accent);
    color: #fff;
    padding: 9px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    pointer-events: none;
}
.rwp-results-actions {
    display: flex;
    gap: 12px;
}

/* ── Error banner ────────────────────────────────────────── */
.rwp-error {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--rwp-error-bg);
    border: 1px solid #FECACA;
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--rwp-error-text);
    font-size: 14px;
    margin-top: 12px;
}
.rwp-error-icon { font-size: 18px; flex-shrink: 0; }
.rwp-error-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--rwp-error-text);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
    .rwp-wrap { padding: 16px 12px 40px; }
    .rwp-canvas-header { flex-direction: column; align-items: flex-start; }
    .rwp-submit-row { flex-wrap: wrap; }
    .rwp-results-grid { grid-template-columns: 1fr 1fr; }
    .rwp-btn-primary { width: 100%; justify-content: center; }
}
@media (max-width: 400px) {
    .rwp-results-grid { grid-template-columns: 1fr; }
}

/* ── Model selector row ──────────────────────────────────────────── */
.rwp-options-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-top: 10px;
}
.rwp-model-selector {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 220px;
}
.rwp-model-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--rwp-muted);
}
.rwp-model-select {
    padding: 8px 12px;
    border: 1px solid var(--rwp-border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--rwp-text);
    background: var(--rwp-surface);
    cursor: pointer;
    transition: border-color .2s;
    font-family: inherit;
    width: 100%;
}
.rwp-model-select:focus {
    outline: none;
    border-color: var(--rwp-accent);
    box-shadow: 0 0 0 3px rgba(79,110,247,.12);
}
.rwp-submit-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
@media (max-width: 600px) {
    .rwp-options-row { flex-direction: column; }
    .rwp-submit-row { width: 100%; }
    .rwp-btn-primary { width: 100%; justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════════════
   RetouchWP Guide — [retouch_guide] shortcode styles
   ═══════════════════════════════════════════════════════════════════ */

.rwp-guide {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 8px 0 32px;
    color: var(--rwp-text, #1A1D23);
}

/* ── Tabs ─────────────────────────────────────────────────────────── */
.rwp-guide-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 0;
    border-bottom: 2px solid #E2E5ED;
    padding-bottom: 0;
}
.rwp-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 13px;
    font-weight: 600;
    color: #6B7280;
    cursor: pointer;
    transition: color .18s, border-color .18s;
    white-space: nowrap;
    font-family: inherit;
    border-radius: 6px 6px 0 0;
}
.rwp-tab:hover { color: #1A1D23; }
.rwp-tab--active {
    color: #4F6EF7;
    border-bottom-color: #4F6EF7;
    background: #F7F8FF;
}

/* Provider badges on tabs */
.rwp-tab-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 2px 5px;
    border-radius: 4px;
}
.rwp-tab-badge--google { background: #E8F5E9; color: #2E7D32; }
.rwp-tab-badge--openai { background: #E3F2FD; color: #1565C0; }

/* ── Tab panels ───────────────────────────────────────────────────── */
.rwp-tab-panel { display: none; }
.rwp-tab-panel--active { display: block; }

/* ── Card ─────────────────────────────────────────────────────────── */
.rwp-guide-card {
    background: #fff;
    border: 1px solid #E2E5ED;
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 28px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.rwp-guide-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #F0F1F5;
    flex-wrap: wrap;
}
.rwp-guide-icon {
    font-size: 28px;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.rwp-guide-title {
    font-size: 20px;
    font-weight: 700;
    color: #1A1D23;
    margin: 0 0 4px;
}
.rwp-guide-subtitle {
    font-size: 13px;
    color: #6B7280;
    margin: 0;
}
.rwp-guide-cost {
    margin-left: auto;
    text-align: right;
    flex-shrink: 0;
}
.rwp-cost-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #9CA3AF;
    margin-bottom: 4px;
}
.rwp-cost-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: #4F6EF7;
    line-height: 1;
}

/* ── Body grid ────────────────────────────────────────────────────── */
.rwp-guide-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
}
.rwp-guide-col h4 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #374151;
    margin: 0 0 10px;
}
.rwp-guide-col h4 + h4 { margin-top: 20px; }
.rwp-guide-col ul {
    margin: 0 0 0 16px;
    padding: 0;
    list-style: disc;
}
.rwp-guide-col ul li {
    font-size: 14px;
    color: #374151;
    line-height: 1.6;
    margin-bottom: 6px;
}
.rwp-guide-col ul li strong { color: #1A1D23; }

/* ── Cost breakdown box ───────────────────────────────────────────── */
.rwp-cost-breakdown {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 16px 18px;
    margin-top: 20px;
}
.rwp-cost-breakdown h4 { margin-bottom: 10px !important; }
.rwp-cost-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 10px;
}
.rwp-cost-table td {
    padding: 5px 0;
    color: #374151;
    border-bottom: 1px solid #E5E7EB;
}
.rwp-cost-table tr:last-child td { border-bottom: none; }
.rwp-cost-table td:last-child {
    text-align: right;
    font-weight: 700;
    color: #1A1D23;
}
.rwp-cost-note {
    font-size: 12px;
    color: #9CA3AF;
    margin: 0;
    line-height: 1.7;
}
.rwp-cost-note code {
    background: #E5E7EB;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
    color: #374151;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .rwp-guide-body { grid-template-columns: 1fr; gap: 16px; }
    .rwp-guide-card { padding: 18px 16px; }
    .rwp-guide-header { gap: 12px; }
    .rwp-cost-value { font-size: 22px; }
    .rwp-tab { padding: 8px 10px; font-size: 12px; }
}

/* ── Review / edit refined prompt section ────────────────────────── */
.rwp-review-section {
    background: var(--rwp-surface);
    border: 1.5px solid #c7d7fc;
    border-radius: var(--rwp-radius);
    padding: 22px 24px 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(79,110,247,.08);
}
.rwp-review-header { margin-bottom: 14px; }
.rwp-review-title-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.rwp-review-icon { font-size: 26px; flex-shrink: 0; margin-top: 2px; }
.rwp-review-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--rwp-text);
    margin: 0 0 3px;
}
.rwp-review-subtitle {
    font-size: 13px;
    color: var(--rwp-muted);
    margin: 0;
    line-height: 1.5;
}
.rwp-textarea--refined {
    border-color: #c7d7fc;
    background: #f7f9ff;
    font-size: 14px;
    line-height: 1.65;
}
.rwp-textarea--refined:focus {
    border-color: var(--rwp-accent);
    background: var(--rwp-surface);
}
.rwp-review-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    margin-bottom: 16px;
}
.rwp-refined-char-count {
    font-size: 12px;
    color: #9CA3AF;
}
.rwp-review-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Compact loading for refine step (no progress bar) */
.rwp-loading--refine {
    padding: 24px;
    background: #f7f9ff;
    border: 1.5px solid #c7d7fc;
}
.rwp-loading--refine .rwp-loading-text {
    margin: 0;
    font-size: 14px;
}

/* ── Model bar at top ─────────────────────────────────────────────── */
.rwp-model-bar {
    background: var(--rwp-surface);
    border: 1px solid var(--rwp-border);
    border-radius: var(--rwp-radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.rwp-model-bar .rwp-model-label { white-space: nowrap; flex-shrink: 0; }
.rwp-model-bar .rwp-model-select { flex: 1; min-width: 200px; max-width: 360px; }
.rwp-model-hint {
    width: 100%;
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--rwp-muted);
    line-height: 1.5;
}

/* ── Live model description in editor ───────────────────────────────── */
.rwp-model-desc {
    width: 100%;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--rwp-muted);
}
.rwp-model-desc strong { color: var(--rwp-text); }
.rwp-model-desc .rwp-desc-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.rwp-desc-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #F0F4FF;
    color: #4F6EF7;
    border: 1px solid #c7d7fc;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    white-space: nowrap;
}
.rwp-desc-pill--warn {
    background: #FFF8E1;
    color: #B45309;
    border-color: #fde68a;
}
.rwp-desc-pill--green {
    background: #F0FDF4;
    color: #166534;
    border-color: #bbf7d0;
}

/* ── Variant selector row in review section ──────────────────── */
.rwp-variant-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    margin-bottom: 4px;
    border-top: 1px solid #e8ecff;
    flex-wrap: wrap;
}
.rwp-variant-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--rwp-muted);
    white-space: nowrap;
}
.rwp-variant-select {
    padding: 7px 10px;
    border: 1px solid var(--rwp-border);
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rwp-text);
    background: var(--rwp-surface);
    cursor: pointer;
    font-family: inherit;
    transition: border-color .2s;
    width: 130px;
}
.rwp-variant-select:focus {
    outline: none;
    border-color: var(--rwp-accent);
    box-shadow: 0 0 0 3px rgba(79,110,247,.12);
}
.rwp-variant-cost {
    font-size: 12px;
    color: var(--rwp-muted);
    margin-left: auto;
}
.rwp-variant-cost strong { color: var(--rwp-accent); }
