/**
 * TextFlow — Styles du panneau éditeur Elementor.
 * Palette : dark #111827 · amber #f59e0b · slate text
 */

/* ---- Panneau principal ---- */
#aicf-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 340px;
    background: #fff;
    border: 1px solid #d5dadf;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    color: #1e1e1e;
    overflow: hidden;
    border-top: 3px solid #f59e0b;
}

/* ---- Header du panneau ---- */
#aicf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #111827;
    color: #fff;
    cursor: default;
}

.aicf-panel-title {
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.3px;
}

#aicf-panel-toggle {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#aicf-panel-toggle:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

/* ---- Corps du panneau ---- */
#aicf-panel-body {
    padding: 14px;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    max-height: 600px;
    opacity: 1;
    overflow-y: auto;
}

#aicf-panel-body.aicf-collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* ---- Textarea du prompt ---- */
#aicf-prompt {
    width: 100%;
    min-height: 70px;
    padding: 10px;
    border: 1px solid #d5dadf;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s;
    color: #1e1e1e;
    background: #f9fafb;
}

#aicf-prompt:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
    background: #fff;
}

#aicf-prompt::placeholder {
    color: #9ca3af;
}

/* ---- Boutons Scanner / Générer / Rescanner ---- */
#aicf-scan-btn,
#aicf-generate-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px 16px;
    background: #f59e0b;
    color: #111827;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.3px;
}

#aicf-action-bar {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

#aicf-action-bar #aicf-generate-btn {
    flex: 1;
    margin-top: 0;
}

#aicf-rescan-btn {
    padding: 10px 12px;
    background: #f3f4f6;
    color: #b45309;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

#aicf-rescan-btn:hover {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

#aicf-rescan-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#aicf-scan-btn:hover,
#aicf-generate-btn:hover {
    background: #d97706;
}

#aicf-scan-btn:active,
#aicf-generate-btn:active {
    transform: scale(0.98);
}

#aicf-scan-btn:disabled,
#aicf-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ---- Zone de statut ---- */
#aicf-status {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

.aicf-status-idle {
    background: #f3f4f6;
    color: #6b7280;
}

.aicf-status-loading {
    background: #eff6ff;
    color: #2563eb;
    animation: aicf-pulse 1.5s ease-in-out infinite;
}

.aicf-status-success {
    background: #ecfdf5;
    color: #059669;
}

.aicf-status-error {
    background: #fef2f2;
    color: #dc2626;
}

/* ---- Progress bar ---- */
.aicf-progress-text {
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

.aicf-progress-eta {
    font-weight: 700;
    opacity: 0.85;
}

.aicf-progress-bar-track {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}

.aicf-progress-bar-fill {
    height: 100%;
    background: #f59e0b;
    border-radius: 2px;
    transition: width 0.25s ease;
    width: 0%;
}

.aicf-status-success .aicf-progress-bar-fill {
    background: #059669;
}

.aicf-status-error .aicf-progress-bar-fill {
    background: #dc2626;
}

@keyframes aicf-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ==============================================================
   Liste des widgets (étape de sélection)
   ============================================================== */

#aicf-widget-list {
    margin-top: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

/* Header de la liste */
.aicf-wl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.aicf-wl-count {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
}

.aicf-wl-toggle-all {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: #b45309;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.aicf-wl-toggle-all:hover {
    background: #f59e0b;
    color: #111827;
    border-color: #f59e0b;
}

.aicf-wl-toggle-all:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Container scrollable des items */
.aicf-wl-items {
    max-height: 200px;
    overflow-y: auto;
}

/* Item individuel */
.aicf-wl-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s, opacity 0.2s;
}

.aicf-wl-item:last-child {
    border-bottom: none;
}

.aicf-wl-item:hover {
    background: #f9fafb;
}

/* Widget marqué comme généré */
.aicf-wl-item-done {
    background: #ecfdf5;
}

.aicf-wl-item-done .aicf-wl-preview {
    color: #059669;
    font-style: italic;
}

/* Checkbox custom */
.aicf-wl-checkbox-label {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.aicf-wl-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.aicf-wl-checkmark {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 3px;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}

.aicf-wl-checkbox-label input[type="checkbox"]:checked + .aicf-wl-checkmark {
    background: #f59e0b;
    border-color: #f59e0b;
}

.aicf-wl-checkbox-label input[type="checkbox"]:checked + .aicf-wl-checkmark::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4px;
    width: 4px;
    height: 8px;
    border: solid #111827;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.aicf-wl-checkbox-label input[type="checkbox"]:disabled + .aicf-wl-checkmark {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Info du widget (type + aperçu) */
.aicf-wl-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* Badge de type */
.aicf-wl-type {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 3px;
    width: fit-content;
}

.aicf-wl-type-heading {
    background: #fef3c7;
    color: #92400e;
}

.aicf-wl-type-text {
    background: #dbeafe;
    color: #1e40af;
}

.aicf-wl-type-button {
    background: #d1fae5;
    color: #065f46;
}

.aicf-wl-type-box {
    background: #ede9fe;
    color: #5b21b6;
}

.aicf-wl-type-testimonial {
    background: #fce7f3;
    color: #9d174d;
}

.aicf-wl-type-data {
    background: #ffedd5;
    color: #9a3412;
}

.aicf-wl-type-cta {
    background: #e0e7ff;
    color: #3730a3;
}

.aicf-wl-type-alert {
    background: #fef2f2;
    color: #991b1b;
}

.aicf-wl-type-default {
    background: #f3f4f6;
    color: #374151;
}

/* Badge nombre de champs */
.aicf-wl-field-count {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    font-size: 9px;
    font-weight: 600;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.1);
    vertical-align: middle;
}

/* Aperçu du texte */
.aicf-wl-preview {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bouton retirer (×) */
.aicf-widget-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #d1d5db;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
}

.aicf-widget-remove:hover {
    color: #ef4444;
    background: #fef2f2;
}

.aicf-widget-remove:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ==============================================================
   Prompt templates
   ============================================================== */

.aicf-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    margin-bottom: 8px;
}

.aicf-templates-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    margin-right: 2px;
}

.aicf-tpl-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 11px;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.aicf-tpl-btn:hover {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.aicf-tpl-btn.aicf-tpl-active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #111827;
    font-weight: 700;
}

/* ==============================================================
   Options row (ton + style titres)
   ============================================================== */

.aicf-options-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.aicf-option-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.aicf-option-group label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
}

.aicf-option-group select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #d5dadf;
    border-radius: 5px;
    font-size: 12px;
    font-family: inherit;
    color: #1e1e1e;
    background: #f9fafb;
    cursor: pointer;
    transition: border-color 0.2s;
}

.aicf-option-group select:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

/* ==============================================================
   Cost estimation
   ============================================================== */

.aicf-cost-estimate {
    margin-top: 8px;
    padding: 6px 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
}

/* ==============================================================
   Widget actions (regenerate, revert, remove)
   ============================================================== */

.aicf-wl-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.aicf-widget-regen,
.aicf-widget-revert {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
}

.aicf-widget-regen:hover {
    color: #b45309;
    background: #fffbeb;
}

.aicf-widget-revert:hover {
    color: #f59e0b;
    background: #fffbeb;
}

.aicf-widget-regen:disabled,
.aicf-widget-revert:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Animation de spin pour le bouton régénérer */
@keyframes aicf-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.aicf-widget-regen.aicf-spinning {
    animation: aicf-spin 0.8s linear infinite;
    color: #f59e0b;
}

/* ==============================================================
   Back to prompt button
   ============================================================== */

#aicf-back-to-prompt {
    padding: 10px 12px;
    background: #f3f4f6;
    color: #b45309;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

#aicf-back-to-prompt:hover {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

#aicf-back-to-prompt:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==============================================================
   Plan badge (FREE / PRO)
   ============================================================== */

.aicf-plan-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    padding: 2px 6px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 6px;
    line-height: 1.4;
}

.aicf-plan-free {
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
}

.aicf-plan-pro {
    background: #1e293b;
    color: #fff;
}

/* ==============================================================
   Daily generation limit counter
   ============================================================== */

.aicf-daily-limit {
    padding: 6px 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    margin-bottom: 8px;
}

.aicf-daily-limit-low {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.aicf-daily-limit-reached {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ==============================================================
   Locked template buttons
   ============================================================== */

.aicf-tpl-btn.aicf-tpl-locked {
    opacity: 0.5;
    border-style: dashed;
    cursor: not-allowed;
}

.aicf-tpl-btn.aicf-tpl-locked:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #9ca3af;
}

/* ==============================================================
   Locked widget items (Pro-only widgets)
   ============================================================== */

.aicf-wl-item-locked {
    opacity: 0.5;
}

.aicf-wl-item-locked .aicf-wl-preview {
    color: #d1d5db;
    font-style: italic;
}

.aicf-wl-pro-badge {
    display: inline-block;
    background: #1e293b;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 2px;
    vertical-align: middle;
    margin-left: 3px;
}
