/**
 * Structura — Post Editor Meta Box (Premium)
 *
 * Brand palette:
 *   Primary:  #4F46E5 (indigo-600)
 *   Light:    #818CF8 (indigo-400)
 *   Dark:     #3730A3 (indigo-800)
 *   Surface:  #EEF2FF (indigo-50)
 */

/* ── Reset WP meta-box padding ─────────────────────────────────────────────── */

#structura-post-info > .inside {
    padding: 0 !important;
    margin: 0 !important;
}

.structura-mb {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Campaign Link ─────────────────────────────────────────────────────────── */

.structura-mb__campaign {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    color: #4338CA;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    border-bottom: 1px solid #C7D2FE;
}

.structura-mb__campaign:hover,
.structura-mb__campaign:focus {
    background: linear-gradient(135deg, #E0E7FF 0%, #C7D2FE 100%);
    color: #3730A3;
    text-decoration: none;
}

.structura-mb__campaign:active {
    color: #3730A3;
    text-decoration: none;
}

.structura-mb__arrow {
    margin-left: auto;
    opacity: 0.5;
    transition: transform 0.2s, opacity 0.2s;
}

.structura-mb__campaign:hover .structura-mb__arrow {
    transform: translateX(2px);
    opacity: 0.9;
}

/* ── Keyword / Keyphrase pills ─────────────────────────────────────────────── */

.structura-mb__pills {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
}

.structura-mb__pill {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.structura-mb__pill-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #9CA3AF;
}

.structura-mb__pill-value {
    font-size: 13px;
    font-weight: 500;
    color: #1F2937;
    background: #F3F4F6;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
    word-break: break-word;
    line-height: 1.45;
}

/* ── Generation Stats ──────────────────────────────────────────────────────── */

.structura-mb__stats {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 14px 12px;
}

.structura-mb__stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 12px;
    color: #6B7280;
    line-height: 1.4;
}

.structura-mb__stat svg {
    flex-shrink: 0;
    color: #9CA3AF;
}

/* ── Naturalness note ──────────────────────────────────────────────────────── */

.structura-mb__note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 14px 12px;
    padding: 10px 12px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: #6B7280;
}

.structura-mb__note svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: #9CA3AF;
}

.structura-mb__note a {
    color: #4F46E5;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.structura-mb__note a:hover,
.structura-mb__note a:focus {
    text-decoration: underline;
}

/* ── Divider ───────────────────────────────────────────────────────────────── */

.structura-mb__divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #E5E7EB 20%, #E5E7EB 80%, transparent 100%);
    margin: 0 14px;
}

/* ── Image Section ─────────────────────────────────────────────────────────── */

.structura-mb__image-section {
    padding: 14px;
}

/* Thumbnail preview */
.structura-mb__thumb {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    line-height: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.structura-mb__thumb img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.structura-mb__thumb:hover img {
    transform: scale(1.03);
}

.structura-mb__thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.35) 100%);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 8px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.structura-mb__thumb:hover .structura-mb__thumb-overlay {
    opacity: 1;
}

.structura-mb__thumb-overlay svg {
    color: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* ── Regenerate Button ─────────────────────────────────────────────────────── */

.structura-mb__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

.structura-mb__btn:hover {
    background: linear-gradient(135deg, #4338CA 0%, #4F46E5 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.structura-mb__btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}

.structura-mb__btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.15) !important;
}

.structura-mb__btn-icon {
    flex-shrink: 0;
    transition: transform 0.5s ease;
}

.structura-mb__btn.is-loading .structura-mb__btn-icon {
    animation: structura-spin 0.8s linear infinite;
}

@keyframes structura-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ── Status messages ───────────────────────────────────────────────────────── */

.structura-mb__status {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
    margin-top: 0;
}

.structura-mb__status.is-visible {
    max-height: 80px;
    opacity: 1;
    margin-top: 10px;
}

.structura-mb__status-msg {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 12.5px;
    line-height: 1.45;
    padding: 8px 10px;
    border-radius: 6px;
}

.structura-mb__status-msg svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.structura-mb__status-msg.is-loading {
    background: #F3F4F6;
    color: #4B5563;
    border: 1px solid #E5E7EB;
}

.structura-mb__status-msg.is-success {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.structura-mb__status-msg.is-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL: Image Generation Studio
   ═══════════════════════════════════════════════════════════════════════════ */

.structura-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100100; /* Above WP admin bars and modals */
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.structura-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: structura-modal-in 0.25s ease;
}

@keyframes structura-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ── Header ────────────────────────────────────────────────────────────────── */

.structura-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #E5E7EB;
}

.structura-modal__header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #1F2937;
    margin: 0;
}

.structura-modal__close {
    background: none;
    border: none;
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    color: #9CA3AF;
    transition: color 0.15s, background 0.15s;
    line-height: 0;
}

.structura-modal__close:hover {
    color: #374151;
    background: #F3F4F6;
}

/* ── Body ──────────────────────────────────────────────────────────────────── */

.structura-modal__body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Prompt */
.structura-modal__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.structura-modal__label-hint {
    font-weight: 400;
    color: #9CA3AF;
}

.structura-modal__textarea {
    width: 100%;
    font-size: 13px;
    line-height: 1.5;
    padding: 9px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    resize: vertical;
    background: #FAFAFA;
    color: #1F2937;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.structura-modal__textarea:focus {
    outline: none;
    border-color: #818CF8;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    background: #fff;
}

.structura-modal__textarea::placeholder {
    color: #9CA3AF;
}

/* Preview area */
.structura-modal__preview {
    margin-top: 16px;
    border-radius: 10px;
    border: 1px solid #E5E7EB;
    background: #F9FAFB;
    min-height: 200px;
    overflow: hidden;
    position: relative;
}

/* Idle state */
.structura-modal__preview-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #9CA3AF;
}

.structura-modal__preview-idle svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.structura-modal__preview-idle p {
    font-size: 13px;
    margin: 0;
}

/* Loading state */
.structura-modal__preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.structura-modal__preview-loading p {
    font-size: 13px;
    color: #6B7280;
    margin: 0 0 16px;
}

.structura-modal__progress-bar {
    width: 80%;
    height: 4px;
    background: #E5E7EB;
    border-radius: 2px;
    overflow: hidden;
}

.structura-modal__progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4F46E5, #818CF8);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Result state */
.structura-modal__preview-result {
    line-height: 0;
}

.structura-modal__preview-result img {
    width: 100%;
    height: auto;
    display: block;
}

/* Error state */
.structura-modal__preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #991B1B;
}

.structura-modal__preview-error svg {
    margin-bottom: 10px;
    opacity: 0.7;
}

.structura-modal__preview-error p {
    font-size: 13px;
    margin: 0;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */

.structura-modal__footer {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
}

/* Generate / Try again button */
.structura-modal__btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    background: #fff;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}

.structura-modal__btn-generate:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
}

.structura-modal__btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}


/* Apply / Use this image button */
.structura-modal__btn-apply {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.25);
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}

.structura-modal__btn-apply:hover {
    background: linear-gradient(135deg, #4338CA 0%, #4F46E5 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

.structura-modal__btn-apply:active {
    transform: translateY(0);
}

.structura-modal__btn-apply:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Body images section (2026-05-02) ───────────────────────────
 * Mirrors the featured-image section visually — same image-section
 * container, same divider above. The label is a small uppercase
 * micro-label so it reads as a sub-section, not a peer to "Featured
 * Image" header. Each row is a small thumbnail + a compact
 * Regenerate button to match the row density of the meta box.
 */
.structura-mb__section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B7280;
    margin: 0 0 8px 0;
}

/* Placeholder-row copy — explains WHY the body-image-create CTA is
   visible (the original image step didn't deliver). Styled smaller +
   muted than the regular body-row so it reads as advisory rather
   than as primary content. */
.structura-mb__placeholder-msg {
    font-size: 12px;
    color: #6B7280;
    margin: 0 0 10px 0;
    line-height: 1.45;
}

.structura-mb__body-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid #F3F4F6;
}

.structura-mb__body-row:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.structura-mb__body-thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    background: #F3F4F6;
}

.structura-mb__body-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.structura-mb__btn--body {
    flex: 1 1 auto;
    /* Slightly tighter than the featured button so the row fits
     * the meta-box width without wrapping on default WP sidebar
     * widths. */
    padding: 7px 10px;
    font-size: 12px;
}

/* ── Image model picker (2026-05-02) ─────────────────────────────
 * Sits between the prompt textarea and the preview area in the
 * regen modal. Hidden for free tier (local adapter ignores per-call
 * overrides). For Cloud tier the disabled options carry an "Agency
 * only" suffix in the label — we keep the native <select> styling
 * because admin-side <select> is tricky to restyle without
 * fighting WP's core stylesheet on every release.
 */
.structura-modal__model-section {
    margin-top: 14px;
}

.structura-modal__select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    line-height: 1.4;
    color: #111827;
    box-sizing: border-box;
    margin-top: 6px;
}

.structura-modal__select:focus {
    outline: 2px solid #4F46E5;
    outline-offset: -1px;
    border-color: #4F46E5;
}
