<?php
namespace Storzen;
defined('ABSPATH') || exit;

/**
 * Section — a group of fields inside a Tab.
 * layout('grid')     → 4-column toggle cards (widget-manager style)
 * layout('settings') → label + control rows (default)
 */
class Section {
    /** @var string */  protected $slug;
    /** @var string */  protected $title;
    /** @var string */  protected $description = '';
    /** @var string */  protected $layout      = 'settings';
    /** @var int    */  protected $columns      = 4;
    /** @var Tab|null */ protected $tab         = null;
    /** @var \Storzen\Contracts\Field[] */ protected $fields = array();

    /** @return static */
    public static function make( $slug, $title = '' ) {
        return new static( $slug, $title );
    }

    public function __construct( $slug, $title = '' ) {
        $this->slug  = $slug;
        $this->title = $title;
    }

    /** @return static */ public function description( $d )     { $this->description = $d; return $this; }
    /** @return static */ public function set_description( $d ) { return $this->description($d); }
    /** @return static */ public function layout( $l )          { $this->layout = $l;      return $this; }
    /** @return static */ public function columns( $c )         { $this->columns = (int)$c; return $this; }

    /** @return static */
    public function add_field( \Storzen\Contracts\Field $field ) {
        $this->fields[] = $field;
        return $this;
    }

    public function set_tab( Tab $tab ) { $this->tab = $tab; }

    public function get_slug()        { return $this->slug; }
    public function get_title()       { return $this->title; }
    public function get_description() { return $this->description; }
    public function get_layout()      { return $this->layout; }
    public function get_columns()     { return $this->columns; }
    public function get_fields()      { return $this->fields; }
    public function get_tab()         { return $this->tab; }
}
