/* Admin CSS for Elementor AI Translator */

/* NUCLEAR OPTION: Hide Elementor bar immediately on page load - before JavaScript runs */
#e-admin-top-bar-root,
.e-admin-top-bar,
.e-admin-top-bar--active,
[id*="e-admin-top-bar"],
[class*="e-admin-top-bar"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    pointer-events: none !important;
}

/* Remove Elementor body classes effects */
body.e-admin-top-bar--active,
body[class*="e-admin-top-bar"] {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Specific targeting for our plugin pages */
body.toplevel_page_ai-translator-for-elementor-polylang #e-admin-top-bar-root,
body.ai-translator_page_ai-translator-for-elementor-polylang-settings #e-admin-top-bar-root,
body.admin_page_aitrfoel-debug #e-admin-top-bar-root,
body[class*="ai-translator-for-elementor-polylang"] #e-admin-top-bar-root,
body[class*="ai-translator-for-elementor-polylang"] .e-admin-top-bar,
body[class*="ai-translator-for-elementor-polylang"] .e-admin-top-bar--active {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Hide Elementor footer on our plugin pages */
body.toplevel_page_ai-translator-for-elementor-polylang #wpfooter #footer-left,
body.ai-translator_page_ai-translator-for-elementor-polylang-settings #wpfooter #footer-left,
body.admin_page_aitrfoel-debug #wpfooter #footer-left,
/* Also target any Elementor footer content directly */
body[class*="ai-translator-for-elementor-polylang"] #footer-left p,
/* Target any content mentioning Elementor */
body[class*="ai-translator-for-elementor-polylang"] #footer-left *:contains("Elementor") {
    display: none !important;
    visibility: hidden !important;
}

/* Reset footer styling on our plugin pages */
body.toplevel_page_ai-translator-for-elementor-polylang #wpfooter,
body.ai-translator_page_ai-translator-for-elementor-polylang-settings #wpfooter,
body.admin_page_aitrfoel-debug #wpfooter {
    margin-top: 20px;
}

/* Main wrapper
   IMPORTANT: Scope to plugin wrappers only; avoid styling core .wrap globally */
.aitrfoel-admin-wrapper, .aitrfoel-dashboard-wrapper {
    width: calc(100% - 36px);
    max-width: none;
    margin: 20px 36px 20px 0;
    position: relative;
}


/* Plugin Header - Full Width */
.aitrfoel-plugin-header {
    background: #fff;
    margin: -20px -36px 20px -20px;
    padding: 8px 20px;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
    z-index: 1;
    /* Stretch to container edges using negative margins; avoid viewport overflow */
}

.aitrfoel-plugin-title {
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1f;
    margin: 0;
    line-height: 1.4;
}

.aitrfoel-breadcrumb-separator {
    color: #666;
    margin: 0 4px;
    font-weight: 300;
    font-size: 14px;
}

.aitrfoel-current-page {
    color: #2271b1;
    font-weight: 500;
    font-size: 14px;
}

/* Cards */
.aitrfoel-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.aitrfoel-card h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

/* Status messages */
#aitrfoel-status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 4px;
    display: none;
}

#aitrfoel-status.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    display: block;
}

#aitrfoel-status.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    display: block;
}

#aitrfoel-status.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    display: block;
}

/* String selection area */
#aitrfoel-string-selection-area {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

#aitrfoel-string-list {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    height: 400px;
    overflow-y: auto;
}

#aitrfoel-string-list p {
    margin: 0;
    padding: 8px 0;
    border-bottom: 1px solid #f1f3f5;
}

#aitrfoel-string-list p:last-child {
    border-bottom: none;
}

#aitrfoel-string-list label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    padding: 5px;
    transition: background 0.2s;
}

#aitrfoel-string-list label:hover {
    background: #f8f9fa;
    border-radius: 4px;
}

#aitrfoel-string-list input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    flex-shrink: 0;
}

.aitrfoel-string-preview {
    flex: 1;
    word-break: break-word;
    line-height: 1.5;
}

/* Highlight HTML tags in preview */
.aitrfoel-string-preview code {
    background: #fee;
    color: #c00;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Select all checkbox */
#aitrfoel-select-all {
    margin-right: 8px;
}

label[for="aitrfoel-select-all"] {
    font-weight: 600;
    color: #2271b1;
}

/* Buttons */
.aitrfoel-button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

#aitrfoel-fetch-strings-button,
#aitrfoel-translate-button {
    min-width: 150px;
}

/* Spinner override */
.spinner.is-active {
    float: none;
    margin-left: 10px;
}

/* Form table improvements */
.form-table th {
    width: 200px;
}

.form-table select {
    min-width: 300px;
}

/* Progress bar */
.aitrfoel-progress-bar {
    width: 100%;
    height: 30px;
    background: #f1f3f5;
    border-radius: 15px;
    overflow: hidden;
    margin: 20px 0;
}

.aitrfoel-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2271b1, #135e96);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}



/* Settings page */
.aitrfoel-settings-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.aitrfoel-settings-section h3 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

/* API key field */
#eat_openai_api_key {
    width: 100%;
    max-width: 500px;
    font-family: monospace;
}

/* Model selector */
.aitrfoel-model-selector {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.aitrfoel-model-option {
    flex: 1;
    padding: 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.aitrfoel-model-option:hover {
    border-color: #2271b1;
    background: #f0f8ff;
}

.aitrfoel-model-option.selected {
    border-color: #2271b1;
    background: #e7f3ff;
}

.aitrfoel-model-option h4 {
    margin: 0 0 5px 0;
    color: #1d2327;
}

.aitrfoel-model-option p {
    margin: 0;
    color: #646970;
    font-size: 0.9em;
}

/* Stats dashboard */
.aitrfoel-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.aitrfoel-stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.aitrfoel-stat-card.aitrfoel-stat-flex {
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 15px;
}

.aitrfoel-stat-card.aitrfoel-stat-flex .aitrfoel-stat-label {
    flex: 1;
    margin: 0;
}

.aitrfoel-stat-card.aitrfoel-stat-flex .aitrfoel-stat-number {
    margin: 0;
    flex-shrink: 0;
}

.aitrfoel-stat-number {
    font-size: 2em;
    font-weight: 700;
    color: #2271b1;
    margin: 10px 0;
}

.aitrfoel-stat-label {
    color: #646970;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.aitrfoel-buy-tokens-btn {
    background: #0073aa;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    transition: background-color 0.2s;
    margin-left: 10px;
    flex-shrink: 0;
}

.aitrfoel-buy-tokens-btn:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
}

/* Empty state */
.aitrfoel-empty-state {
    text-align: center;
    padding: 40px;
    color: #646970;
}

.aitrfoel-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* Translation Success UI */
.aitrfoel-translation-success {
    padding: 20px;
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
    border-left: 4px solid #28a745;
    border-radius: 8px;
    margin: 15px 0;
}

.aitrfoel-success-message {
    margin-bottom: 15px;
}

.aitrfoel-success-message strong {
    font-size: 1.1em;
    color: #155724;
    display: block;
    margin-bottom: 5px;
}

.aitrfoel-success-message p {
    margin: 0;
    color: #155724;
    opacity: 0.9;
}

.aitrfoel-action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.aitrfoel-action-buttons .button {
    min-width: 140px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.aitrfoel-action-buttons .button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.aitrfoel-preview-btn {
    background: linear-gradient(135deg, #007cba 0%, #0073aa 100%) !important;
    border-color: #0073aa !important;
    color: white !important;
    font-weight: 600;
}

.aitrfoel-preview-btn:hover {
    background: linear-gradient(135deg, #005a87 0%, #004c75 100%) !important;
    border-color: #004c75 !important;
}

.aitrfoel-publish-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    border-color: #28a745 !important;
    color: white !important;
    font-weight: 600;
}

.aitrfoel-publish-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #17a2b8 100%) !important;
    border-color: #218838 !important;
}

.aitrfoel-translation-details {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

.aitrfoel-translation-details strong {
    color: #495057;
    font-weight: 600;
}

/* Button loading states */
.aitrfoel-preview-btn:disabled,
.aitrfoel-publish-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Success message improvements */
#aitrfoel-status.success {
    border: none;
    background: transparent;
    padding: 0;
}

#aitrfoel-status.success .aitrfoel-translation-success {
    animation: slideInUp 0.3s ease-out;
}

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

/* Post-translation button spacing */
.aitrfoel-button-group .button {
    margin-right: 8px;
}

.aitrfoel-button-group .button:last-child {
    margin-right: 0;
}

/* Enhanced reset button after translation */
#aitrfoel-reset-button {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%) !important;
    border-color: #6c757d !important;
    color: white !important;
    font-weight: 600;
    min-width: 200px;
}

#aitrfoel-reset-button:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%) !important;
    border-color: #5a6268 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Responsive */
@media (max-width: 782px) {
    .form-table th {
        width: auto;
        display: block;
        margin-bottom: 5px;
    }
    
    .form-table td {
        display: block;
        margin-left: 0;
    }
    
    .aitrfoel-model-selector {
        flex-direction: column;
    }
    
    .aitrfoel-button-group {
        flex-direction: column;
    }
    
    #aitrfoel-fetch-strings-button,
    #aitrfoel-translate-button {
        width: 100%;
    }
    
    .aitrfoel-action-buttons {
        flex-direction: column;
    }
    
    .aitrfoel-action-buttons .button {
        width: 100%;
        min-width: auto;
    }
}

/* Theme Compatibility Popup Styles */
.theme-fields-info {
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 2px 6px;
    background: #f0f6fc;
    border: 1px solid #0073aa;
}

.theme-fields-info:hover {
    background: #0073aa;
    color: white !important;
    transform: scale(1.05);
}

.theme-fields-popup ul {
    list-style-type: none;
}

.theme-fields-popup ul li {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    padding: 5px 8px;
    margin: 3px 0;
}

.theme-fields-popup ul li:hover {
    background: #e9ecef;
}

.copy-fields-btn:hover {
    background: #005a87 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Animation for successful copy */
.copy-fields-btn.copied {
    background: #28a745 !important;
    transform: scale(1.05);
    transition: all 0.3s ease;
}

.copy-fields-btn.error {
    background: #dc3545 !important;
    transform: scale(1.05);
    transition: all 0.3s ease;
}

.copy-fields-btn {
    transition: all 0.2s ease;
}

.close-popup:hover {
    background: #e0e0e0 !important;
    color: #333 !important;
}

/* Animation for popup appearance */
.theme-fields-popup {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


/*Settings page*/

        .api-status {
            padding: 8px 12px;
            border-radius: 4px;
            font-weight: 500;
            border-left: 4px solid;
            background: #f8f9fa;
        }
        
        .api-status-success {
            color: #155724;
            background-color: #d4edda;
            border-color: #28a745;
        }
        
        .api-status-error {
            color: #721c24;
            background-color: #f8d7da;
            border-color: #dc3545;
        }
        
        .api-status-loading {
            color: #004085;
            background-color: #cce7ff;
            border-color: #007bff;
        }
        
        .api-status:empty {
            display: none;
        }
        
        #test-openai-api {
            margin-left: 0px;
        }
        
        #test-openai-api:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }
        .aitrfoel-status-green { background: #d4edda; color: #155724; padding: 10px 15px; border-radius: 4px; border-left: 4px solid #28a745; }
        .aitrfoel-status-yellow { background: #fff3cd; color: #856404; padding: 10px 15px; border-radius: 4px; border-left: 4px solid #ffc107; }
        .aitrfoel-status-red { background: #f8d7da; color: #721c24; padding: 10px 15px; border-radius: 4px; border-left: 4px solid #dc3545; }

/* License Information Styles - ENHANCED FOR VISIBILITY */
.aitrfoel-license-info,
table.form-table .aitrfoel-license-info,
table.form-table td .aitrfoel-license-info {
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
    padding: 15px !important;
    margin-bottom: 10px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.aitrfoel-license-status,
.aitrfoel-word-usage,
table.form-table .aitrfoel-license-status,
table.form-table .aitrfoel-word-usage {
    margin-bottom: 10px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.aitrfoel-plan-name,
table.form-table .aitrfoel-plan-name {
    background: #2271b1 !important;
    color: white !important;
    padding: 3px 8px !important;
    border-radius: 3px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.aitrfoel-usage-bar,
table.form-table .aitrfoel-usage-bar {
    background: #e9ecef !important;
    height: 8px !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    margin-top: 5px !important;
    position: relative !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
}

.aitrfoel-usage-progress,
table.form-table .aitrfoel-usage-progress {
    background: linear-gradient(90deg, #28a745 0%, #ffc107 70%, #dc3545 100%) !important;
    height: 100% !important;
    transition: width 0.3s ease !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    border-radius: 4px !important;
}

.aitrfoel-license-info .description {
    margin-top: 10px;
    margin-bottom: 5px;
}

.description {
    margin: 10px 0px!important;
}

#wpfooter {
    display:none!important;
}

/* Multilingual Plugin Badge Styles */
.aitrfoel-multilingual-info {
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
    padding: 15px !important;
    display: block !important;
}

.aitrfoel-plugin-badge {
    display: inline-block !important;
    padding: 6px 12px !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
}

.aitrfoel-plugin-badge.aitrfoel-plugin-active {
    background: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb !important;
}

.aitrfoel-plugin-badge.aitrfoel-plugin-missing {
    background: #fff3cd !important;
    color: #856404 !important;
    border: 1px solid #ffeeba !important;
}
