<!-- ============================================================ -->
<!-- EMPRESAS - Formulario crear/editar -->
<!-- ============================================================ -->

<div class="mb-6">
    <a href="<?= BASE_URL ?>?c=empresas" class="text-xs text-gray-400 hover:text-primary-400 transition-colors inline-flex items-center gap-1">
        <i class="fas fa-arrow-left"></i> Volver al listado
    </a>
</div>

<div class="glass-card rounded-2xl p-6 max-w-2xl">
    <h3 class="font-sora font-bold text-white text-lg mb-1">
        <?= $empresa ? 'Editar Empresa' : 'Nueva Empresa' ?>
    </h3>
    <p class="text-xs text-gray-500 mb-6">
        <?= $empresa ? 'Modifique los datos de la empresa proveedora' : 'Registre una nueva empresa proveedora' ?>
    </p>

    <form method="POST" action="<?= BASE_URL ?>?c=empresas&a=<?= $empresa ? 'actualizar' : 'guardar' ?>">
        <?php if ($empresa): ?>
        <input type="hidden" name="id" value="<?= $empresa['id'] ?>">
        <?php endif; ?>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
            <div class="md:col-span-2">
                <label class="block text-xs text-gray-400 mb-1.5 font-medium">Razón Social *</label>
                <input type="text" name="razon_social" value="<?= htmlspecialchars($empresa['razon_social'] ?? '') ?>" required 
                       class="input-glass w-full" placeholder="Ej: JYW REPUESTOS S.R.L.">
            </div>

            <div>
                <label class="block text-xs text-gray-400 mb-1.5 font-medium">RUC *</label>
                <input type="text" name="ruc" value="<?= htmlspecialchars($empresa['ruc'] ?? '') ?>" required
                       class="input-glass w-full" placeholder="20456789012" minlength="11" maxlength="11" pattern="\d{11}"
                       title="El RUC debe tener exactamente 11 dígitos numéricos">
            </div>

            <div>
                <label class="block text-xs text-gray-400 mb-1.5 font-medium">Teléfono</label>
                <input type="text" name="telefono" value="<?= htmlspecialchars($empresa['telefono'] ?? '') ?>" 
                       class="input-glass w-full" placeholder="Ej: 944922651">
            </div>

            <div class="md:col-span-2">
                <label class="block text-xs text-gray-400 mb-1.5 font-medium">Dirección</label>
                <input type="text" name="direccion" value="<?= htmlspecialchars($empresa['direccion'] ?? '') ?>" 
                       class="input-glass w-full" placeholder="Ej: Av. Industrial 456, Lima">
            </div>

            <div>
                <label class="block text-xs text-gray-400 mb-1.5 font-medium">Contacto</label>
                <input type="text" name="contacto" value="<?= htmlspecialchars($empresa['contacto'] ?? '') ?>" 
                       class="input-glass w-full" placeholder="Nombre del contacto">
            </div>

            <div>
                <label class="block text-xs text-gray-400 mb-1.5 font-medium">Email</label>
                <input type="email" name="email" value="<?= htmlspecialchars($empresa['email'] ?? '') ?>" 
                       class="input-glass w-full" placeholder="contacto@empresa.com">
            </div>
        </div>

        <div class="flex items-center justify-end gap-3">
            <a href="<?= BASE_URL ?>?c=empresas" class="px-6 py-2.5 rounded-xl text-sm font-medium text-gray-400 hover:text-white border border-white/10 hover:border-white/20 transition-colors">
                Cancelar
            </a>
            <button type="submit" class="btn-primary px-8 py-2.5 rounded-xl text-sm font-bold inline-flex items-center gap-2">
                <i class="fas fa-save"></i> <?= $empresa ? 'Actualizar' : 'Guardar' ?>
            </button>
        </div>
    </form>
</div>
