/**
 * MxChat Content Generator Styles
 *
 * @package MxChat
 * @since 3.1.0
 */

/* ─── Toolbar ───────────────────────────────────────────────────── */

.mxch-cg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--mxch-card-bg, #fff);
    border: 1px solid var(--mxch-card-border, #e2e4e9);
    border-radius: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.mxch-cg-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 0;
    min-width: 0;
    overflow: visible;
}

.mxch-cg-toolbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--mxch-text-primary, #1a1a2e);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mxch-cg-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ─── Generate Button (compact) ─────────────────────────────────── */

.mxch-cg-generate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: var(--mxch-primary, #7873f5);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.mxch-cg-generate-btn:hover {
    background: var(--mxch-primary-hover, #6863e5);
    box-shadow: 0 2px 8px rgba(120, 115, 245, 0.3);
}

.mxch-cg-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.mxch-cg-generate-btn.mxch-cg-loading {
    position: relative;
    color: transparent;
}

.mxch-cg-generate-btn.mxch-cg-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mxch-spin 0.6s linear infinite;
}

.mxch-cg-generate-btn-full {
    width: 100%;
    padding: 12px 24px;
    font-size: 14px;
}

@keyframes mxch-spin {
    to { transform: rotate(360deg); }
}

/* ─── Action Buttons (toolbar) ──────────────────────────────────── */

.mxch-cg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid var(--mxch-input-border, #d1d5db);
    border-radius: 6px;
    background: transparent;
    color: var(--mxch-text-secondary, #64748b);
    font-size: 12px;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    white-space: nowrap;
}

.mxch-cg-action-btn:hover {
    border-color: var(--mxch-primary, #7873f5);
    color: var(--mxch-primary, #7873f5);
    text-decoration: none;
}

/* Status Badge (clickable dropdown trigger) */
.mxch-cg-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.mxch-cg-status-badge:hover {
    opacity: 0.85;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.mxch-cg-badge-draft {
    background: #fef3c7;
    color: #92400e;
}

.mxch-cg-badge-publish {
    background: #d1fae5;
    color: #065f46;
}

.mxch-cg-badge-future {
    background: #dbeafe;
    color: #1e40af;
}

/* ── Status Dropdown ──────────────────────────────────── */

.mxch-cg-status-dropdown {
    position: relative;
    flex-shrink: 0;
}

.mxch-cg-status-chevron {
    opacity: 0.6;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.mxch-cg-status-dropdown.mxch-cg-dropdown-open .mxch-cg-status-chevron {
    transform: rotate(180deg);
}

.mxch-cg-status-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 160px;
    background: var(--mxch-card-bg, #fff);
    border: 1px solid var(--mxch-card-border, #e2e4e9);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 100060;
    padding: 4px;
    animation: mxch-dropdown-in 0.15s ease-out;
}

@keyframes mxch-dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.mxch-cg-status-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--mxch-text-primary, #1a1a2e);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.mxch-cg-status-option:hover {
    background: #f1f5f9;
}

.mxch-cg-status-option.mxch-cg-status-active {
    font-weight: 600;
    background: #f8fafc;
}

.mxch-cg-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mxch-cg-dot-draft {
    background: #f59e0b;
}

.mxch-cg-dot-publish {
    background: #10b981;
}

.mxch-cg-dot-future {
    background: #3b82f6;
}

.mxch-cg-status-schedule-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px 4px;
    border-top: 1px solid var(--mxch-card-border, #e2e4e9);
    margin-top: 4px;
}

.mxch-cg-status-schedule-input {
    flex: 1;
    font-size: 11px;
    padding: 4px 6px;
    min-width: 0;
}

.mxch-cg-status-schedule-confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 5px;
    background: var(--mxch-primary, #7873f5);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.mxch-cg-status-schedule-confirm:hover {
    background: var(--mxch-primary-hover, #6863e5);
}

.mxch-cg-status-badge.mxch-cg-status-updating {
    pointer-events: none;
    opacity: 0.6;
}

.mxch-cg-status-badge.mxch-cg-status-updating .mxch-cg-status-chevron {
    animation: mxch-spin 0.6s linear infinite;
}

/* Viewport Toggle */
.mxch-cg-viewport-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 2px;
}

.mxch-cg-viewport-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--mxch-text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.2s;
}

.mxch-cg-viewport-btn.active {
    background: #fff;
    color: var(--mxch-primary, #7873f5);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ─── Full-Width Preview ────────────────────────────────────────── */

.mxch-cg-preview-wrap {
    border: 1px solid var(--mxch-card-border, #e2e4e9);
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    position: relative;
}

.mxch-cg-preview-container {
    width: 100%;
    min-height: calc(100vh - 220px);
    position: relative;
    overflow: hidden;
    background: #fff;
    transition: max-width 0.3s ease;
}

.mxch-cg-preview-container.mxch-cg-viewport-mobile {
    max-width: 375px;
    margin: 0 auto;
    min-height: 667px;
    border-left: 1px solid var(--mxch-card-border, #e2e4e9);
    border-right: 1px solid var(--mxch-card-border, #e2e4e9);
}

.mxch-cg-preview-iframe {
    width: 1400px;
    height: calc(100vh - 220px);
    border: none;
    display: block;
    transform-origin: 0 0;
}

/* ─── Inline Generation Form ────────────────────────────────────── */

.mxch-cg-inline-form {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 220px);
    padding: 40px 20px;
}

.mxch-cg-inline-form-inner {
    width: 100%;
    max-width: 560px;
    background: var(--mxch-card-bg, #fff);
    border: 1px solid var(--mxch-card-border, #e2e4e9);
    border-radius: 14px;
    padding: 28px 28px 24px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    animation: mxch-inline-form-in 0.3s ease-out;
}

@keyframes mxch-inline-form-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.mxch-cg-inline-form-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.mxch-cg-inline-form-header svg {
    color: var(--mxch-primary, #7873f5);
    opacity: 0.7;
    flex-shrink: 0;
}

.mxch-cg-inline-form-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--mxch-text-primary, #1a1a2e);
    margin: 0 0 2px;
}

.mxch-cg-inline-form-header p {
    font-size: 13px;
    color: var(--mxch-text-muted, #94a3b8);
    margin: 0;
}

.mxch-cg-inline-form.mxch-cg-form-collapsing {
    animation: mxch-inline-form-out 0.3s ease-in forwards;
}

@keyframes mxch-inline-form-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-12px); }
}

/* Toolbar hidden when inline form is visible */
.mxch-cg-toolbar.mxch-cg-toolbar-minimal {
    display: none;
}

/* Preview container transparent when form is showing */
.mxch-cg-preview-wrap.mxch-cg-preview-wrap-form {
    border: none;
    background: transparent;
}

/* ─── Generation Form ──────────────────────────────────────────── */

.mxch-cg-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mxch-cg-prompt {
    width: 100%;
    min-height: 80px;
    padding: 12px 14px;
    border: 1px solid var(--mxch-input-border, #d1d5db);
    border-radius: 8px;
    background: var(--mxch-input-bg, #fff);
    color: var(--mxch-text-primary, #1a1a2e);
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
    font-family: inherit;
}

.mxch-cg-prompt:focus {
    outline: none;
    border-color: var(--mxch-input-focus, #7873f5);
    box-shadow: 0 0 0 3px var(--mxch-primary-light, rgba(120, 115, 245, 0.1));
}

.mxch-cg-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.mxch-cg-option {
    flex: 1;
    min-width: 120px;
}

.mxch-cg-option-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--mxch-text-secondary, #64748b);
    margin-bottom: 4px;
}

.mxch-cg-select,
.mxch-cg-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--mxch-input-border, #d1d5db);
    border-radius: 6px;
    background: var(--mxch-input-bg, #fff);
    color: var(--mxch-text-primary, #1a1a2e);
    font-size: 13px;
    transition: border-color 0.2s;
}

.mxch-cg-select:focus,
.mxch-cg-input:focus {
    outline: none;
    border-color: var(--mxch-input-focus, #7873f5);
    box-shadow: 0 0 0 3px var(--mxch-primary-light, rgba(120, 115, 245, 0.1));
}

/* ─── Progress Bar (inside modal) ───────────────────────────────── */

.mxch-cg-progress {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--mxch-card-border, #e2e4e9);
}

.mxch-cg-progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.mxch-cg-progress-fill {
    height: 100%;
    background: var(--mxch-primary, #7873f5);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.mxch-cg-progress-text {
    font-size: 13px;
    color: var(--mxch-text-secondary, #64748b);
    margin: 0;
}

/* ─── Mini Chat Panel (bottom overlay) ──────────────────────────── */

.mxch-cg-chat-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-height: 420px;
    background: var(--mxch-card-bg, #fff);
    border: 1px solid var(--mxch-card-border, #e2e4e9);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 100040;
    display: flex;
    flex-direction: column;
    animation: mxch-chat-in 0.2s ease-out;
}

@keyframes mxch-chat-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mxch-cg-chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--mxch-card-border, #e2e4e9);
    flex-shrink: 0;
}

.mxch-cg-chat-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--mxch-text-primary, #1a1a2e);
}

.mxch-cg-chat-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--mxch-text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.15s;
}

.mxch-cg-chat-panel-close:hover {
    background: #f1f5f9;
    color: var(--mxch-text-primary, #1a1a2e);
}

.mxch-cg-chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    min-height: 120px;
    max-height: 260px;
}

.mxch-cg-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.mxch-cg-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.mxch-cg-chat-msg {
    display: flex;
}

.mxch-cg-chat-user {
    justify-content: flex-end;
}

.mxch-cg-chat-assistant {
    justify-content: flex-start;
}

.mxch-cg-chat-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.mxch-cg-chat-user .mxch-cg-chat-bubble {
    background: var(--mxch-primary, #7873f5);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.mxch-cg-chat-assistant .mxch-cg-chat-bubble {
    background: #f1f5f9;
    color: var(--mxch-text-primary, #1a1a2e);
    border-bottom-left-radius: 4px;
}

/* Loading dots */
.mxch-cg-chat-loading {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.mxch-cg-chat-loading span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: mxch-bounce 1.4s infinite both;
}

.mxch-cg-chat-loading span:nth-child(2) {
    animation-delay: 0.16s;
}

.mxch-cg-chat-loading span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes mxch-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Input */
.mxch-cg-chat-input-wrap {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--mxch-card-border, #e2e4e9);
    flex-shrink: 0;
}

.mxch-cg-chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--mxch-input-border, #d1d5db);
    border-radius: 16px;
    background: var(--mxch-input-bg, #fff);
    color: var(--mxch-text-primary, #1a1a2e);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    overflow-y: auto;
    max-height: 150px;
    line-height: 1.4;
}

.mxch-cg-chat-input:focus {
    border-color: var(--mxch-input-focus, #7873f5);
}

.mxch-cg-chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--mxch-primary, #7873f5);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mxch-cg-chat-send:hover:not(:disabled) {
    background: var(--mxch-primary-hover, #6863e5);
}

.mxch-cg-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ─── Notices ────────────────────────────────────────────────────── */

.mxch-cg-notice {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.mxch-cg-notice-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.mxch-cg-notice-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ─── Save Indicators ────────────────────────────────────────────── */

.mxch-field-label.mxch-saving::after,
.mxch-toggle-label.mxch-saving::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 6px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--mxch-success, #10b981);
    border-radius: 50%;
    animation: mxch-spin 0.6s linear infinite;
    vertical-align: middle;
}

.mxch-field-label.mxch-saved::after,
.mxch-toggle-label.mxch-saved::after {
    content: ' \2713';
    color: var(--mxch-success, #10b981);
    font-weight: bold;
}

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 782px) {
    .mxch-cg-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .mxch-cg-toolbar-right {
        width: 100%;
        flex-wrap: wrap;
    }

    .mxch-cg-status-menu {
        left: auto;
        right: 0;
    }

    .mxch-cg-options {
        flex-direction: column;
    }

    .mxch-cg-chat-panel {
        left: 10px;
        right: 10px;
        width: auto;
        bottom: 10px;
        max-height: calc(100vh - 60px);
    }

    .mxch-cg-chat-panel.mxch-cg-chat-panel--with-images {
        width: auto;
        flex-direction: column;
        max-height: calc(100vh - 60px);
        overflow: hidden;
    }

    .mxch-cg-images-col {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--mxch-card-border, #e2e4e9);
    }

    .mxch-cg-images-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }

    .mxch-cg-left-tabs {
        flex-shrink: 0;
    }

    .mxch-cg-chat-messages {
        max-height: 180px;
    }

    .mxch-cg-inline-form {
        padding: 20px 12px;
        min-height: auto;
    }

    .mxch-cg-inline-form-inner {
        padding: 20px 16px 18px;
    }
}

/* ─── Pro Feature Lock Styles ──────────────────────────────────── */

.mxch-cg-pro-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    margin-left: 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, rgba(120, 115, 245, 0.15), rgba(168, 139, 250, 0.15));
    color: var(--mxch-primary, #7873f5);
    line-height: 1;
    vertical-align: middle;
}

.mxch-cg-pro-field.mxch-cg-pro-locked .mxch-toggle-switch {
    opacity: 0.4;
    cursor: not-allowed;
}

.mxch-cg-pro-field.mxch-cg-pro-locked .mxch-toggle {
    cursor: default;
}

.mxch-cg-pro-field.mxch-cg-pro-locked .mxch-field-description {
    opacity: 0.6;
}

.mxch-cg-pro-upgrade-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--mxch-primary, #7873f5);
    text-decoration: none;
    margin-top: 4px;
    transition: color 0.2s;
}

.mxch-cg-pro-upgrade-link:hover {
    color: var(--mxch-primary-hover, #6863e5);
    text-decoration: underline;
}

/* ─── Image Management Panel (Two-Column Chat) ────────────────── */

.mxch-cg-chat-panel.mxch-cg-chat-panel--with-images {
    width: 760px;
    max-height: 480px;
    flex-direction: row;
}

.mxch-cg-images-col {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--mxch-card-border, #e2e4e9);
    position: relative;
    overflow: hidden;
}

/* ── Left Column Tabs ──────────────────────────────────── */

.mxch-cg-left-tabs {
    display: flex;
    border-bottom: 1px solid var(--mxch-card-border, #e2e4e9);
    flex-shrink: 0;
}

.mxch-cg-left-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: var(--mxch-text-muted, #94a3b8);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.mxch-cg-left-tab:hover {
    color: var(--mxch-text-secondary, #64748b);
    background: rgba(0, 0, 0, 0.03);
}

.mxch-cg-left-tab.active {
    color: var(--mxch-primary, #7873f5);
    font-weight: 600;
}

.mxch-cg-left-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 12px;
    right: 12px;
    height: 2px;
    background: var(--mxch-primary, #7873f5);
    border-radius: 1px;
}

.mxch-cg-left-tab .mxch-cg-pro-badge {
    margin-left: 2px;
    font-size: 8px;
    padding: 1px 4px;
}

.mxch-cg-left-tab.mxch-cg-tab-flash {
    animation: mxch-tab-flash 0.6s ease 3;
}

@keyframes mxch-tab-flash {
    0%, 100% { color: var(--mxch-primary, #7873f5); }
    50% { color: #10b981; }
}

.mxch-cg-left-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.mxch-cg-left-panel.active {
    display: flex;
    flex-direction: column;
}

/* ── Meta/SEO Form ─────────────────────────────────────── */

.mxch-cg-meta-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.mxch-cg-meta-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mxch-cg-meta-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--mxch-text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.mxch-cg-meta-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--mxch-input-border, #d1d5db);
    border-radius: 5px;
    background: var(--mxch-input-bg, #fff);
    color: var(--mxch-text-primary, #1a1a2e);
    font-size: 12px;
    line-height: 1.4;
    transition: border-color 0.2s;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.mxch-cg-meta-input:focus {
    outline: none;
    border-color: var(--mxch-input-focus, #7873f5);
    box-shadow: 0 0 0 2px rgba(120, 115, 245, 0.1);
}

.mxch-cg-meta-input:disabled,
.mxch-cg-meta-input[readonly] {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8fafc;
}

textarea.mxch-cg-meta-input {
    min-height: 48px;
}

.mxch-cg-meta-charcount {
    font-size: 10px;
    color: var(--mxch-text-muted, #94a3b8);
    text-align: right;
}

.mxch-cg-meta-charcount-over {
    color: #ef4444;
    font-weight: 600;
}

.mxch-cg-meta-lock-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.04);
    z-index: 2;
    pointer-events: none;
}

.mxch-cg-meta-lock-overlay svg {
    opacity: 0.3;
}

.mxch-cg-meta-lock-overlay span {
    font-size: 11px;
    color: var(--mxch-primary, #7873f5);
    font-weight: 500;
}

.mxch-cg-meta-field label.mxch-saving::after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 4px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--mxch-success, #10b981);
    border-radius: 50%;
    animation: mxch-spin 0.6s linear infinite;
    vertical-align: middle;
}

.mxch-cg-meta-field label.mxch-saved::after {
    content: ' \2713';
    color: var(--mxch-success, #10b981);
    font-weight: bold;
}

/* Legacy header (kept for backward compat if needed) */
.mxch-cg-images-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--mxch-card-border, #e2e4e9);
    flex-shrink: 0;
}

.mxch-cg-images-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--mxch-text-primary, #1a1a2e);
    display: flex;
    align-items: center;
}

.mxch-cg-images-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
    position: relative;
}

.mxch-cg-image-thumb {
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    position: relative;
    background: var(--mxch-input-bg, #fff);
    border: 1px solid var(--mxch-card-border, #e2e4e9);
}

.mxch-cg-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mxch-cg-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #cbd5e1;
}

/* Empty state (before generation) */
.mxch-cg-images-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 12px;
    color: var(--mxch-text-muted, #94a3b8);
    text-align: center;
}

.mxch-cg-images-empty svg {
    opacity: 0.5;
}

.mxch-cg-images-empty span {
    font-size: 11px;
    line-height: 1.4;
}

/* Hover actions on images */
.mxch-cg-image-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 4px;
    padding: 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
    opacity: 0;
    transition: opacity 0.2s;
}

.mxch-cg-image-thumb:hover .mxch-cg-image-actions {
    opacity: 1;
}

.mxch-cg-image-action-btn {
    flex: 1;
    padding: 5px 4px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: #1a1a2e;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: background 0.15s;
    line-height: 1;
}

.mxch-cg-image-action-btn:hover {
    background: #fff;
}

/* Locked action buttons */
.mxch-cg-image-actions-locked .mxch-cg-image-action-btn {
    cursor: not-allowed;
    opacity: 0.7;
}

.mxch-cg-image-actions-locked .mxch-cg-image-action-btn:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* Per-image PRO lock badge (top-right corner) */
.mxch-cg-image-lock-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: rgba(120, 115, 245, 0.85);
    color: #fff;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.mxch-cg-image-lock-badge svg {
    flex-shrink: 0;
}

/* Image loading state (used by add-on during upload/regenerate) */
.mxch-cg-image-thumb.mxch-cg-image-loading {
    position: relative;
    pointer-events: none;
}
.mxch-cg-image-thumb.mxch-cg-image-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    z-index: 10;
}
.mxch-cg-image-thumb.mxch-cg-image-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    z-index: 11;
    animation: mxch-spin 0.8s linear infinite;
}
@keyframes mxch-spin {
    to { transform: rotate(360deg); }
}

/* Image selected state (regen mode) */
.mxch-cg-image-thumb.mxch-cg-image-selected {
    outline: 2px solid #7873f5;
    outline-offset: -2px;
    border-radius: 6px;
    box-shadow: 0 0 0 4px rgba(120, 115, 245, 0.25);
}

/* Regen bar — sits above chat input when an image is selected for regeneration */
.mxch-cg-regen-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(120, 115, 245, 0.1);
    border-top: 1px solid rgba(120, 115, 245, 0.3);
    animation: mxch-regen-bar-in 0.2s ease;
}
@keyframes mxch-regen-bar-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.mxch-cg-regen-bar-thumb {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(120, 115, 245, 0.4);
    flex-shrink: 0;
}
.mxch-cg-regen-bar-text {
    flex: 1;
    font-size: 12px;
    color: #a0a0b0;
    line-height: 1.3;
}
.mxch-cg-regen-bar-cancel {
    background: none;
    border: none;
    color: #a0a0b0;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.mxch-cg-regen-bar-cancel:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Chat column in two-column layout */
.mxch-cg-chat-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ─── Mobile overrides for two-column chat (must come after desktop rules) ── */
@media (max-width: 782px) {
    .mxch-cg-chat-panel.mxch-cg-chat-panel--with-images {
        width: auto;
        flex-direction: column;
        max-height: calc(100vh - 60px);
        overflow: hidden;
    }

    .mxch-cg-images-col {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--mxch-card-border, #e2e4e9);
    }

    .mxch-cg-chat-col {
        min-height: 0;
    }

    .mxch-cg-chat-messages {
        max-height: 180px;
    }
}

/* ─── History Tab ────────────────────────────────────────────────── */

.mxch-cg-history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--mxch-text-muted, #94a3b8);
}

.mxch-cg-history-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--mxch-primary, #7873f5);
    border-radius: 50%;
    animation: mxch-spin 0.6s linear infinite;
    margin-bottom: 12px;
}

.mxch-cg-history-loading p {
    font-size: 14px;
    margin: 0;
}

.mxch-cg-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--mxch-text-muted, #94a3b8);
    text-align: center;
}

.mxch-cg-history-empty svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.mxch-cg-history-empty p {
    font-size: 14px;
    margin: 0;
    max-width: 360px;
}

.mxch-cg-history-list {
    display: flex;
    flex-direction: column;
}

.mxch-cg-history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--mxch-card-border, #e2e4e9);
}

.mxch-cg-history-item:last-child {
    border-bottom: none;
}

.mxch-cg-history-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f1f5f9;
    border: 1px solid var(--mxch-card-border, #e2e4e9);
}

.mxch-cg-history-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mxch-cg-history-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
}

.mxch-cg-history-info {
    flex: 1;
    min-width: 0;
}

.mxch-cg-history-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--mxch-text-primary, #1a1a2e);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.mxch-cg-history-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mxch-cg-history-meta .mxch-cg-status-badge {
    font-size: 10px;
    padding: 1px 6px;
    cursor: default;
    pointer-events: none;
}

.mxch-cg-history-type,
.mxch-cg-history-date {
    font-size: 12px;
    color: var(--mxch-text-muted, #94a3b8);
}

.mxch-cg-history-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.mxch-cg-history-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--mxch-input-border, #d1d5db);
    border-radius: 6px;
    background: transparent;
    color: var(--mxch-text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.mxch-cg-history-action-btn svg {
    width: 15px;
    height: 15px;
}

/* View — blue hover */
.mxch-cg-history-view-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* Edit — purple hover */
.mxch-cg-history-edit-btn:hover {
    border-color: var(--mxch-primary, #7873f5);
    color: var(--mxch-primary, #7873f5);
    background: rgba(120, 115, 245, 0.1);
}

/* Delete — red hover */
.mxch-cg-history-delete-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.mxch-cg-history-action-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* History Pagination */

.mxch-cg-history-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding-top: 20px;
    margin-top: 8px;
    border-top: 1px solid var(--mxch-card-border, #e2e4e9);
}

.mxch-cg-history-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--mxch-input-border, #d1d5db);
    border-radius: 6px;
    background: transparent;
    color: var(--mxch-text-secondary, #64748b);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.mxch-cg-history-page-btn:hover {
    border-color: var(--mxch-primary, #7873f5);
    color: var(--mxch-primary, #7873f5);
}

.mxch-cg-history-page-current {
    background: var(--mxch-primary, #7873f5);
    color: #fff;
    border-color: var(--mxch-primary, #7873f5);
    cursor: default;
    font-weight: 600;
}

.mxch-cg-history-page-current:hover {
    background: var(--mxch-primary, #7873f5);
    color: #fff;
    border-color: var(--mxch-primary, #7873f5);
}

.mxch-cg-history-page-prev,
.mxch-cg-history-page-next {
    font-size: 12px;
    font-weight: 500;
}

.mxch-cg-history-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    color: var(--mxch-text-muted, #94a3b8);
    font-size: 13px;
}

@media (max-width: 782px) {
    .mxch-cg-history-item {
        flex-wrap: wrap;
    }

    .mxch-cg-history-info {
        flex: 1 1 calc(100% - 62px);
    }

    .mxch-cg-history-actions {
        margin-left: auto;
    }
}

/* ─── Loading Indicator (preview area) ──────────────────────────── */

.mxch-cg-loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 220px);
    padding: 40px 20px;
    text-align: center;
    gap: 24px;
}

/* Spinner: three concentric rings + center icon */
.mxch-cg-loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
}

.mxch-cg-loading-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
}

.mxch-cg-loading-spinner-ring:nth-child(1) {
    border-top-color: var(--mxch-primary, #7873f5);
    animation: mxch-spin 1.2s linear infinite;
}

.mxch-cg-loading-spinner-ring:nth-child(2) {
    inset: 8px;
    border-right-color: rgba(120, 115, 245, 0.5);
    animation: mxch-spin 1.8s linear infinite reverse;
}

.mxch-cg-loading-spinner-ring:nth-child(3) {
    inset: 16px;
    border-bottom-color: rgba(120, 115, 245, 0.3);
    animation: mxch-spin 2.4s linear infinite;
}

.mxch-cg-loading-spinner-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--mxch-primary, #7873f5);
    opacity: 0.8;
}

/* Phrase text with fade transition */
.mxch-cg-loading-phrase {
    font-size: 17px;
    font-weight: 500;
    color: var(--mxch-text-secondary, #64748b);
    margin: 0;
    min-height: 28px;
    max-width: 400px;
    transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 1;
    transform: translateY(0);
}

.mxch-cg-loading-phrase.mxch-cg-phrase-exit {
    opacity: 0;
    transform: translateY(-8px);
}

.mxch-cg-loading-phrase.mxch-cg-phrase-enter {
    opacity: 0;
    transform: translateY(8px);
}

/* Mini progress bar beneath the phrase */
.mxch-cg-loading-progress-mini {
    width: 100%;
    max-width: 280px;
}

.mxch-cg-loading-progress-mini-bar {
    width: 100%;
    height: 4px;
    background: var(--mxch-card-border, #e2e4e9);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.mxch-cg-loading-progress-mini-fill {
    height: 100%;
    background: var(--mxch-primary, #7873f5);
    border-radius: 2px;
    transition: width 0.6s ease;
}

.mxch-cg-loading-progress-mini-text {
    font-size: 12px;
    color: var(--mxch-text-muted, #94a3b8);
    margin: 0;
}

/* Error state */
.mxch-cg-loading-indicator.mxch-cg-loading-error .mxch-cg-loading-spinner-ring {
    animation-play-state: paused;
}

.mxch-cg-loading-indicator.mxch-cg-loading-error .mxch-cg-loading-spinner-ring:nth-child(1) {
    border-top-color: #ef4444;
}

.mxch-cg-loading-indicator.mxch-cg-loading-error .mxch-cg-loading-spinner-ring:nth-child(2) {
    border-right-color: rgba(239, 68, 68, 0.5);
}

.mxch-cg-loading-indicator.mxch-cg-loading-error .mxch-cg-loading-spinner-ring:nth-child(3) {
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.mxch-cg-loading-indicator.mxch-cg-loading-error .mxch-cg-loading-spinner-icon {
    color: #ef4444;
}

.mxch-cg-loading-error-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.mxch-cg-loading-error-actions .mxch-cg-generate-btn {
    font-size: 13px;
    padding: 8px 16px;
}

.mxch-cg-loading-error-actions .mxch-cg-action-btn {
    font-size: 13px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--mxch-card-border, #e2e4e9);
    border-radius: 6px;
    color: var(--mxch-text-secondary, #64748b);
    cursor: pointer;
}

.mxch-cg-loading-error-actions .mxch-cg-action-btn:hover {
    background: var(--mxch-card-bg, #f8f9fa);
}

/* Success state */
.mxch-cg-loading-indicator.mxch-cg-loading-success .mxch-cg-loading-spinner-ring:nth-child(1) {
    border-top-color: #10b981;
}

.mxch-cg-loading-indicator.mxch-cg-loading-success .mxch-cg-loading-spinner-ring:nth-child(2) {
    border-right-color: rgba(16, 185, 129, 0.5);
}

.mxch-cg-loading-indicator.mxch-cg-loading-success .mxch-cg-loading-spinner-ring:nth-child(3) {
    border-bottom-color: rgba(16, 185, 129, 0.3);
}

.mxch-cg-loading-indicator.mxch-cg-loading-success .mxch-cg-loading-spinner-icon {
    color: #10b981;
}

/* Responsive */
@media (max-width: 782px) {
    .mxch-cg-loading-phrase {
        font-size: 15px;
    }

    .mxch-cg-loading-spinner {
        width: 64px;
        height: 64px;
    }
}
