<?php
/**
 * ITSWEBER CMS – Call-to-Action Section
 *
 * Prominent CTA block with background image, text and up to 2 buttons.
 *
 * @author    Benny Weber (ITSWEBER)
 * @copyright © ITSWEBER – www.itsweber.de
 * @contact   kontakt@itsweber.de
 */

namespace App\Sections\Core;

use App\Sections\AbstractSection;
use App\Core\Request;

class CtaSection extends AbstractSection
{
    public static function typeKey(): string    { return 'cta'; }
    public static function label(): string      { return 'Call-to-Action'; }
    public static function category(): string   { return 'action'; }
    public static function description(): string { return 'Prominenter CTA-Block mit Hintergrundbild und Buttons'; }

    public static function iconSvg(): string
    {
        return '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">'
             . '<rect x="3" y="8" width="18" height="8" rx="2"/>'
             . '<line x1="8" y1="12" x2="16" y2="12"/>'
             . '<polyline points="13 9 16 12 13 15"/>'
             . '</svg>';
    }

    public function buildData(Request $request): array
    {
        $data = [
            'title'              => trim($request->input('title', '')),
            'eyebrow'            => trim($request->input('eyebrow', '')),
            'text'               => trim($request->input('text', '')),
            'cta_text'           => trim($request->input('cta_text', '')),
            'cta_url'            => trim($request->input('cta_url', '')),
            'cta2_text'          => trim($request->input('cta2_text', '')),
            'cta2_url'           => trim($request->input('cta2_url', '')),
            'image'              => trim($request->input('image', '')),
            'color_scheme'       => self::sanitizeToken(trim($request->input('color_scheme', '')),    self::allowedColorScheme()),
            'text_align'         => self::sanitizeToken(trim($request->input('text_align', '')),      self::allowedSectionAlign()),
            'overlay_strength'   => self::sanitizeToken(trim($request->input('overlay_strength', '')), self::allowedOverlay()),
            'section_text_color' => self::sanitizeToken(trim($request->input('section_text_color', '')), self::allowedSectionTextColor()),
        ];

        return $this->mergeThemeExtras($data, $request);
    }

    public function defaultData(): array
    {
        return [
            'title' => '', 'eyebrow' => '', 'text' => '',
            'cta_text' => '', 'cta_url' => '', 'cta2_text' => '', 'cta2_url' => '',
            'image' => '', 'color_scheme' => '', 'text_align' => '',
            'overlay_strength' => '', 'section_text_color' => '',
        ];
    }
}
