    <div class="card card-inverse card-info">
          <div class="card-header">
                <div class="row align-items-center justify-content-between">
                  <div class="col-sm-auto">
                      <h4 class="mb-10">Application Settings</h4>
                      <h6 class="card-subtitle">Setup Your Organization</h6>  
                  </div>
                </div>
              </div>
        <div class="col-sm-12 p-4">
    <?= form_open_multipart('admin/settings/save'); ?>

    <!-- Hidden ID so update happens -->
    
    <input type="hidden" name="id" value="<?= !empty($settings->id) ? $settings->id : '' ?>">

    <div class="row">
        <div class="col-md-6 form-group">
            <label>Organization Name</label>
            <input type="text" name="org_name" class="form-control"
                   value="<?= !empty($settings->org_name) ? html_escape($settings->org_name) : '' ?>">
        </div>
        <div class="col-md-6 form-group">
            <label>Tagline</label>
            <input type="text" name="org_tagline" class="form-control"
                   value="<?= !empty($settings->org_tagline) ? html_escape($settings->org_tagline) : '' ?>">
        </div>
    </div>

    <div class="form-group">
        <label>About</label>
        <textarea name="org_about" class="form-control" rows="3"><?= !empty($settings->org_about) ? html_escape($settings->org_about) : '' ?></textarea>
    </div>

    <div class="row">
        <div class="col-md-6 form-group">
            <label>Email</label>
            <input type="email" name="org_email" class="form-control"
                   value="<?= !empty($settings->org_email) ? html_escape($settings->org_email) : '' ?>">
        </div>
        <div class="col-md-6 form-group">
            <label>Phone</label>
            <input type="text" name="org_phone" class="form-control"
                   value="<?= !empty($settings->org_phone) ? html_escape($settings->org_phone) : '' ?>">
        </div>
    </div>

    <div class="row">
        <div class="col-md-6 form-group">
            <label>Website</label>
            <input type="text" name="org_website" class="form-control"
                   value="<?= !empty($settings->org_website) ? html_escape($settings->org_website) : '' ?>">
        </div>
        <div class="col-md-6 form-group">
            <label>Default Year</label>
            <input type="number" name="default_year" class="form-control"
                   value="<?= !empty($settings->default_year) ? html_escape($settings->default_year) : '' ?>">
        </div>
    </div>

    <div class="form-group">
        <label>Address</label>
        <textarea name="org_address" class="form-control" rows="2"><?= !empty($settings->org_address) ? html_escape($settings->org_address) : '' ?></textarea>
    </div>

    <div class="row">
        <div class="col-md-4 form-group">
            <label>Theme Topbar Color</label>
            <input type="color" name="theme_topbar_color" class="form-control"
                   value="<?= !empty($settings->theme_topbar_color) ? $settings->theme_topbar_color : '#ffffff' ?>">
        </div>
        <div class="col-md-4 form-group">
            <label>Theme Sidebar Color</label>
            <input type="color" name="theme_sidebar_color" class="form-control"
                   value="<?= !empty($settings->theme_sidebar_color) ? $settings->theme_sidebar_color : '#ffffff' ?>">
        </div>
        <div class="col-md-4 form-group">
            <label>Theme Body Color</label>
            <input type="color" name="theme_body_color" class="form-control"
                   value="<?= !empty($settings->theme_body_color) ? $settings->theme_body_color : '#ffffff' ?>">
        </div>
    </div>

    <!-- Upload fields with preview -->
    <?php
    $fields = [
        'logo_login'        => 'Logo (Login)',
        'logo_sidebar'      => 'Logo (Sidebar)',
        'logo_receipt'      => 'Logo (Receipt)',
        'favicon'           => 'Favicon',
        'login_background'  => 'Login Background'
    ];
    foreach ($fields as $field => $label): ?>
        <div class="form-group row">
          <div class="col-md-8">
            <label><?= $label ?></label>
            <input type="file" name="<?= $field ?>" class="form-control">
            <?php if (!empty($settings->$field)): ?>
                
            <?php endif; ?>
          </div>
          <div class="col-md-4">
            <div class="mt-2">
              <img src="<?= base_url('uploads/settings/' . $settings->$field) ?>" alt="<?= $label ?>" style="max-height:60px">
            </div>
          </div>
        </div>
        <hr>
    <?php endforeach; ?>

    <button type="submit" class="btn btn-primary mt-3">Save Settings</button>
</div>
<?= form_close(); ?>

    </div>