/* ===================================
   AEO AGENT - MODERN SAAS DASHBOARD
   Inspired by Vercel & Shopify
   =================================== */

/* ========== CSS VARIABLES ========== */
:root {
    /* Primary Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    
    /* Surfaces */
    --bg-base: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    
    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --error: #ef4444;
    --error-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Spacing */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== TYPOGRAPHY ========== */
.wrap h1 {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.wrap h1 .dashicons {
    color: var(--primary);
    font-size: 32px;
}

/* ========== GRID LAYOUT ========== */
.aeo-agent-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

/* ========== CARDS ========== */
.aeo-agent-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.aeo-agent-card:hover {
    box-shadow: var(--shadow-md);
}

/* Left Card - Sticky */
.aeo-agent-grid > .aeo-agent-card:first-child {
    position: sticky;
    top: var(--spacing-lg);
    align-self: start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Custom Scrollbar */
.aeo-agent-grid > .aeo-agent-card:first-child::-webkit-scrollbar {
    width: 6px;
}

.aeo-agent-grid > .aeo-agent-card:first-child::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: var(--radius-full);
}

.aeo-agent-grid > .aeo-agent-card:first-child::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.aeo-agent-grid > .aeo-agent-card:first-child::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.aeo-agent-card h2 {
    margin: 0 0 var(--spacing-md) 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.aeo-agent-card h3 {
    margin-top: var(--spacing-md);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========== FORM ELEMENTS ========== */
.aeo-agent-label {
    display: block;
    margin: var(--spacing-md) 0 var(--spacing-xs) 0;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.aeo-agent-input,
.aeo-agent-select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface);
    transition: var(--transition);
    font-family: inherit;
}

.aeo-agent-input:hover,
.aeo-agent-select:hover {
    border-color: var(--text-muted);
}

.aeo-agent-input:focus,
.aeo-agent-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.aeo-agent-input {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.5;
}

/* Override cho textarea trong images tab để đảm bảo độ cao */
#aeo-agent-tab-images textarea.aeo-agent-input {
    min-height: 120px !important;
}

/* Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    accent-color: var(--primary);
}

input[type="radio"] {
    border-radius: var(--radius-full);
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
    border-color: var(--primary);
}

/* ========== ENHANCED FORM STYLES ========== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.form-group.half {
    margin-bottom: 0;
}

/* Required Mark */
.required-mark {
    color: var(--error);
    font-weight: 700;
    margin-left: 4px;
}

/* Custom Option Styling */
.aeo-agent-select option.custom-option {
    font-weight: 600;
    color: var(--primary);
    border-top: 2px solid var(--border);
    margin-top: 4px;
}

/* Checkbox & Radio Labels */
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 0;
    transition: var(--transition);
}

.checkbox-label:hover,
.radio-label:hover {
    color: var(--primary);
}

.checkbox-text {
    font-weight: 500;
}

/* Help Text */
.help-text {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Disabled Form Group & Coming Soon Fix */
.form-group-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.form-group-disabled .aeo-agent-select {
    background-color: var(--border-light) !important; /* Chỉ đặt màu nền */
    background-image: none !important; /* ⭐ Xóa sạch icon/ảnh nền */
    box-shadow: none !important; /* Xóa bóng đổ nếu có */
    color: var(--text-muted) !important;
    cursor: not-allowed;
    pointer-events: none;
    
    /* Ẩn mũi tên mặc định của trình duyệt triệt để */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    
    /* Đảm bảo không có padding thừa gây lệch chữ */
    padding-right: 14px; 
}

/* Ẩn options trong disabled select */
.form-group-disabled .aeo-agent-select option {
    display: none;
}

/* Alternative: Hiển thị text placeholder thay vì dropdown */
.form-group-disabled .aeo-agent-select::after {
    content: none !important;
    display: none !important;
}

.form-group-disabled .help-text {
    color: var(--text-secondary);
    font-style: italic;
}

/* Coming Soon Badge */
.badge-coming-soon {
    display: inline-flex;
    align-items: center;
    background: var(--warning);
    color: #000;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: var(--spacing-xs);
}

/* ========== BUTTONS ========== */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.button-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.button-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.button-primary:active {
    transform: translateY(0);
}

.button-primary:disabled {
    background: var(--text-muted);
    border-color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
}

.button-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
}

.button-hero {
    padding: 12px 24px;
    font-size: 15px;
}

/* Button with Icon */
.button .dashicons {
    font-size: 18px;
    height: 18px;
    width: 18px;
    margin-right: 6px;
    vertical-align: middle;
}

.button-hero .dashicons {
    font-size: 20px;
    height: 20px;
    width: 20px;
}

/* ========== BUTTON GENERATE - FIXED VERSION ========== */
.aeo-agent-actions {
    margin-top: var(--spacing-lg);
    display: flex;
    justify-content: center;
    width: 100%;
}

.button-generate {
    width: 100%;
    max-width: 100%;
    position: relative;
    animation: button-pulse 2s ease-in-out infinite;
}

/* Pulse Effect - No Overflow */
@keyframes button-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(37, 99, 235, 0);
    }
}

.button-generate:hover {
    animation: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Sparkle Icon Animation */
.button-icon-sparkle {
    display: inline-block;
    animation: icon-sparkle 1.5s ease-in-out infinite;
}

@keyframes icon-sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: scale(1.2) rotate(-10deg);
        opacity: 0.85;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
        opacity: 1;
    }
    75% {
        transform: scale(1.2) rotate(-5deg);
        opacity: 0.9;
    }
}

/* Disabled state */
.button:disabled .button-icon-sparkle {
    animation: none;
    opacity: 0.6;
}

/* Button Generate trong Images Tab */
#aeo-agent-image-actions {
    margin-top: var(--spacing-lg);
    display: flex;
    justify-content: center;
    width: 100%;
}

#aeo-agent-generate-images-btn {
    min-width: 240px;
}

/* ========== BADGES ========== */
.aeo-agent-badge-wrap {
    margin: var(--spacing-sm) 0 var(--spacing-md) 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.aeo-agent-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-full);
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.aeo-agent-badge:hover {
    background: var(--primary);
    color: white;
}

/* ========== LOADING SPINNER ========== */
.aeo-agent-card.is-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    border-radius: var(--radius-md);
    z-index: 10;
}

.aeo-agent-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: aeoAgentSpin 0.8s linear infinite;
    z-index: 11;
}

@keyframes aeoAgentSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== TABS ========== */
.aeo-agent-tabs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: var(--spacing-md);
}

.aeo-agent-tabs-nav {
    display: flex;
    gap: var(--spacing-xs);
}

.aeo-agent-tab-link {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    cursor: pointer;
}

.aeo-agent-tab-link:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.aeo-agent-tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.aeo-agent-tab-link.disabled {
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}

.aeo-agent-tab-panel {
    display: none;
}

.aeo-agent-tab-panel.active {
    display: block;
}

.aeo-agent-tabs-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ========== CATEGORY SELECTOR ========== */
.aeo-agent-category-selector {
    margin-bottom: var(--spacing-md);
}

.aeo-agent-category-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-sm);
    border: 1px solid var(--border);
    padding: var(--spacing-md);
    background: var(--bg-base);
    border-radius: var(--radius-sm);
}

.aeo-agent-category-list .checkbox-label {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.aeo-agent-category-list .checkbox-label:hover {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

#aeo-agent-category-status {
    font-size: 12px;
    font-weight: normal;
    color: var(--text-muted);
    margin-left: var(--spacing-xs);
}

/* ========== SCHEDULE OPTIONS ========== */
#aeo-agent-schedule-options {
    display: none;
    padding: var(--spacing-sm);
    border: 1px solid var(--border);
    margin-top: var(--spacing-sm);
    border-radius: var(--radius-sm);
    background: var(--bg-base);
}

#aeo-agent-schedule-options.visible {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

#aeo-agent-schedule-options input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
}

#aeo-agent-schedule-options input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ========== PREVIEW CONTENT ========== */
#aeo-agent-preview-body,
#aeo-agent-full-preview-body {
    border: 1px solid var(--border);
    background: var(--surface);
    padding: var(--spacing-xl);
    max-height: 60vh;
    overflow: auto;
    border-radius: var(--radius-sm);
    line-height: 1.7;
    font-size: 15px;
    color: var(--text-primary);
}

#aeo-agent-preview-body h1,
#aeo-agent-full-preview-body h1 {
    font-size: 32px !important;
    font-weight: 700 !important;
    text-align: center !important;
    padding: var(--spacing-md) 0 !important;
    color: var(--text-primary) !important;
    line-height: 1.2 !important;
}

#aeo-agent-full-preview-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
    box-shadow: var(--shadow-lg);
}

/* ========== SUMMARY CONTAINER ========== */
.summary-container {
    padding: var(--spacing-lg);
    border: 1px solid var(--border);
    border-top: none;
    background: var(--surface);
}

.summary-section {
    margin-bottom: var(--spacing-xl);
}

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

.summary-section h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.summary-section .dashicons {
    color: var(--primary);
    font-size: 20px;
}

.summary-box {
    padding: var(--spacing-md);
    background: var(--bg-base);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    line-height: 1.7;
}

.summary-box p {
    margin: 0;
    color: var(--text-primary);
    font-size: 15px;
}

.summary-box ul {
    margin: 0;
    padding-left: var(--spacing-lg);
    list-style-type: disc;
}

.summary-box li {
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
    line-height: 1.7;
}

/* ========== IMAGES CONTAINER & PROMPTS IMPROVEMENTS ========== */
.images-container {
    padding: var(--spacing-lg);
    border: 1px solid var(--border);
    border-top: none;
    background: var(--surface);
}

.image-prompt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.image-prompt-grid .form-group {
    margin-bottom: 0;
}

.image-prompt-grid .aeo-agent-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
    font-size: 14px;
    font-weight: 600;
}

.image-prompt-grid .dashicons {
    color: var(--primary);
    font-size: 18px;
}

/* ⭐ TEXTAREA TRONG IMAGES TAB - CẢI THIỆN */
#aeo-agent-featured-prompt,
#aeo-agent-incontent-prompt {
    min-height: 120px; /* Tăng chiều cao */
    resize: vertical; /* Cho phép resize dọc */
    font-size: 14px;
    line-height: 1.6;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: var(--transition);
    font-family: inherit;
    width: 100%;
}

#aeo-agent-featured-prompt:hover,
#aeo-agent-incontent-prompt:hover {
    border-color: var(--text-muted);
}

#aeo-agent-featured-prompt:focus,
#aeo-agent-incontent-prompt:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Placeholder styling */
#aeo-agent-featured-prompt::placeholder,
#aeo-agent-incontent-prompt::placeholder {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

/* Image Results Grid */
#aeo-agent-image-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

#aeo-agent-image-results > div {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    transition: var(--transition);
}

#aeo-agent-image-results > div:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

#aeo-agent-image-results h4 {
    margin: 0 0 var(--spacing-sm) 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

#aeo-agent-image-results h4::before {
    content: '📷';
    font-size: 16px;
}

#aeo-agent-image-results img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: block;
}

#aeo-agent-image-results img:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

/* ========== STATUS MESSAGES ========== */
.notice {
    padding: var(--spacing-md);
    border-left: 4px solid;
    border-radius: var(--radius-sm);
    margin: var(--spacing-md) 0;
}

.notice-success {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.notice-error {
    background: var(--error-light);
    border-color: var(--error);
    color: var(--error);
}

.notice-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
}

.notice-info {
    background: var(--info-light);
    border-color: var(--info);
    color: var(--info);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.notice-info .dashicons {
    color: var(--info);
    font-size: 20px;
}

/* ========== HELP TEXT ========== */
.aeo-agent-help {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
    line-height: 1.5;
}

/* ========== UPDATE STATUS ========== */
#aeo-agent-update-status {
    font-size: 12px;
    color: var(--success);
    font-style: italic;
    font-weight: 500;
}

/* ========== UI LOCKING ========== */
.aeo-agent-grid.aeo-agent-ui-locked {
    position: relative;
    cursor: not-allowed;
}

.aeo-agent-grid.aeo-agent-ui-locked::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    z-index: 999;
    border-radius: var(--radius-md);
}

/* ========== CARD HEADER ========== */
.aeo-agent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border-light);
}

.aeo-agent-card-header h2 {
    margin: 0;
}

.aeo-agent-header-actions {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.aeo-agent-publish-status-options {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.aeo-agent-polylang-options {
    display: flex;
    align-items: center;
    padding-right: var(--spacing-md);
    border-right: 1px solid var(--border);
}

/* ========== PREVIEW LINK ========== */
.preview-link,
#aeo-agent-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.preview-link:hover,
#aeo-agent-preview-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateX(4px);
}

.preview-link .dashicons {
    font-size: 16px;
}

/* ========== PLACEHOLDER STYLES ========== */
#aeo-agent-initial-placeholder {
    background: var(--bg-base);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-xl);
    text-align: center;
}

#aeo-agent-preview-body-placeholder {
    border: none !important;
    background: transparent !important;
}

#aeo-agent-preview-body-placeholder p,
.placeholder-text {
    text-align: center;
    padding: 4rem 0;
    opacity: 0.6;
    color: var(--text-muted);
    font-size: 15px;
}

/* ========== SPINNER IN MESSAGES ========== */
.spinner.is-active {
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><circle cx="10" cy="10" r="8" fill="none" stroke="%232563eb" stroke-width="2" stroke-dasharray="40" stroke-dashoffset="10"><animateTransform attributeName="transform" type="rotate" from="0 10 10" to="360 10 10" dur="1s" repeatCount="indefinite"/></circle></svg>') no-repeat center;
    width: 20px;
    height: 20px;
    margin: 0 !important;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1400px) {
    .aeo-agent-grid {
        grid-template-columns: 380px 1fr;
    }
}

@media (max-width: 1024px) {
    .aeo-agent-grid {
        grid-template-columns: 1fr;
    }
    
    .aeo-agent-grid > .aeo-agent-card:first-child {
        position: static;
        max-height: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .image-prompt-grid {
        grid-template-columns: 1fr;
    }
    
    #aeo-agent-image-results {
        grid-template-columns: 1fr;
    }
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aeo-agent-card {
    animation: fadeIn 0.3s ease-out;
}

/* Container chứa 2 nút */
#aeo-regen-buttons {
    display: flex;
    justify-content: center;
    gap: 15px; /* Khoảng cách giữa 2 nút */
    margin-top: 25px;
}

/* Style chung cho nút tạo lẻ */
.btn-gen-single {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Khoảng cách giữa icon và chữ */
    
    background-color: #fff !important;
    color: #2271b1 !important;
    border: 1px solid #2271b1 !important;
    border-radius: 6px !important;
    
    padding: 10px 20px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    height: auto !important; /* Fix lỗi chiều cao mặc định của WP */
    line-height: normal !important;
}

/* Hiệu ứng khi di chuột vào */
.btn-gen-single:hover {
    background-color: #f0f6fc !important;
    transform: translateY(-2px); /* Nút nổi lên nhẹ */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-color: #0a4b78 !important;
    color: #0a4b78 !important;
}

/* Hiệu ứng khi bấm */
.btn-gen-single:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Chỉnh lại icon cho đẹp */
.btn-gen-single .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    margin: 0;
}

/* Nút disable (khi đang chạy) */
.btn-gen-single:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    background-color: #f6f7f7 !important;
    color: #a7aaad !important;
    border-color: #dcdcde !important;
}

/* ========== WIZARD SETUP STYLES ========== */
.eonsr-aeo-wizard-container { text-align: left; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.eonsr-aeo-wizard-desc { font-size: 14px; color: #646970; margin-bottom: 15px; line-height: 1.5; }
.eonsr-aeo-wizard-section-title { font-size: 12px; font-weight: 700; color: #1d2327; text-transform: uppercase; margin: 20px 0 10px; display: flex; justify-content: space-between; align-items: center; letter-spacing: 0.5px; }
.eonsr-aeo-wizard-limit-badge { background: #f0f6fc; color: #2271b1; padding: 2px 8px; border-radius: 10px; font-size: 11px; border: 1px solid #c5d7ed; }
.eonsr-aeo-wizard-search-box { position: relative; margin-bottom: 12px; }
.eonsr-aeo-wizard-search-box input { width: 100%; padding: 10px 10px 10px 36px; border: 1px solid #dcdcde; border-radius: 6px; font-size: 14px; transition: all 0.2s; box-sizing: border-box; background: #fff; }
.eonsr-aeo-wizard-search-box input:focus { border-color: #2271b1; box-shadow: 0 0 0 1px #2271b1; outline: none; }
.eonsr-aeo-wizard-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #a0a0a0; pointer-events: none; font-size: 18px; }
.eonsr-aeo-layout-row { display: flex; gap: 20px; align-items: start; }
.eonsr-aeo-layout-col { flex: 1; width: 50%; display: flex; flex-direction: column; }
.eonsr-aeo-wizard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 350px; min-height: 300px; overflow-y: auto; padding: 2px; }
.eonsr-aeo-wizard-grid::-webkit-scrollbar, .eonsr-aeo-style-list::-webkit-scrollbar { width: 6px; }
.eonsr-aeo-wizard-grid::-webkit-scrollbar-track, .eonsr-aeo-style-list::-webkit-scrollbar-track { background: #f0f0f1; border-radius: 4px; }
.eonsr-aeo-wizard-grid::-webkit-scrollbar-thumb, .eonsr-aeo-style-list::-webkit-scrollbar-thumb { background: #c3c4c7; border-radius: 4px; }
.eonsr-aeo-wizard-item { position: relative; display: block; }
.eonsr-aeo-wizard-item input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.eonsr-aeo-wizard-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid #dcdcde; border-radius: 6px; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); font-size: 14px; color: #3c434a; user-select: none; }
.eonsr-aeo-wizard-card:hover { border-color: #2271b1; background: #f8f9fa; transform: translateY(-1px); }
.eonsr-aeo-wizard-item input[type="checkbox"]:checked + .eonsr-aeo-wizard-card { border-color: #2271b1; background: #f0f6fc; color: #2271b1; font-weight: 600; box-shadow: 0 2px 4px rgba(34, 113, 177, 0.15); }
.eonsr-aeo-check-icon { width: 18px; height: 18px; border: 1px solid #c3c4c7; border-radius: 4px; background: #fff; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.eonsr-aeo-wizard-item input[type="checkbox"]:checked + .eonsr-aeo-wizard-card .eonsr-aeo-check-icon { background: #2271b1; border-color: #2271b1; }
.eonsr-aeo-check-icon::after { content: '✓'; color: #fff; font-size: 12px; display: none; font-weight: bold; }
.eonsr-aeo-wizard-item input[type="checkbox"]:checked + .eonsr-aeo-wizard-card .eonsr-aeo-check-icon::after { display: block; }
.eonsr-aeo-style-list { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow-y: auto; padding: 4px; }
.eonsr-aeo-style-card-wrapper { position: relative; display: block; }
.eonsr-aeo-style-card { display: flex; justify-content: space-between; align-items: center; padding: 15px; background: #fff; border: 1px solid #dcdcde; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.eonsr-aeo-style-card:hover { border-color: #2271b1; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.eonsr-aeo-style-content h4 { margin: 0 0 4px 0; font-size: 15px; color: #1d2327; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.eonsr-aeo-style-content p { margin: 0; font-size: 13px; color: #646970; }
.eonsr-aeo-style-tag { font-size: 10px; background: #f0f0f1; color: #50575e; padding: 2px 6px; border-radius: 4px; font-weight: normal; text-transform: uppercase; border: 1px solid #dcdcde; }
.eonsr-aeo-style-card-wrapper input[type="checkbox"]:checked + .eonsr-aeo-style-card { border-color: #2271b1; background: #f0f6fc; box-shadow: 0 0 0 1px #2271b1; }
.eonsr-aeo-style-card-wrapper input[type="checkbox"]:checked + .eonsr-aeo-style-card .eonsr-aeo-style-tag { background: #2271b1; color: #fff; border-color: #2271b1; }
.eonsr-aeo-btn-preview { font-size: 12px; color: #2271b1; background: #fff; border: 1px solid #2271b1; padding: 6px 12px; border-radius: 4px; text-decoration: none; font-weight: 600; transition: 0.2s; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.eonsr-aeo-btn-preview:hover { background: #2271b1; color: #fff; }
@keyframes eonsr-aeo-shake { 0% { transform: translateX(0); } 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-5px); } 100% { transform: translateX(0); } }
.eonsr-aeo-inline-error { color: #d63638; font-size: 12px; font-weight: 500; margin-left: 10px; opacity: 0; transition: opacity 0.3s ease; display: inline-block; }
.eonsr-aeo-error-show { opacity: 1 !important; animation: eonsr-aeo-shake 0.4s ease-in-out; }
.eonsr-aeo-badge-error { background: #fbeaea !important; color: #d63638 !important; border-color: #d63638 !important; }
@media (max-width: 768px) {
    .eonsr-aeo-layout-row { flex-direction: column; }
    .eonsr-aeo-layout-col { width: 100%; }
    .eonsr-aeo-wizard-grid { max-height: 200px; }
}


        :root {
            --eonsr-aeo-primary:         #4f46e5; /* Indigo 600 */
            --eonsr-aeo-primary-hover:   #4338ca; /* Indigo 700 */
            --eonsr-aeo-secondary:       #f1f5f9;
            --eonsr-aeo-secondary-hover: #e2e8f0;
            --eonsr-aeo-text-dark:       #1e293b;
            --eonsr-aeo-text-gray:       #64748b;
            --eonsr-aeo-success:         #10b981;
            --eonsr-aeo-warning:         #f59e0b;
            --eonsr-aeo-shadow:          0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
        }

        /* --- Layout & Container --- */
        .eonsr-aeo-license-wrapper {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background: #f8fafc;
            min-height: calc(100vh - 50px);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px 20px;
            margin-left: -20px; /* Fix WP Admin Padding */
        }

        .eonsr-aeo-card {
            background: #ffffff;
            width: 100%;
            max-width: 500px;
            border-radius: 24px;
            box-shadow: var(--eonsr-aeo-shadow);
            padding: 48px;
            text-align: center;
            border: 1px solid rgba(255,255,255,1);
            position: relative;
            overflow: hidden;
            animation: eonsrAeoSlideUp 0.5s ease-out;
        }

        @keyframes eonsrAeoSlideUp { 
            from { opacity: 0; transform: translateY(20px); } 
            to { opacity: 1; transform: translateY(0); } 
        }

        /* Top Gradient Line Decoration */
        .eonsr-aeo-card::before {
            content: ''; 
            position: absolute; top: 0; left: 0; right: 0; height: 6px;
            background: linear-gradient(90deg, #4f46e5 0%, #8b5cf6 50%, #ec4899 100%);
        }

        /* --- Icons & Typography --- */
        .eonsr-aeo-icon-box {
            width: 80px; height: 80px;
            background: #eff6ff; 
            color: var(--eonsr-aeo-primary);
            border-radius: 24px;
            display: inline-flex; align-items: center; justify-content: center;
            margin-bottom: 24px;
            box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.1);
        }
        .eonsr-aeo-icon-box.success { background: #ecfdf5; color: var(--eonsr-aeo-success); }
        .eonsr-aeo-icon-box .dashicons { font-size: 40px; width: 40px; height: 40px; }

        h2.eonsr-aeo-head { 
            font-size: 26px; font-weight: 800; color: var(--eonsr-aeo-text-dark); 
            margin: 0 0 12px; letter-spacing: -0.5px; 
        }
        p.eonsr-aeo-sub { 
            font-size: 15px; color: var(--eonsr-aeo-text-gray); 
            margin: 0 0 32px; line-height: 1.6; 
        }

        /* --- Form Elements --- */
        .eonsr-aeo-input-group { text-align: left; margin-bottom: 24px; position: relative; }
        
        .eonsr-aeo-label { 
            display: block; font-size: 13px; font-weight: 700; color: #334155; 
            margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; 
        }
        
        .eonsr-aeo-input {
            width: 100%;
            padding: 16px;
            border: 2px solid #e2e8f0;
            border-radius: 12px;
            font-family: 'SF Mono', 'Roboto Mono', Menlo, monospace;
            font-size: 16px;
            color: #1e293b;
            text-align: center;
            text-transform: uppercase;
            letter-spacing: 2px;
            transition: all 0.2s;
            background: #f8fafc;
        }
        .eonsr-aeo-input:focus {
            background: #fff;
            border-color: var(--eonsr-aeo-primary);
            box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
            outline: none;
        }
        .eonsr-aeo-input::placeholder { color: #cbd5e1; letter-spacing: normal; }

        /* --- Buttons --- */
        .eonsr-aeo-btn {
            width: 100%;
            padding: 16px;
            font-size: 16px;
            font-weight: 600;
            border-radius: 12px;
            cursor: pointer;
            border: none;
            display: flex; align-items: center; justify-content: center;
            gap: 10px;
            transition: all 0.2s ease;
            position: relative;
        }
        
        /* Primary */
        .eonsr-aeo-btn-primary {
            background: var(--eonsr-aeo-primary);
            color: #fff;
            box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
        }
        .eonsr-aeo-btn-primary:hover {
            background: var(--eonsr-aeo-primary-hover);
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
        }

        /* Secondary */
        .eonsr-aeo-btn-secondary {
            background: #fff;
            color: #475569;
            border: 2px solid #e2e8f0;
            margin-top: 15px;
        }
        .eonsr-aeo-btn-secondary:hover {
            background: #f8fafc;
            border-color: #cbd5e1;
            color: #1e293b;
            transform: translateY(-2px);
        }

        /* Loading State */
        .eonsr-aeo-btn.is-loading { opacity: 0.8; pointer-events: none; cursor: not-allowed; }
        
        .eonsr-aeo-spinner {
            width: 20px; height: 20px;
            border: 3px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: eonsrSpin 0.8s linear infinite;
            display: none;
        }
        .eonsr-aeo-btn-secondary .eonsr-aeo-spinner {
            border: 3px solid rgba(0,0,0,0.1);
            border-top-color: #475569;
        }

        @keyframes eonsrSpin { to { transform: rotate(360deg); } }

        /* --- Components --- */
        .eonsr-aeo-divider {
            display: flex; align-items: center; text-align: center;
            color: #94a3b8; font-size: 12px; font-weight: 600; text-transform: uppercase;
            margin: 25px 0;
        }
        .eonsr-aeo-divider::before, .eonsr-aeo-divider::after { content: ''; flex: 1; border-bottom: 1px solid #e2e8f0; }
        .eonsr-aeo-divider span { padding: 0 15px; }

        .eonsr-aeo-info-box {
            background: #f8fafc; border: 1px solid #e2e8f0;
            border-radius: 16px; padding: 24px; text-align: left;
            margin-bottom: 20px;
        }
        .eonsr-aeo-info-row { display: flex; justify-content: space-between; margin-bottom: 12px; }
        .eonsr-aeo-info-row:last-child { margin-bottom: 0; }
        
        .eonsr-aeo-key-display { font-family: monospace; font-weight: 700; color: var(--eonsr-aeo-primary); }
        .eonsr-aeo-key-trial { color: var(--eonsr-aeo-warning); }
        
        .eonsr-aeo-footer { margin-top: 24px; font-size: 14px; color: #64748b; }
        .eonsr-aeo-footer a { color: var(--eonsr-aeo-primary); text-decoration: none; font-weight: 600; }
        .eonsr-aeo-footer a:hover { text-decoration: underline; }

        /* Upgrade Mini Form */
        .eonsr-aeo-upgrade-form { display: flex; gap: 10px; margin-top: 15px; }
        .eonsr-aeo-upgrade-form .eonsr-aeo-input { padding: 12px; font-size: 14px; }
        .eonsr-aeo-upgrade-form .eonsr-aeo-btn { width: auto; padding: 0 24px; white-space: nowrap; }
    