<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <h3 class="mb-4 fw-bold text-dark"><i class="bi bi-building me-2"></i> <?php echo __('company_profile'); ?></h3>
            
            <?php if ($message): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <?php echo $message; ?>
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            <?php endif; ?>

            <div class="card shadow-sm border-0">
                <div class="card-header py-3 d-flex align-items-center">
                    <i class="bi bi-info-circle me-2"></i>
                    <h5 class="mb-0 fw-bold"><?php echo __('company_details'); ?></h5>
                </div>
                <div class="card-body p-4">
                    <form action="settings.php" method="POST" enctype="multipart/form-data">
                        <div class="row g-4">
                            <!-- Basic Information -->
                            <div class="col-md-6">
                                <label for="company_name" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('company_name'); ?></label>
                                <input type="text" class="form-control" id="company_name" name="company_name" value="<?php echo htmlspecialchars($settings['company_name'] ?? ''); ?>" required>
                            </div>
                            <div class="col-md-6">
                                <label for="company_email" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('company_email'); ?></label>
                                <input type="email" class="form-control" id="company_email" name="company_email" value="<?php echo htmlspecialchars($settings['company_email'] ?? ''); ?>">
                            </div>

                            <div class="col-md-6">
                                <label for="company_phone" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('company_phone'); ?></label>
                                <input type="text" class="form-control" id="company_phone" name="company_phone" value="<?php echo htmlspecialchars($settings['company_phone'] ?? ''); ?>">
                            </div>
                            <div class="col-md-6">
                                <label for="company_address" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('company_address'); ?></label>
                                <input type="text" class="form-control" id="company_address" name="company_address" value="<?php echo htmlspecialchars($settings['company_address'] ?? ''); ?>">
                            </div>

                            <!-- Registration Details -->
                            <div class="col-md-4">
                                <label for="company_ctr_no" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('ctr_no'); ?></label>
                                <input type="text" class="form-control" id="company_ctr_no" name="company_ctr_no" value="<?php echo htmlspecialchars($settings['company_ctr_no'] ?? ''); ?>">
                            </div>
                            <div class="col-md-4">
                                <label for="company_registration_no" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('registration_no'); ?></label>
                                <input type="text" class="form-control" id="company_registration_no" name="company_registration_no" value="<?php echo htmlspecialchars($settings['company_registration_no'] ?? ''); ?>">
                            </div>
                            <div class="col-md-4">
                                <label for="company_vat_no" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('vat_no'); ?></label>
                                <input type="text" class="form-control" id="company_vat_no" name="company_vat_no" value="<?php echo htmlspecialchars($settings['company_vat_no'] ?? ''); ?>">
                            </div>

                                                        <!-- Timezone & Working Hours -->
                            <div class="col-12 mt-4"><hr></div>
                            <div class="col-md-4">
                                <label for="timezone" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('timezone'); ?></label>
                                <select class="form-select" id="timezone" name="timezone">
                                    <?php
                                    $timezones = DateTimeZone::listIdentifiers();
                                    $current_tz = $settings['timezone'] ?? 'UTC';
                                    foreach ($timezones as $tz) {
                                        $selected = ($tz === $current_tz) ? 'selected' : '';
                                        echo "<option value=\"{$tz}\" {$selected}>{$tz}</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="col-md-4">
                                <label for="working_hours_start" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('working_hours_start'); ?></label>
                                <input type="time" class="form-control" id="working_hours_start" name="working_hours_start" value="<?php echo htmlspecialchars($settings['working_hours_start'] ?? '08:00'); ?>">
                            </div>
                            <div class="col-md-4">
                                <label for="working_hours_end" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('working_hours_end'); ?></label>
                                <input type="time" class="form-control" id="working_hours_end" name="working_hours_end" value="<?php echo htmlspecialchars($settings['working_hours_end'] ?? '17:00'); ?>">
                            </div>

                            <!-- Branding -->
                            <div class="col-md-6 mt-5">
                                <label for="company_logo" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('company_logo'); ?></label>
                                <?php if (!empty($settings['company_logo'])): ?>
                                <div class="mb-2">
                                    <img src="<?php echo htmlspecialchars($settings['company_logo']); ?>" alt="Logo" class="img-thumbnail" style="max-height: 80px;">
                                </div>
                                <?php endif; ?>
                                <input type="file" class="form-control" id="company_logo" name="company_logo" accept="image/*">
                            </div>
                            <div class="col-md-6 mt-5">
                                <label for="company_favicon" class="form-label fw-semibold text-muted small text-uppercase"><?php echo __('company_favicon'); ?></label>
                                <?php if (!empty($settings['company_favicon'])): ?>
                                <div class="mb-2">
                                    <img src="<?php echo htmlspecialchars($settings['company_favicon']); ?>" alt="Favicon" class="img-thumbnail" style="max-height: 32px;">
                                </div>
                                <?php endif; ?>
                                <input type="file" class="form-control" id="company_favicon" name="company_favicon" accept="image/x-icon,image/png">
                            </div>

                            <div class="col-12 mt-5 text-end">
                                <button type="submit" name="submit" class="btn btn-primary btn-lg px-5">
                                    <i class="bi bi-check2-circle me-2"></i> <?php echo __('save_changes'); ?>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
