/**
 * TextFlow — Styles de la sidebar Gutenberg
 * Palette : dark #111827 · amber #f59e0b · slate text
 */

/* ---- Conteneur principal ---- */
.aicf-gb-panel {
    padding: 12px;
    font-size: 13px;
    color: #1e1e1e;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Header info (badge plan + compteur) ---- */
.aicf-gb-header-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.aicf-gb-plan-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    padding: 2px 7px;
    border-radius: 3px;
    line-height: 1.5;
}

.aicf-plan-free {
    background: #e5e7eb;
    color: #374151;
}

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

/* ---- Compteur quotidien ---- */
.aicf-gb-daily {
    font-size: 11px;
    color: #6b7280;
}

.aicf-daily-limit-low {
    color: #92400e;
    font-weight: 600;
}

.aicf-daily-limit-reached {
    color: #dc2626;
    font-weight: 600;
}

/* ---- Templates ---- */
.aicf-gb-templates {
    margin-bottom: 8px;
}

.aicf-gb-templates-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    display: block;
    margin-bottom: 5px;
}

.aicf-gb-templates-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.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;
}

.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;
}

/* ---- Textarea prompt ---- */
.aicf-gb-prompt {
    width: 100%;
    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;
    margin-bottom: 0;
    min-height: 80px;
}

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

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

/* ---- Boutons ---- */
.aicf-gb-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-align: center;
    box-sizing: border-box;
}

.aicf-gb-btn-primary {
    background: #f59e0b;
    color: #111827;
}

.aicf-gb-btn-primary:hover:not(:disabled) {
    background: #d97706;
}

.aicf-gb-btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.aicf-gb-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ---- Barre d'action (retour + rescan + générer) ---- */
.aicf-gb-action-bar {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.aicf-gb-btn-back,
.aicf-gb-btn-rescan {
    padding: 10px 12px;
    background: #f3f4f6;
    color: #b45309;
    border: 1px solid #d1d5db;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    width: auto;
    margin-top: 0;
    flex-shrink: 0;
    border-radius: 6px;
}

.aicf-gb-btn-back:hover:not(:disabled),
.aicf-gb-btn-rescan:hover:not(:disabled) {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.aicf-gb-btn-back:disabled,
.aicf-gb-btn-rescan:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aicf-gb-btn-flex {
    flex: 1;
    margin-top: 0;
}

/* ---- Liste de blocs ---- */
.aicf-gb-block-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: 7px 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:not(:disabled) {
    background: #f59e0b;
    color: #111827;
    border-color: #f59e0b;
}

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

/* Container scrollable */
.aicf-wl-items {
    max-height: 220px;
    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;
}

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

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

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

/* 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;
    flex-shrink: 0;
}

.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 bloc */
.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-default    { background: #f3f4f6; color: #374151; }

/* Badge PRO sur les blocs verrouillés */
.aicf-wl-pro-badge {
    display: inline-block;
    background: #1e293b;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 1px 4px;
    border-radius: 2px;
    vertical-align: middle;
    margin-left: 4px;
}

/* 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;
}

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

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

/* ---- Zone d'actions par bloc (régénérer / revert / retirer) ---- */
.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:not(:disabled) {
    color: #b45309;
    background: #fffbeb;
}

.aicf-widget-revert:hover:not(:disabled) {
    color: #f59e0b;
    background: #fffbeb;
}

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

@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;
}

.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:not(:disabled) {
    color: #ef4444;
    background: #fef2f2;
}

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

/* ---- Estimation des coûts (Pro) ---- */
.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;
}

/* ---- Zone de statut ---- */
.aicf-gb-status {
    margin-top: 8px;
    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; }
}
