/* Grid View (Default) */
#qcld_ai_saved_charts_list {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); 
    gap: 20px; 
    margin-top: 20px;
}
/* List View */
#qcld_ai_saved_charts_list.qcld-list-view {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
}
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card-left {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 0;
}
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card-left p {
    margin: 0;
}
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card-right {
    border-top: none;
    padding-top: 0;
}
.qcld-view-toggles {
    display: flex;
    align-items: center;
}
.qcld-view-toggles button {
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 5px 10px;
    cursor: pointer;
}
.qcld-view-toggles button.active {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}
/* Modal Styles */
.qcld-ai-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}
.qcld-ai-modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 80%;
    padding: 30px;
    border-radius: 16px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.3s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.qcld-ai-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    font-size: 24px;
    color: #94a3b8;
    transition: color 0.2s, transform 0.2s;
}
.qcld-ai-modal-close:hover {
    color: #ef4444;
    transform: scale(1.1);
}

/* Modern Inputs & Buttons inside modal */
.qcld-ai-modal-content input[type="text"],
.qcld-ai-modal-content input[type="file"],
.qcld-ai-modal-content select,
.qcld-ai-modal-content textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #334155;
    background-color: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.qcld-ai-modal-content input[type="text"]:focus,
.qcld-ai-modal-content select:focus,
.qcld-ai-modal-content textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
    background-color: #ffffff;
}
.qcld-ai-modal-content .button-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
.qcld-ai-modal-content .button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px -1px rgba(59, 130, 246, 0.4);
}

/* =====================================================
   Secondary & Small Buttons (Nice Design)
   ===================================================== */
.qcld-ai-modal-content .button-secondary,
.qcld-ai-modal-content .button.button-small {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    transition: all 0.2s ease-in-out !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    cursor: pointer !important;
    height: auto !important;
    line-height: normal !important;
}

.qcld-ai-modal-content .button-secondary:hover,
.qcld-ai-modal-content .button.button-small:hover {
    background: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #1e293b !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08) !important;
}

.qcld-ai-modal-content .button-secondary .dashicons,
.qcld-ai-modal-content .button.button-small .dashicons {
    color: #64748b !important;
    transition: color 0.2s !important;
}

.qcld-ai-modal-content .button-secondary:hover .dashicons,
.qcld-ai-modal-content .button.button-small:hover .dashicons {
    color: #3b82f6 !important;
}

/* Specific styling for the Edit JSON / D3 Code buttons group to make them pop more */
#qcld_ai_preview_actions .button-secondary {
    border: 1px solid #e2e8f0 !important;
}
#qcld_ai_preview_actions #qcld_ai_toggle_code_btn:hover {
    border-color: #818cf8 !important;
    color: #4f46e5 !important;
    background: #eef2ff !important;
}
#qcld_ai_preview_actions #qcld_ai_toggle_code_btn:hover .dashicons {
    color: #6366f1 !important;
}

#qcld_ai_preview_actions #qcld_ai_toggle_d3_btn:hover {
    border-color: #34d399 !important;
    color: #059669 !important;
    background: #ecfdf5 !important;
}
#qcld_ai_preview_actions #qcld_ai_toggle_d3_btn:hover .dashicons {
    color: #10b981 !important;
}

    transform: translateY(-2px);
    box-shadow: 0 6px 10px -1px rgba(59, 130, 246, 0.4);
}

/* Panels */
.qc-ichart-ai-prompt-area, .qc-ichart-ai-preview-area {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px;
    padding: 25px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
}
.qcld-ai-modal-content h3 {
    color: #0f172a;
    font-size: 18px;
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
}
.qcld-ai-modal-content label {
    color: #475569;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.qcld-hide { display: none !important; }
.qcld-description-box { margin-top: 15px; padding: 15px; background: #f8f9fa; border-left: 4px solid #00a0d2; }
.qcld-text-sm { font-size: 14px; line-height: 1.6; margin: 0; }
.qcld-modal-title { margin-top: 0; font-size: 24px; color: #0f172a; margin-bottom: 5px; }
.qcld-modal-subtitle { color: #64748b; margin-top: 0; margin-bottom: 25px; }
.qcld-flex-gap-25 { display: flex; gap: 25px; }
.qcld-flex-1 { flex: 1; }
.qcld-mb-15 { margin-bottom: 15px; }
.qcld-label-bold { display: block; font-weight: bold; margin-bottom: 5px; }
.qcld-w-100 { width: 100%; }
.qcld-flex-gap-15 { display: flex; gap: 15px; margin-bottom: 15px; }
.qcld-w-100 { width: 100%; margin-bottom: 10px; }
.qcld-mb-10 { margin-bottom: 10px; }
.qcld-w-100 { width: 100%; margin-top: 10px; }
.qcld-mt-10 { margin-top: 10px; }
.qcld-icon-fix { margin-top: 4px; margin-right: 5px; }
.qcld-loading-box { display: none; margin-top: 15px; text-align: center; color: #3b82f6; font-weight: 600; }
.qcld-spinner-fix { float: none; margin: 0; }
.qcld-error-box { color: #ef4444; margin-top: 15px; display: none; background: #fef2f2; padding: 10px; border-radius: 8px; border: 1px solid #fca5a5; text-align: center; }
.qcld-flex-1-2 { flex: 1.2; }
.qcld-preview-box { min-height: 400px; display: flex; align-items: center; justify-content: center; border: 2px dashed #cbd5e1; border-radius: 12px; background: #f8fafc; }
.qcld-text-center-muted { text-align: center; color: #94a3b8; }
.qcld-icon-48 { font-size: 48px; width: 48px; height: 48px; margin-bottom: 15px; opacity: 0.5; }
.qcld-mt-25 { display: none; margin-top: 25px; text-align: right; }
.qcld-text-right { text-align: right; }
.qcld-h4-title { margin-top: 0; text-align: left; color: #0f172a; font-size: 15px; border-bottom: 1px solid #e2e8f0; padding-bottom: 8px; margin-bottom: 12px; }
.qcld-code-editor { width: 100%; font-family: 'Courier New', Courier, monospace; font-size: 13px; margin-bottom: 15px; border: 1px solid #cbd5e1; border-radius: 8px; background: #1e293b; color: #a5b4fc; padding: 12px; }
.qcld-saved-charts-box { margin-top: 20px; background: #fff; padding: 20px; border: 1px solid #ccd0d4; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.qcld-flex-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.qcld-m-0 { margin: 0; }
.qcld-flex-gap-15 { display: flex; align-items: center; gap: 15px; }
.qcld-mt-2 { margin-top:2px; }
.qcld-icon-fix-3 { margin-top: 3px; }
.qcld-mt-0 { margin-top: 0; }
.qcld-chart-card-custom { border: 1px solid #e2e4e7; border-radius: 4px; padding: 15px; background: #fafafa; display: flex; flex-direction: column; justify-content: space-between; }
.qcld-mb-15 { margin-bottom:15px; }
.qcld-chart-title-text { margin-top: 0; margin-bottom: 10px; font-size: 16px; }
.qcld-chart-type-text { display: inline-block; padding: 3px 8px; background: #e0f0fa; color: #0073aa; border-radius: 12px; font-size: 11px; margin-bottom: 10px; text-transform: uppercase; }
.qcld-mini-chart-preview { width: 100%; height: 150px; margin-bottom: 15px; display: flex; align-items: center; justify-content: center; }
.qcld-chart-card-right-custom { display: flex; justify-content: flex-end; align-items: center; flex-wrap: nowrap; gap: 5px; border-top: 1px solid #ddd; padding-top: 10px; overflow-x: auto; padding-bottom: 5px; }
.qcld-btn-edit { color: #0073aa; border-color: #0073aa; }
.qcld-btn-remove { color: #b32d2e; border-color: #b32d2e; }
.qcld-no-charts-msg { grid-column: 1 / -1; padding: 20px; text-align: center; color: #999; border: 1px dashed #ccc; }
/* Premium Action Buttons CSS */
.qcld-chart-card-right-custom .button {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #64748b !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto !important;
    line-height: normal !important;
    font-weight: 500 !important;
}

.qcld-chart-card-right-custom .button:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    transform: translateY(-1px);
}

.qcld-chart-card-right-custom .button:active {
    transform: translateY(0);
}

.qcld-chart-card-right-custom .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-top: 0 !important;
    margin-right: 4px;
}

/* Reset margin for icon-only buttons */
.qcld-chart-card-right-custom .qcld_ai_copy_btn .dashicons,
.qcld-chart-card-right-custom .qcld_ai_export_png_btn .dashicons,
.qcld-chart-card-right-custom .qcld_ai_export_csv_btn .dashicons,
.qcld-chart-card-right-custom .qcld_ai_duplicate_btn .dashicons {
    margin-right: 0;
}

/* Individual Premium Hover Colors */
.qcld-chart-card-right-custom .qcld_ai_copy_btn:hover { background: #e0e7ff !important; color: #4338ca !important; }
.qcld-chart-card-right-custom .qcld_ai_export_png_btn:hover { background: #dcfce7 !important; color: #15803d !important; }
.qcld-chart-card-right-custom .qcld_ai_export_csv_btn:hover { background: #fef3c7 !important; color: #b45309 !important; }
.qcld-chart-card-right-custom .qcld_ai_duplicate_btn:hover { background: #fae8ff !important; color: #a21caf !important; }
.qcld-chart-card-right-custom .qcld_ai_edit_chart_btn:hover { background: #e0f2fe !important; color: #0369a1 !important; }
.qcld-chart-card-right-custom .qcld_ai_remove_chart_btn:hover { background: #fee2e2 !important; color: #b91c1c !important; }

/* Override any default edit/remove styles */
.qcld-chart-card-right-custom .qcld-btn-edit { border-color: transparent !important; color: #64748b !important; }
.qcld-chart-card-right-custom .qcld-btn-remove { border-color: transparent !important; color: #64748b !important; }

/* Ensure Shortcode View Does Not Wrap */
.qcld_ai_ichart_s_view {
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: inline-block;
}
.qcld_ai_ichart_s_view code {
    white-space: nowrap !important;
}


/* --- Ultra-Premium List View --- */
#qcld_ai_saved_charts_list.qcld-list-view {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Tighter gap for sleek rows */
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    border-radius: 8px;
    transition: all 0.2s ease;
}

#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card:last-child {
    border-bottom: none;
}

#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card:hover {
    background: #f8fafc;
    box-shadow: inset 4px 0 0 0 #3b82f6; /* Beautiful left border indicator on hover */
}

/* Organize the left side content horizontally */
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    margin-bottom: 0;
    flex: 1;
}

/* Make thumbnail very small in list view */
#qcld_ai_saved_charts_list.qcld-list-view .qcld-mini-chart-preview {
    width: 48px;
    height: 48px;
    margin: 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    padding: 4px;
    flex-shrink: 0;
}

/* Adjust Title for horizontal alignment */
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-title-text {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    min-width: 180px;
}

/* Adjust Type Badge */
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-type-text {
    margin: 0;
    padding: 4px 10px;
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 600;
}

/* Adjust Shortcode Box */
#qcld_ai_saved_charts_list.qcld-list-view .qcld_ai_ichart_s_view {
    margin: 0;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 6px;
    color: #475569;
    max-width: 250px;
}

/* Remove right-side top border since they are side-by-side */
#qcld_ai_saved_charts_list.qcld-list-view .qcld-chart-card-right-custom {
    border-top: none;
    padding: 0;
}


/* Fix D3 SVG overflowing out of the mini preview box in List View */
#qcld_ai_saved_charts_list.qcld-list-view .qcld-mini-chart-preview {
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 350px;
}

#qcld_ai_saved_charts_list.qcld-list-view .qcld-mini-chart-preview svg,
#qcld_ai_saved_charts_list.qcld-list-view .qcld-mini-chart-preview canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}


/* --- Dynamic Loading & Entry Animations --- */

/* 1. Staggered Card Entry Animation */
@keyframes fadeInUpCard {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qcld-chart-card {
    animation: fadeInUpCard 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Stagger the delay so they load in a beautiful cascade */
.qcld-chart-card:nth-child(1) { animation-delay: 0.05s; }
.qcld-chart-card:nth-child(2) { animation-delay: 0.1s; }
.qcld-chart-card:nth-child(3) { animation-delay: 0.15s; }
.qcld-chart-card:nth-child(4) { animation-delay: 0.2s; }
.qcld-chart-card:nth-child(5) { animation-delay: 0.25s; }
.qcld-chart-card:nth-child(6) { animation-delay: 0.3s; }
.qcld-chart-card:nth-child(n+7) { animation-delay: 0.35s; }

/* 2. Mini Chart Preview Elastic Pop Animation */
@keyframes popInSVG {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.qcld-mini-chart-preview svg,
.qcld-mini-chart-preview canvas {
    animation: popInSVG 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: 0.2s; /* Starts right as the card settles */
}

/* 3. D3 Internal SVG Animations */

/* Draw-line effect for line charts (paths with no fill) */
@keyframes drawPath {
    from {
        stroke-dasharray: 1000;
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dasharray: 1000;
        stroke-dashoffset: 0;
    }
}

.qcld-mini-chart-preview svg path[fill="none"] {
    animation: drawPath 1.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    animation-delay: 0.3s;
}

/* Fade up effect for bars and pie slices */
.qcld-mini-chart-preview svg rect,
.qcld-mini-chart-preview svg path[fill]:not([fill="none"]):not([fill="white"]) {
    opacity: 0;
    transform-origin: bottom center;
    animation: fadeInUpCard 0.4s ease-out forwards;
}

/* Stagger the bars/slices */
.qcld-mini-chart-preview svg rect:nth-child(1), .qcld-mini-chart-preview svg path[fill]:not([fill="none"]):nth-child(1) { animation-delay: 0.30s; }
.qcld-mini-chart-preview svg rect:nth-child(2), .qcld-mini-chart-preview svg path[fill]:not([fill="none"]):nth-child(2) { animation-delay: 0.35s; }
.qcld-mini-chart-preview svg rect:nth-child(3), .qcld-mini-chart-preview svg path[fill]:not([fill="none"]):nth-child(3) { animation-delay: 0.40s; }
.qcld-mini-chart-preview svg rect:nth-child(4), .qcld-mini-chart-preview svg path[fill]:not([fill="none"]):nth-child(4) { animation-delay: 0.45s; }
.qcld-mini-chart-preview svg rect:nth-child(n+5), .qcld-mini-chart-preview svg path[fill]:not([fill="none"]):nth-child(n+5) { animation-delay: 0.50s; }

/* Custom Multi-Select */
.qcld-multi-select {
    position: relative;
    width: 100%;
    margin-top: 10px;
}
.qcld-multi-select-header {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #f8fafc;
    color: #334155;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    transition: all 0.2s;
    height: 42px;
    box-sizing: border-box;
}
.qcld-multi-select-header:hover {
    border-color: #3b82f6;
}
.qcld-multi-select-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 20px);
}
.qcld-multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}
.qcld-multi-select-option {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s;
}
.qcld-multi-select-option:hover {
    background: #f1f5f9;
}
.qcld-multi-select-option input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}
.qcld-multi-select-option label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
    color: #334155;
    width: 100%;
}

/* Hover animation for mini chart preview */
.qcld-mini-chart-preview {
    transition: transform 0.3s ease;
}
.qcld-mini-chart-preview:hover {
    transform: scale(1.05);
}

/* Fullscreen Preview */
.qcld-preview-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: #ffffff !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.qcld-preview-fullscreen svg,
.qcld-preview-fullscreen canvas {
    width: 90% !important;
    height: 90% !important;
    max-width: none !important;
    max-height: none !important;
}

/* Modal Fullscreen Button */
.qcld-ai-modal-fullscreen {
    position: absolute;
    top: 20px;
    right: 60px;
    cursor: pointer;
    font-size: 24px;
    color: #94a3b8;
    transition: color 0.2s, transform 0.2s;
}
.qcld-ai-modal-fullscreen:hover {
    color: #3b82f6;
    transform: scale(1.1);
}
.qcld-modal-fullscreen-active {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    top: 0 !important;
    margin: 0 !important;
}


/* CSV Preview Table Fixes - High Specificity */
#qcld_ai_csv_preview_area {
    width: 100% !important;
    max-width: 600px;
}
#qcld-ai-builder-modal #qcld_ai_csv_preview_table.wp-list-table {
    table-layout: auto !important;
    border-collapse: collapse !important;
    width: 100% !important;
    max-width: 600px;
}
#qcld-ai-builder-modal #qcld_ai_csv_preview_table.wp-list-table th,
#qcld-ai-builder-modal #qcld_ai_csv_preview_table.wp-list-table td {
    white-space: nowrap !important;
    padding: 8px 12px !important;
    text-align: left !important;
    font-size: 13px !important;
    color: #333 !important;
    border: 1px solid #e2e8f0 !important;
}
#qcld-ai-builder-modal #qcld_ai_csv_preview_table.wp-list-table thead th {
    background-color: #f1f5f9 !important;
    font-weight: 600 !important;
    color: #0f172a !important;
}


/* =====================================================
   Code Editor Overlay
   ===================================================== */
#qcld_ai_code_overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 30px;
    box-sizing: border-box;
    animation: fadeIn 0.2s ease-out;
}
#qcld_ai_code_overlay.is-visible {
    display: flex;
}
#qcld_ai_code_overlay_inner {
    background: #0f172a;
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255,255,255,0.05);
    animation: slideUp 0.25s ease-out;
    overflow: hidden;
}
#qcld_ai_code_overlay_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: #1e293b;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
#qcld_ai_code_overlay_title {
    display: flex;
    align-items: center;
    gap: 10px;
}
#qcld_ai_code_overlay_title h3 {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #e2e8f0 !important;
}
#qcld_ai_code_overlay_actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.qcld-overlay-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1;
    font-family: inherit;
}
.qcld-overlay-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin: 0;
}
.qcld-overlay-btn-secondary {
    background: rgba(255,255,255,0.08);
    color: #94a3b8;
    border: 1px solid rgba(255,255,255,0.1);
}
.qcld-overlay-btn-secondary:hover {
    background: rgba(255,255,255,0.15);
    color: #e2e8f0;
}
.qcld-overlay-btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.qcld-overlay-btn-primary:hover {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}
.qcld-overlay-btn-close {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 8px 10px;
    border-radius: 8px;
}
.qcld-overlay-btn-close:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}
#qcld_ai_code_overlay_body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 20px 24px 24px;
    gap: 14px;
}
#qcld_ai_code_overlay_hint {
    display: flex;
    align-items: flex-start;
    font-size: 13px;
    color: #64748b;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    line-height: 1.5;
}
#qcld_ai_code_overlay_hint .dashicons {
    color: #6366f1;
    flex-shrink: 0;
    margin-top: 1px;
    width: 16px;
    height: 16px;
    font-size: 16px;
}
#qcld_ai_code_overlay #qcld_ai_generated_data {
    flex: 1;
    width: 100%;
    min-height: 380px;
    resize: none;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.7;
    padding: 16px 20px;
    border-radius: 10px;
    background: #020617;
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.25);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    caret-color: #6366f1;
}
#qcld_ai_code_overlay #qcld_ai_generated_data:focus {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 0 0 3px rgba(99, 102, 241, 0.15);
}
/* Override the generic modal textarea styles for the overlay textarea */
#qcld_ai_code_overlay textarea {
    background: #020617 !important;
    color: #a5b4fc !important;
    border-color: rgba(99, 102, 241, 0.25) !important;
    padding: 16px 20px !important;
}

/* =====================================================
   D3 Code Editor Overlay
   ===================================================== */
#qcld_ai_d3_overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(6px);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 30px;
    box-sizing: border-box;
    animation: fadeIn 0.2s ease-out;
}
#qcld_ai_d3_overlay_inner {
    background: #0d1117;
    border-radius: 16px;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 80px -20px rgba(0,0,0,0.8), 0 0 0 1px rgba(16,185,129,0.15);
    animation: slideUp 0.25s ease-out;
    overflow: hidden;
}
#qcld_ai_d3_overlay_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: #161b22;
    border-bottom: 1px solid rgba(16,185,129,0.15);
    flex-shrink: 0;
}
#qcld_ai_d3_overlay_title {
    display: flex;
    align-items: center;
    gap: 10px;
}
#qcld_ai_d3_overlay_title h3 {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #e2e8f0 !important;
}
#qcld_ai_d3_overlay_actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.qcld-overlay-btn-d3-run {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}
.qcld-overlay-btn-d3-run:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
}
#qcld_ai_d3_overlay_body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 20px 24px 24px;
    gap: 14px;
}
#qcld_ai_d3_overlay_hint {
    display: flex;
    align-items: flex-start;
    font-size: 13px;
    color: #64748b;
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    line-height: 1.5;
    flex-shrink: 0;
}
#qcld_ai_d3_editor_wrap {
    display: flex;
    flex: 1;
    gap: 16px;
    overflow: hidden;
    min-height: 0;
}
#qcld_ai_d3_overlay_preview {
    flex: 1;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(16,185,129,0.2);
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
#qcld_ai_d3_overlay_preview svg {
    max-width: 100%;
    height: auto;
}
#qcld_ai_d3_overlay #qcld_ai_d3_code_editor {
    flex: 1.2;
    resize: none;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.7;
    padding: 16px 20px;
    border-radius: 10px;
    background: #020617;
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.25);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    outline: none;
    caret-color: #10b981;
    transition: border-color 0.2s;
    min-height: 300px;
}
#qcld_ai_d3_overlay #qcld_ai_d3_code_editor:focus {
    border-color: rgba(16,185,129,0.6);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 0 0 3px rgba(16,185,129,0.12);
}
/* Show preview actions as flex when shown */
#qcld_ai_preview_actions { display: none; }
#qcld_ai_preview_actions.is-visible { display: flex !important; }
